Skip to content

Commit 9e864fa

Browse files
committed
Fixed test
2 parents 74c3a56 + b11ace0 commit 9e864fa

File tree

1 file changed

+21
-13
lines changed
  • hibernate-orm-rest-data-panache-quickstart/src/test/java/org/acme/hibernate/orm/panache/rest/entity

1 file changed

+21
-13
lines changed

hibernate-orm-rest-data-panache-quickstart/src/test/java/org/acme/hibernate/orm/panache/rest/entity/PeopleResourceTest.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import io.quarkus.test.junit.QuarkusTest;
1717
import io.restassured.http.ContentType;
18+
import io.restassured.response.Response;
1819

1920
@QuarkusTest
2021
public class PeopleResourceTest {
@@ -65,13 +66,13 @@ void shouldListPersonsInDescending() {
6566

6667
@Test
6768
void shouldListPersonsWithPageAndSize() {
68-
given().accept(ContentType.JSON)
69-
.and().queryParam("page", 0)
70-
.and().queryParam("size", 1)
71-
.when().get("/my-people/all")
72-
.then().statusCode(200)
73-
.and().body("id", contains(1))
74-
.and().body("name", contains("John Johnson"));
69+
given().accept(ContentType.JSON)
70+
.and().queryParam("page", 0)
71+
.and().queryParam("size", 1)
72+
.when().get("/my-people/all?sort=name")
73+
.then().statusCode(200)
74+
.and().body("id", contains(1))
75+
.and().body("name", contains("John Johnson"));
7576
}
7677

7778
@Test
@@ -120,25 +121,32 @@ void shouldDeleteNotBeExposed() {
120121

121122
@Test
122123
void shouldUpdatePerson() {
123-
124+
given().accept(ContentType.JSON)
125+
.when().get("/my-people/1")
126+
.then().statusCode(200)
127+
.and().body("id", is(equalTo(1)))
128+
.and().body("name", is(equalTo("John Johnson")));
129+
124130
Person newPerson = new Person();
125-
newPerson.name = "Holly";
126-
newPerson.birthDate = LocalDate.of(2001, 11, 20);
131+
newPerson.id = 1L;
132+
newPerson.name = "John Johnson";
127133

128134
Map<String, Object> jsonObject = new HashMap<>();
129135
jsonObject.put("zipcode", 95014);
130136
jsonObject.put("city", "cupertino");
131137
newPerson.jsonAddress = jsonObject;
132138

133-
given().accept(ContentType.JSON).and().contentType(ContentType.JSON).and().body(newPerson).when()
134-
.put("/my-people/1").then().statusCode(204);
139+
given().accept(ContentType.JSON)
140+
.and().contentType(ContentType.JSON)
141+
.and().body(newPerson)
142+
.when().put("/my-people/1").then().statusCode(204);
135143

136144
// verify after updating that the new json address fields were stored
137145
given().accept(ContentType.JSON)
138146
.when().get("/my-people/1")
139147
.then().statusCode(200)
140148
.and().body("id", is(equalTo(1)))
141-
.and().body("name", is(equalTo("Holly")))
149+
.and().body("name", is(equalTo("John Johnson")))
142150
.and().body("jsonAddress", is( equalTo(jsonObject)));
143151

144152
}

0 commit comments

Comments
 (0)