Wiremock not ordering withRequestBody

Asked

Viewed 11 times

0

I am implementing some tests in my application as follows:

stubFor(post(urlPathEqualTo("endpoint"))
  .withRequestBody(equalToJson(stringJson, true, false))
  .willReturn(aResponse().withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)
    .withBodyFile("returnfile.json")))

The value of the stringJson variable is thus:

{
    "firstKey": {
        // other keys
    },
    "items": [{
        "external_order_id": "824429",
        "external_product_id": "MLB1284886260",
        "external_variant_id": "51126257782",
        // other keys
    }, {
        "external_order_id": "824429",
        "external_product_id": "MLB1284886260",
        "external_variant_id": "51126257782",
        // other keys
    }]
}

The problem is that even passing true to the ignoreArrayOrder parameter of wiremock, in the equalToJson method, it is not ignoring, therefore it is returning that not of the match in body.

Could you tell me if there’s another way to solve this problem ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.