Merge branch 'master' into DATACOUCH-27
Conflicts: .gitignore
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,6 +5,5 @@ target/
|
||||
.project
|
||||
.settings/*
|
||||
|
||||
# IntelliJ IDEA
|
||||
*.iml
|
||||
.idea
|
||||
.idea/*
|
||||
14
pom.xml
14
pom.xml
@@ -18,8 +18,8 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<couchbase>1.1.9</couchbase>
|
||||
<jackson>2.2.2</jackson>
|
||||
<couchbase>1.2.0</couchbase>
|
||||
<jackson>2.2.3</jackson>
|
||||
<springdata.commons>1.6.1.RELEASE</springdata.commons>
|
||||
</properties>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>couchbase</groupId>
|
||||
<groupId>com.couchbase.client</groupId>
|
||||
<artifactId>couchbase-client</artifactId>
|
||||
<version>${couchbase}</version>
|
||||
</dependency>
|
||||
@@ -90,14 +90,6 @@
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>couchbase</id>
|
||||
<name>Couchbase Maven Repository</name>
|
||||
<url>http://files.couchbase.com/maven2/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-lib-release</id>
|
||||
<url>http://repo.springsource.org/libs-release-local</url>
|
||||
|
||||
@@ -104,7 +104,7 @@ public class CouchbaseDocument implements CouchbaseStorable {
|
||||
* @return the {@link CouchbaseDocument} for chaining.
|
||||
*/
|
||||
public final CouchbaseDocument put(final String key, final Object value) {
|
||||
verifyValueType(value.getClass());
|
||||
verifyValueType(value);
|
||||
|
||||
payload.put(key, value);
|
||||
return this;
|
||||
@@ -259,15 +259,19 @@ public class CouchbaseDocument implements CouchbaseStorable {
|
||||
* <p>If this is not the case, a {@link IllegalArgumentException} is
|
||||
* thrown.</p>
|
||||
*
|
||||
* @param clazz the class type to check and verify.
|
||||
* Objects that are NULL cannot be stored.
|
||||
*
|
||||
* @param value the object to verify its type.
|
||||
*/
|
||||
private void verifyValueType(final Class<?> clazz) {
|
||||
if (simpleTypeHolder.isSimpleType(clazz)) {
|
||||
return;
|
||||
private void verifyValueType(final Object value) {
|
||||
if(value == null) {
|
||||
throw new IllegalArgumentException("Attribute of type null cannot be stored.");
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Attribute of type "
|
||||
+ clazz.getCanonicalName() + " can not be stored and must be converted.");
|
||||
final Class<?> clazz = value.getClass();
|
||||
if (simpleTypeHolder.isSimpleType(clazz)) {
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Attribute of type " + clazz.getCanonicalName() + " cannot be stored and must be converted.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -179,6 +179,18 @@ public class CouchbaseTemplateTests {
|
||||
assertNotNull(beer.getActive());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotSaveNull() {
|
||||
final Map<String, String> things = new HashMap<String, String>();
|
||||
things.put("key", null);
|
||||
try {
|
||||
template.save(things);
|
||||
fail("We should not be able to store a NULL!");
|
||||
} catch(final IllegalArgumentException e) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A sample document with just an id and property.
|
||||
|
||||
Reference in New Issue
Block a user