如何在 Wiremock 中验证两个 post 对同一个 url 的请求,但主体不同?

How do I verify two post requests to the same url but with different bodies in Wiremock?

如何在 Wiremock 中验证两个 post 对同一个 url 的请求,但主体不同?相同的 url 应该在 body 1 中调用一次,在 body 2 中调用一次。

现在 Wiremock 只关心验证最后一行。

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)));

我最终这样做了:

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"));