DATAREST-1249 - Backport of tests.
The issue doesn't seem to need a fix in this branch as DomainObjectReader already contains the guard we apparently had lost when moving to 3.0.
This commit is contained in:
@@ -112,6 +112,7 @@ public class DomainObjectReaderUnitTests {
|
||||
mappingContext.getPersistentEntity(CollectionOfEnumWithMethods.class);
|
||||
mappingContext.getPersistentEntity(SampleWithReference.class);
|
||||
mappingContext.getPersistentEntity(Note.class);
|
||||
mappingContext.getPersistentEntity(WithNullCollection.class);
|
||||
mappingContext.afterPropertiesSet();
|
||||
|
||||
this.entities = new PersistentEntities(Collections.singleton(mappingContext));
|
||||
@@ -554,6 +555,18 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.tags, contains(second));
|
||||
}
|
||||
|
||||
@Test // DATAREST-1249
|
||||
public void mergesIntoUninitializedCollection() throws Exception {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode source = (ObjectNode) mapper.readTree("{ \"strings\" : [ \"value\" ] }");
|
||||
|
||||
WithNullCollection result = reader.readPut(source, new WithNullCollection(), mapper);
|
||||
|
||||
assertThat(result.strings, hasSize(1));
|
||||
assertThat(result.strings, hasItem("value"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T as(Object source, Class<T> type) {
|
||||
|
||||
@@ -768,4 +781,11 @@ public class DomainObjectReaderUnitTests {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// DATAREST-1249
|
||||
|
||||
@JsonAutoDetect(fieldVisibility = Visibility.ANY)
|
||||
static class WithNullCollection {
|
||||
List<String> strings;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user