Open mikahjc opened 3 years ago
I've added a builder to construct the body. See https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/UrlEncocdedFormPostTest.java#L38 for an example.
4.1.13 released
We are trying to implement a pact where the request body is a URL-encoded form, but our client doesn't guarantee the order of parameters because they are in a set. This causes the stub server to report a mismatch because the hard-coded string that we give it for the body doesn't match. For example, a body of
id=1&value=1&value=2&value=3
may be sent by the consumer asid=1&value=3&value=1&value=2
.We did try using
PactDslRootValue.stringMatcher()
with a regex like/^id=\d+&(value=\d+&?)+/
, but that didn't work as we anticipated. We got a BodyMismatch exception:...and the
value
field yields similar errors:(yes, I know the mismatch message is using the actual value, but the rest of the mismatch exceptions were as expected)
I had thought that there may be a way to specify the matchers manually, but it feels like maybe there should be another LambdaDSL or something similar to specify the schema of a URL-encoded form. It seems that it's somewhat aware that the different properties/arrays exist in the body, it's just a matter of passing in the right spec to the
.body()
method.