I am trying to mock two different requests to the ...
# wiremock-java
a
I am trying to mock two different requests to the same endpoint. One mock is set up like this
Copy code
"request": {
        "method": "POST",
        "urlPattern": "/store|/v2/store",
        "queryParameters": {
          "client": {
            "matches": "STORE-ABC-.+"
          },
...
          }
        }
and the second looks like this
Copy code
"request": {
        "method": "POST",
        "urlPattern": "/store|/v2/store",
        "queryParameters": {
          "client": {
            "matches": "STORE-123-.+"
          },
...
        }
      },
Both have additional but the same query parameters to match. Both also have different body patterns to match. When I send this request (from WireMock's log)
Copy code
POST /v2/store?client=STORE-123-12345&user=userId&realm=realm&key=sessionId
I see that WireMock only tries the other request (STORE-ABC) but fails because it cannot match some parts of the body patterns of STORE-ABC, even though STORE-123 would match. So I wonder if WireMock even tries the STORE-123 mock because I cannot see it in the log. More curiosly, at the very end I get a "closest stub" that is a completely different stub where of course neither URL nor body match; how come it shows this, and not for example the stubs it tried?
Hm, I just removed all stubs but the one I expect to work, and it does not match, i.e., I get 404 from WireMock 😲
Ooooh, could it be when I am using
urlPattern
that it ignores
queryParameters
? 😮
D'oh, yeah, seems like I need to use
urlPathPattern
in that case. It's even documented, I just didn't read it careful enough...