Skip to content

Commit

Permalink
Fixed formatting and test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfali16 committed Nov 1, 2023
1 parent e479011 commit 4940058
Showing 1 changed file with 34 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -119,27 +118,34 @@ void shouldDeleteNotBeExposed() {
}

@Test
void shouldUpdatePerson() {

Person newPerson = new Person();
newPerson.name = "Holly";
newPerson.birthDate = LocalDate.of(2001, 11, 20);

Map<String, Object> 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<String, Object> 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)));

}

Expand Down

0 comments on commit 4940058

Please sign in to comment.