Hello Team,
As a newbie to wiremock, I started some test to do poc for my mobile app.
The intention of POC is, to automate the app local notification, for that I need to mock the response made by my app(client).
I read the documentation and set up my stub for POST request with right headers and body, but when my app (client) makes call to that endpoint, only the url is matching with the stub setting and for headers, it says Header is not present and Header does not match.
I don't understand why the headers are missing and not matching. Your timely help is much appreciated. Thank you in advance.
I have started the wiremock server and setup the stub in @Beforeclass and close the server @Afterclass in my testrunner class.
Starting Server, Stub set up and Closing Server methods:
static WireMockServer wireMockServer;
@BeforeClass
public static void setup () {
wireMockServer = new WireMockServer(8090);
wireMockServer.start();
setupStub();
}
@AfterClass
public static void teardown () {
wireMockServer.stop();
}
public static void setupStub() {
wireMockServer.stubFor(post(urlEqualTo("/twlYourWarehouseTest/GetProductsRanking.json"))
.withHeader("sub-key", equalTo("xxxxxxxxxxxxxx"))
.withHeader("Content-Type", containing("application/json"))
.withHeader("X-xxx-Environment", equalTo("qat"))
.withHeader("X-xxx-Device", equalTo("Android"))
.withHeader("X-xxx-API-Version", equalTo("3.7"))
.withRequestBody(containing("products"))
.willReturn(aResponse()
.withHeader("Content-Type", "application/json; charset=utf-8")
.withStatus(200)
.withBodyFile("/json/GetProductsRanking.json")));
}
please let me know for any further information.