Hi, I have a simple consumer test in which I expec...
# pact-jvm
k
Hi, I have a simple consumer test in which I expect the producer to return a json array as response body. However when we ran the producer test, it turned out that the producer returns the array unordered. All the data is there, but the order is inequal. As the consumer, we don’t care about the order. So I assume I have to edit the pact in the consumer test to somehow specify that the order is irrelevant, but I have no how to do so. I believe this documentation here is relevant, but its hard to find example usages of it. Am I on the right track here?
m
I think you want the eachLike matcher from here: https://github.com/pact-foundation/pact-jvm/tree/master/consumer/junit#ensuring-all-items-in-a-list-match-an-example If you need exact value matching, but without the ordering of elements, I'm not sure that's currently possible
Ah, you want
unorderedArray
: https://github.com/pact-foundation/pact-jvm/tree/master/consumer/junit#ignoring-the-list-order-v4-specification (Only if you want value matching. You might just want to be ensuring the shape is correct)
k
Yeah I think the unorderedArray and value matching is what we want. However I am unfamiliar with defining the response as a DslPart object. Currently we just define our response as a json string. Do you maybe have any code examples or documentation where unorderedArray is used?
m
I don’t sorry (I literally only just discovered that new matcher now)
(see also howtoexamples)
s
k
Thanks a lot! I expect this should be enough to get me going
🙌 1