I'm trying to create a mock server using wire-mock and I'm facing the following problem: I want to hit an URL like this /customers?customerId={customerId}&customerNo={customerNo}
.
My question is how can I match the request parameters customerId
and customerNo
from the stub of the mock server in Java code.
EDIT
After the first response, this is the result:
EDIT 2
Here is my stub:
WireMockServer mockServer = new WireMockServer(8079);
mockServer.start();
mockServer.stubFor(get(urlEqualTo("/api/loan/admin/contracts"))
.withQueryParam("status", equalTo("ACTIVE"))
.withQueryParam("cnp", equalTo("1950503410033"))
.willReturn(aResponse().withBody("Welcome to Baeldung!")));
My problem was that the WireMock is hardcoded in UTF-8 format, so when firing requests from browser I didn't send the UTF-8 format to the endpoint. You can't change the WireMock to accept anything instead of UTF-8, but you can fire some UTF-8 requests.