Marco Bungart created AXIOM-520:
-----------------------------------
Summary: Truth-XML: support XML comparison, ignoring element order
Key: AXIOM-520
URL: https://issues.apache.org/jira/browse/AXIOM-520
Project: Axiom
Issue Type: New Feature
Reporter: Marco Bungart
XMLUnit allows a similarity comparison, ignoring element order:
{code:java}
class XmlTest {
@Test
void test() {
final String expected = """
<struct>
<int>3</int>
<boolean>true</boolean>
</struct>
""";
final String actual = """
<struct>
<boolean>true</boolean>
<int>3</int>
</struct>
""";
assertThat(
actual,
isSimilarTo(expected)
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)));
}
}
{code}
It would b enice to have a similar behaviour in {{truth-xml}}.
---
Story:
*As* a user of {{truth-xml}}
*When* I want to compare XML documents
*Then* I want a way to compare them ignoring the order
---
Idea for implementation:
A new method {{ignoringElementOrder()}} (and corresponding
{{ignoringElementOrder(boolean)}}) could be implemented.
A corresponding acceptance test would then look like this:
{code:java}
class XmlTest {
@Test
void positiveTest() {
final String expected = """
<struct>
<int>3</int>
<boolean>true</boolean>
</struct>
""";
final String actual = """
<struct>
<boolean>true</boolean>
<int>3</int>
</struct>
""";
assertAbout(xml())
.that(actual)
.ignoringElementOrder()
.hasSameContentAs(expected);
}
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]