I have test:
@Test
public void sixTest() {
FlowerList flowerList = new FlowerList();
Specification.installSpec(Specification.requestSpec(), Specification.responseSpec());
Response response = given()
.when()
.get("/api/unknown")
.then()
.log().all()
.body("data.year", hasKey("2001"))
.extract().response().as((Type) FlowerList.class);
I need to check that at least one year field contained the value 2001. But I get an exception:
Expected: map containing ["2001,"->ANYTHING]
Actual: [2000, 2001, 2002, 2003, 2004, 2005]
What am I doing wrong? In theory hasKey should return a single value 2001
get:
{
page: 1,
per_page: 6,
total: 12,
total_pages: 2,
data: [
{
id: 1,
name: "cerulean",
year: 2000,
color: "#98B2D1",
pantone_value: "15-4020"
},
{
id: 2,
name: "fuchsia rose",
year: 2001,
color: "#C74375",
pantone_value: "17-2031"
},
...