2
votes

How to match a wiremock POST request with some optional JSON parameters & any values?

Being new to Stack community, I have raised the below query(afraid that it would be marked as duplicate) in the post (link mentioned above) but it has been deleted stating its the different question and need to raise new question.

Below is my query on top of it:

If the optional parameter is not present in the request than the solution provided in the above post suffice the purpose.

But If the optional parameter is present and we need to check that it contains specific values only (say not null) then how to do that using request matching in .

Kindly provide your inputs as I am new to

For instance:

{
"optional1"="ValueAlwaysYESIfPresent",
"optional2"="ValueAlwaysNOIfPresent"
}

Thanks in advance.

1

1 Answers

0
votes

Have a look at http://wiremock.org/docs/request-matching/ instead of going to other places basically you can do matching like

withQueryParam("optional2", equalTo("ValueAlwaysNOIfPresent"))

Or

 withQueryParam("optional2", matching(".*12345.*"))

and many other things.