How do I verify two post requests to the same url but with different bodies in Wiremock? The same url should be called once with body 1 and once with body 2.
As it is now Wiremock only cares about verifying the last line.
verify(postRequestedFor(urlEqualTo("/my-url"))
.withRequestBody(equalToJson(resourceAsString("my-first-body.json"), true, false)));
verify(postRequestedFor(urlEqualTo("/my-url"))
.withRequestBody(equalToJson(resourceAsString("my-other-body.json"), true, false)));
I ended up doing this:
var postRequests = findAll(postRequestedFor(urlMatching("/my-url")));
assertThat(postRequests.get(0).getBodyAsString()).isEqualTo(resourceAsString("my-first-body.json"));
assertThat(postRequests.get(1).getBodyAsString()).isEqualTo(resourceAsString("my-other-body.json"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With