Viktor Melnychuk
06/05/2024, 1:58 PMequalToXml matcher not matching tags with same value but in different order.
Here is how I create stub:
WireMock wm = new WireMock(<remove_host_options>);
wm.register(post("/testurl")
.withRequestBody(equalToXml("<body><entry>1</entry><entry>2</entry></body>"))
.willReturn(aResponse().withBody("OK")));
And this request is not matching:
POST /testurl HTTP/1.1
Content-Type: application/xml
Content-Length: 59
<body>
<entry>2</entry>
<entry>1</entry>
</body>
Is there a way to tell WireMock to ignore order of same tags?
ThanksLee Turner
06/05/2024, 3:00 PM<my-elements>
<one />
<two />
<three />
</my-elements>
<my-elements>
<two />
<three />
<one />
</my-elements>
However, in your case I don't think this would make much difference because the data within the elements means they are technically different elements.
You could tweak the comparison bing made by passing in options to the exemptedComparisons method. Perhaps the TEXT_VALUE option would work so the comparison doesn't take into account the values within the entry elements. Perhaps not ideal but it might be enough?Viktor Melnychuk
06/05/2024, 4:13 PMViktor Melnychuk
06/05/2024, 4:20 PMLee Turner
06/05/2024, 4:21 PMViktor Melnychuk
06/05/2024, 4:21 PMLee Turner
06/21/2024, 4:27 PM