Hello,
I have an array within a collection I'd like to validate. The problem is I can't seem to match the array using hasItems and the array itself. It seems that it is as expected two arrays, but the matcher appears to think they're different I'm not quite sure why. Can anybody help?
Here is the code:
given().get(url).
then().
body(matchesJsonSchemaInClasspath("Schema.json"))
.and()
.body("id", hasItems("id1234","id5678"))
.and()
.body("name", hasItems("Aname", "AnotherName"))
.and()
.body("categories", hasItems("Item->FirstItem, Item->SecondItem,Item->ThirdItem, Item->FourthItem, Item->FifthItem, Item->SixthItem", "Item->FirstItem"))
.log().body();
I get the following error:
JSON path categories doesn't match.
Expected: (a collection containing
"Item->FirstItem, Item->SecondItem,Item->ThirdItem, Item->FourthItem, Item->FifthItem, Item->SixthItem", "Item->FirstItem")
Actual: [[Item->FirstItem, Item->SecondItem,Item->ThirdItem, Item->FourthItem, Item->FifthItem, Item->SixthItem], [Item->FirstItem]]
And here is the json:
[
{
"id": "id1234",
"name": "Aname",
"things": [
"Item->FirstItem",
"Item->SecondItem",
"Item->ThirdItem",
"Item->FourthItem",
"Item->FifthItem",
"Item->SixthItem"
],
"rating": "999",
"date": "13/12/2015",
"year": 2015,
"length": 120,
"description": {
"short": "blah.",
"medium": "blah blah blah",
"long": "blah blah blah blah blah."
},
"passed": true,
"created": {
"user": "jimmy",
"time": "2015-06-22T19:33:56.411Z"
},
"updated": {
"user": "jeff",
"time": "2015-06-22T19:33:56.411Z"
}
},
{
"id": "id5678",
"name": "AnotherName",
"categories": [
"Item -> FirstItem"
],
"summary": {
"short": "blah.",
"medium": "blah blah."
},
"created": {
"user": "steff",
"time": "2015-06-22T19:33:56.411Z"
},
"updated": {
"user": "james",
"time": "2012-04-24T18:25:43.511Z"
}
}
]
Thanks,
Zerb