[英]Assertj Comparing extracted which are String arrays
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: 我很可能不了解smth,但是这段代码可以正常工作:
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. 我已经尝试过很多函数,例如isSubsetOf()
或containsOnly()
,我也尝试过在isSubsetOf()
进行强制转换,但总是会isSubsetOf()
一些异常/错误。
How do I compare them? 我如何比较它们?
在这一点上,我将考虑使用https://github.com/lukas-krecan/JsonUnit代替AssertJ,它提供了不错的导航功能来断言JSON数据的各个部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.