DATAREST-959 - Fix adding elements to empty array in DomainObjectReader.
Original pull request: #246.
This commit is contained in:
committed by
Oliver Gierke
parent
83899bb42a
commit
0b1bbbab31
@@ -348,7 +348,7 @@ public class DomainObjectReader {
|
||||
private static Collection<Object> asCollection(Object source) {
|
||||
|
||||
if (source == null) {
|
||||
return Collections.emptyList();
|
||||
return new ArrayList<Object>();
|
||||
}
|
||||
|
||||
if (source instanceof Collection) {
|
||||
|
||||
@@ -390,6 +390,24 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.inner.items.get(0).some, is("value"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-959
|
||||
*/
|
||||
@Test
|
||||
public void writesArrayOverUndefinedValueForPut() throws Exception {
|
||||
|
||||
Parent source = new Parent();
|
||||
source.inner = new Child();
|
||||
source.inner.items = null;
|
||||
|
||||
JsonNode node = new ObjectMapper().readTree("{ \"inner\" : { \"items\" : [ { \"some\" : \"value\" } ] } }");
|
||||
|
||||
Parent result = reader.readPut((ObjectNode) node, source, new ObjectMapper());
|
||||
|
||||
assertThat(result.inner.items.size(), is(1));
|
||||
assertThat(result.inner.items.get(0).some, is("value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testname() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user