|
15 | 15 |
|
16 | 16 | import io.quarkus.test.junit.QuarkusTest; |
17 | 17 | import io.restassured.http.ContentType; |
| 18 | +import io.restassured.response.Response; |
18 | 19 |
|
19 | 20 | @QuarkusTest |
20 | 21 | public class PeopleResourceTest { |
@@ -65,13 +66,13 @@ void shouldListPersonsInDescending() { |
65 | 66 |
|
66 | 67 | @Test |
67 | 68 | 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")); |
75 | 76 | } |
76 | 77 |
|
77 | 78 | @Test |
@@ -120,25 +121,32 @@ void shouldDeleteNotBeExposed() { |
120 | 121 |
|
121 | 122 | @Test |
122 | 123 | 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 | + |
124 | 130 | 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"; |
127 | 133 |
|
128 | 134 | Map<String, Object> jsonObject = new HashMap<>(); |
129 | 135 | jsonObject.put("zipcode", 95014); |
130 | 136 | jsonObject.put("city", "cupertino"); |
131 | 137 | newPerson.jsonAddress = jsonObject; |
132 | 138 |
|
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); |
135 | 143 |
|
136 | 144 | // verify after updating that the new json address fields were stored |
137 | 145 | given().accept(ContentType.JSON) |
138 | 146 | .when().get("/my-people/1") |
139 | 147 | .then().statusCode(200) |
140 | 148 | .and().body("id", is(equalTo(1))) |
141 | | - .and().body("name", is(equalTo("Holly"))) |
| 149 | + .and().body("name", is(equalTo("John Johnson"))) |
142 | 150 | .and().body("jsonAddress", is( equalTo(jsonObject))); |
143 | 151 |
|
144 | 152 | } |
|
0 commit comments