-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZooResourceTest.java
29 lines (22 loc) · 1021 Bytes
/
ZooResourceTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.acme;
import static io.restassured.RestAssured.given;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.Response;
import org.acme.dtos.AnimalsDto;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@QuarkusTest
public class ZooResourceTest {
@Test
public void getAnimals_ShouldReturnAnimalsDtoWithMelaniDogsAndRats_WhenGivenMelaniAsOwner() {
Response response = given().when().get("/zoo/animals/Melani").then().extract().response();
Assertions.assertEquals(200, response.statusCode());
ObjectMapper mapper = new ObjectMapper();
AnimalsDto responseBody = mapper.convertValue(response.jsonPath().get(), AnimalsDto.class);
Assertions.assertEquals(1, responseBody.getDogs().size());
Assertions.assertEquals(1, responseBody.getRats().size());
Assertions.assertEquals(0, responseBody.getCats().size());
Assertions.assertEquals(0, responseBody.getDolphins().size());
}
}