0

I have written a hamcrest like this in RestAssured response specification

builder.expectBody("hotelavailabilities.rateplans.rooms.adults", 
    anyOf(
       hasItemInArray(
          anyOf(
             hasItemInArray(
                 anyOf(hasItemInArray(Integer.parseInt(adults))))))));

I want to build an assertion like above so I compare the json output with this assertion

But i get an error like below

java.lang.AssertionError: 1 expectation failed.
JSON path hotelAvailabilities.ratePlans.rooms.adults doesn't match.
Expected: (an array containing (an array containing (an array containing <2>)))
  Actual: [[[2], [2]], [[2]], [[2], [2]], [[2], [2]]]

How to write the hamcrest so that the output is covered and asserted?

JSON schema:

enter image description here

Also sometimes there might be only one array in rooms object or there might be three but 2 will be constant

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

0

solved it finally

hasItem(anyOf(hasItems(anyOf(hasItem(Integer.parseInt(adults)))))));