diff --git a/hibernate-orm-rest-data-panache-quickstart/src/test/java/org/acme/hibernate/orm/panache/rest/entity/PeopleResourceTest.java b/hibernate-orm-rest-data-panache-quickstart/src/test/java/org/acme/hibernate/orm/panache/rest/entity/PeopleResourceTest.java index c167158154..cc3624a82d 100644 --- a/hibernate-orm-rest-data-panache-quickstart/src/test/java/org/acme/hibernate/orm/panache/rest/entity/PeopleResourceTest.java +++ b/hibernate-orm-rest-data-panache-quickstart/src/test/java/org/acme/hibernate/orm/panache/rest/entity/PeopleResourceTest.java @@ -6,7 +6,6 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -import java.time.LocalDate; import java.util.HashMap; import java.util.Map; @@ -66,12 +65,12 @@ void shouldListPersonsInDescending() { @Test void shouldListPersonsWithPageAndSize() { given().accept(ContentType.JSON) - .and().queryParam("page", 0) - .and().queryParam("size", 1) - .when().get("/my-people/all") - .then().statusCode(200) - .and().body("id", contains(1)) - .and().body("name", contains("John Johnson")); + .and().queryParam("page", 0) + .and().queryParam("size", 1) + .when().get("/my-people/all?sort=name") + .then().statusCode(200) + .and().body("id", contains(1)) + .and().body("name", contains("John Johnson")); } @Test @@ -119,27 +118,34 @@ void shouldDeleteNotBeExposed() { } @Test - void shouldUpdatePerson() { - - Person newPerson = new Person(); - newPerson.name = "Holly"; - newPerson.birthDate = LocalDate.of(2001, 11, 20); - - Map jsonObject = new HashMap<>(); - jsonObject.put("zipcode", 95014); - jsonObject.put("city", "cupertino"); - newPerson.jsonAddress = jsonObject; - - given().accept(ContentType.JSON).and().contentType(ContentType.JSON).and().body(newPerson).when() - .put("/my-people/1").then().statusCode(204); - - // verify after updating that the new json address fields were stored - given().accept(ContentType.JSON) - .when().get("/my-people/1") - .then().statusCode(200) - .and().body("id", is(equalTo(1))) - .and().body("name", is(equalTo("Holly"))) - .and().body("jsonAddress", is( equalTo(jsonObject))); + void shouldUpdatePerson() { + given().accept(ContentType.JSON) + .when().get("/my-people/1") + .then().statusCode(200) + .and().body("id", is(equalTo(1))) + .and().body("name", is(equalTo("John Johnson"))); + + Person newPerson = new Person(); + newPerson.id = 1L; + newPerson.name = "John Johnson"; + + Map jsonObject = new HashMap<>(); + jsonObject.put("zipcode", 95014); + jsonObject.put("city", "cupertino"); + newPerson.jsonAddress = jsonObject; + + given().accept(ContentType.JSON) + .and().contentType(ContentType.JSON) + .and().body(newPerson) + .when().put("/my-people/1").then().statusCode(204); + + // verify after updating that the new json address fields were stored + given().accept(ContentType.JSON) + .when().get("/my-people/1") + .then().statusCode(200) + .and().body("id", is(equalTo(1))) + .and().body("name", is(equalTo("John Johnson"))) + .and().body("jsonAddress", is(equalTo(jsonObject))); }