DATAREST-50 - Added test case demonstrating this issue no longer exists.

Properties with null values properly get rendered in JSON outputs. This was fixed some time ago. Added test case to prove it.

Original pull request: #132.
This commit is contained in:
Greg Turnquist
2014-02-03 19:31:33 -06:00
committed by Oliver Gierke
parent a5e7aebb65
commit 6e817c440b

View File

@@ -298,6 +298,27 @@ public class JpaWebTests extends AbstractWebIntegrationTests {
assertSiblingNames(frodosSiblingsLink, "Bilbo", "Merry");
}
/**
* @see DATAREST-50
*/
@Test
public void propertiesCanHaveNulls() throws Exception {
Link peopleLink = discoverUnique("people");
ObjectMapper mapper = new ObjectMapper();
Person frodo = new Person();
frodo.setFirstName("Frodo");
frodo.setLastName(null);
MockHttpServletResponse response = postAndGet(peopleLink, mapper.writeValueAsString(frodo),
MediaType.APPLICATION_JSON);
String responseBody = response.getContentAsString();
assertEquals(JsonPath.read(responseBody, "$.firstName"), "Frodo");
assertNull(JsonPath.read(responseBody, "$.lastName"));
}
private List<Link> preparePersonResources(Person primary, Person... persons) throws Exception {
Link peopleLink = discoverUnique("people");