mockserver icon indicating copy to clipboard operation
mockserver copied to clipboard

Enforce matching all query parameters

Open sdaus opened this issue 1 year ago • 0 comments

Describe the feature request I am using the .withQueryStringParameter method in MockServer for parameter matching. However, there does not seem to be a way to always force matching all query parameters. If parameters are omitted, the test still passes because it doesn't test for the presence of any parameters. I would like to request a feature to always check for all parameters.

What you are trying to do I'm trying to make sure that the parameter is passed to the endpoint with .withQueryStringParameter:

        mockServerClient
                .when(MockServerRequests.getForJson("/example")
                        .withQueryStringParameter("token", "EXAMPLETOKEN"), Times.once())
                .respond(response().withStatusCode(Integer.valueOf(200)));

However, the following example will also work without any parameters at all:

        mockServerClient
                .when(MockServerRequests.getForJson("/example"), Times.once())
                .respond(response().withStatusCode(Integer.valueOf(200)));

The solution you'd like I want to make sure that certain parameter(s) are always present, and the test should fail if those parameters are not passed.

Describe alternatives you've considered None so far.

sdaus avatar May 31 '24 07:05 sdaus