我在下面DiffBuilder
使用 XMLUnit-2
diff = DiffBuilder.compare(control).withTest(test).checkForSimilar()
.normalizeWhitespace().ignoreComments()
.ignoreWhitespace().ignoreElementContentWhitespace()
.withNodeFilter(node -> (filter(node, attrsToIgnore)))
.withAttributeFilter(fields -> (filterFields(fields, fieldsToIgnore)))
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).build();
它适用于改组List<>
值或随机值,List<>
如下所示
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE ResourceObject PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<ResourceObject displayName="aggaccnm1" identity="U013JFHQ59D" objectType="account">
<Attributes>
<Map>
<entry key="costCenter" value="1111"/>
<entry key="department" value="QA"/>
<entry key="displayName" value="AggACCDN1"/>
<entry key="groups">
<value>
<List>
<String>S013J6S7STH</String>
<String>S013S71EMLN</String>
<String>S013S71GTU6</String>
</List>
</value>
</entry>
</Map>
</Attributes>
</ResourceObject>
但是,当我List < Map {} >
失败时.. 可以做些什么来处理值的随机顺序List<String>
以及List < Map {} >
值顺序。
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE ResourceObject PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<ResourceObject displayName="aggaccnm1" identity="U013JFHQ59D" objectType="account">
<Attributes>
<Map>
<entry key="costCenter" value="1111"/>
<entry key="department" value="QA"/>
<entry key="displayName" value="AggACCDN1"/>
<entry key="groups">
<value>
<List>
<String>S013J6S7STH</String>
<String>S013S71EMLN</String>
<String>S013S71GTU6</String>
</List>
</value>
</entry>
<entry key="groups_objects">
<value>
<List>
<Map>
<entry key="display" value="Agggrp1"/>
<entry key="value" value="S013S71EMLN"/>
</Map>
<Map>
<entry key="display" value="Agggrp5"/>
<entry key="value" value="S013S71GTU6"/>
</Map>
<Map>
<entry key="display" value="Agggrp7"/>
<entry key="value" value="S013S71HVU6"/>
</Map>
</List>
</value>
</entry>
</Map>
</Attributes>
</ResourceObject>
在上面的示例中,您可以注意到我List < Map {} >
和我的上述实现对于简单List<>
但不适用于List < Map {} >
我想忽略两者的顺序,有人请告诉我如何实现?
谢谢,
斯瓦普尼尔。