In my case I need to request the set of names from two different systems and verify they are equal (regardless order). Most probably I don't understand smth, but this code works fine:
assertThat(asList(assertThat(firstJSON)
.flatExtracting("innerObject")
.extracting("name")).stream().map(Object::toString).collect(Collectors.toList()))
.containsExactlyElementsOf(
asList(assertThat(secondJSON)
.flatExtracting("innerObject")
.extracting("name")).stream().map(Object::toString).collect(Collectors.toList()));
, but it looks really ugly and I want something like this:
assertThat(firstJSON)
.flatExtracting("innerObject")
.extracting("name")
.containsExactlyElementsOf(
assertThat(secondJSON)
.flatExtracting("innerObject")
.extracting("name"));
I've tried many functions like isSubsetOf()
or containsOnly()
, also I tried putting casting here and there but always catching some exception/error.
How do I compare them?