XmlBodyMatcher does not ignore unexpected elements
See original GitHub issueI am using pact-jvm-provider-junit_2.12 version 3.6.9 and I have a problem when verifying the matching rules on the provider side. I have an XML as request body and response body and I am trying to verify a specific field from the response, but there is a problem when the response contains more fields than what we expect, so the child element will have a different path.
I will try to explain what happens with the below example:
Actual response:
<note> <to>John</to> <from>Jane</from> <subject>Reminder</subject> <address> <firstName>John</firstName> <lastName>Doe</lastName> <street>Prince Street</street> <number>34</number> <city>Manchester</city> </address> </note>
Expected response:
<note> <to>John</to> <from>Jane</from> <subject>Reminder</subject> <address> <city>Manchester</city> </address> </note>
On the consumer side I am interested just in the city field, so I have the following matching rule in my pact file:
"$.note.*.address.*.city: { "matchers": [ { "match": "equality" } ], "combine": "AND" }
But the problem is that everytime it takes the first child field
$.note.3.address.0.city -> Expected <firstName>John</firstName> to equal <city>Manchester</city>
I am not sure if this is an issue or it’s the expected behavior. Or is there another way to identify that element?
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top GitHub Comments
I had to remove the intermediate indices (which imposed the order on the elements) to get it to match. So before the path would have been
a.0.b['@year']
which now becomesa.b['@year']
Not rude, just demanding 😄 3.6.10 has been released