Map<String, Object> actual = JsonPath.from(restAssuredResponse.body().asString()).getMap(ROOT);
String expectedJson = readJsonFromFile(fileName);
Map<String, Object> expected = JsonPath.from(expectedJson).getMap("");
assertThat(actual).containsAllEntriesOf(expected);
However, I would like to use the Rest-Assured api intead of parsing the response and my expected result. In order words, I would like to have something similar to:String expectedJson = readJsonFromFile(fileName);
Map<String, Object> expected = JsonPath.from(expectedJson).getMap(ROOT);
restAssuredResponse.then().assertThat().body(containsAllEntriesOf(expected));OrString expectedJson = readJsonFromFile(fileName);
restAssuredResponse.then().assertThat().body(containsAllEntriesOf(expectedJson));
I tried something like belowString expectedJson = readJsonFromFile(fileName);
Map<String, Object> expected = JsonPath.from(expectedJson).getMap(ROOT);
restAssuredResponse.then().body(containsInAnyOrder(expected));but I got the error:java.lang.AssertionError: 1 expectation failed.Response body doesn't match expectation.Expected: iterable over [<{date_time=2017-12-25T20:00:00Z>] in any orderActual: {"event_id":"1260366", "date_time":"2017-12-25T20:00:00Z"}
Does anyone has some idea?ThanksDavid
String expectedJson = readJsonFromFile(expectedFileNameOrJsonContent);
restAssuredResponse.then().assertThat()
.body(SameJSONAs.sameJSONAs(expectedJson).allowingAnyArrayOrdering().allowingExtraUnexpectedFields());
String expectedJson = readJsonFromFile(expectedFileNameOrJsonContent);
restAssuredResponse.then().assertThat().body(path,
hasItems(JsonPath.from(expectedJson).getMap(ROOT)));
--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
String expectedJson = readJsonFromFile(expectedFileNameOrJsonContent);
restAssuredResponse.then().assertThat().body(path,
hasItems((Object)JsonPath.from(expectedJson).get(ROOT)));