DATAREST-150 - Added test case showing PUT now works correctly.

The JIRA issue asserts that PUT wasn't properly storing things. But now it does. A partial record causes all other fields to get nulled out. Added a test case to confirm this.

Original pull request: #134.
This commit is contained in:
Greg Turnquist
2014-02-05 16:29:54 -06:00
committed by Oliver Gierke
parent ba71362c15
commit 0a3738782d

View File

@@ -207,8 +207,10 @@ public class JpaWebTests extends AbstractWebIntegrationTests {
@Test
public void createThenPatch() throws Exception {
MockHttpServletResponse bilbo = postAndGet(new Link("/people"),
"{ \"firstName\" : \"Bilbo\", \"lastName\" : \"Baggins\" }", MediaType.APPLICATION_JSON);
Link peopleLink = discoverUnique("people");
MockHttpServletResponse bilbo = postAndGet(peopleLink, "{ \"firstName\" : \"Bilbo\", \"lastName\" : \"Baggins\" }",
MediaType.APPLICATION_JSON);
Link bilboLink = assertHasLinkWithRel("self", bilbo);
@@ -221,6 +223,31 @@ public class JpaWebTests extends AbstractWebIntegrationTests {
assertThat((String) JsonPath.read(frodo.getContentAsString(), "$.lastName"), equalTo("Baggins"));
}
/**
* @see DATAREST-150
*/
@Test
public void createThenPut() throws Exception {
Link peopleLink = discoverUnique("people");
MockHttpServletResponse bilbo = postAndGet(peopleLink,//
"{ \"firstName\" : \"Bilbo\", \"lastName\" : \"Baggins\" }",//
MediaType.APPLICATION_JSON);
Link bilboLink = assertHasLinkWithRel("self", bilbo);
assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.firstName"), equalTo("Bilbo"));
assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.lastName"), equalTo("Baggins"));
MockHttpServletResponse frodo = putAndGet(bilboLink,//
"{ \"firstName\" : \"Frodo\" }",//
MediaType.APPLICATION_JSON);
assertThat((String) JsonPath.read(frodo.getContentAsString(), "$.firstName"), equalTo("Frodo"));
assertNull(JsonPath.read(frodo.getContentAsString(), "$.lastName"));
}
@Test
public void listsSiblingsWithContentCorrectly() throws Exception {