I have below request URL:
http://localhost:9082/v1/action/query
And I have below requests in wiremock request file:
{"queryString":"Select firstname, lastname, workphone, id, accountId from mydetails}
{ "request": { "method": "POST", "url": "/v1/action/query", "bodyPatterns" : [ { "contains": "queryString=from mydetails" } ] }, "response": { "status": 200, "bodyFileName": "mydetails.json", "headers": { "Content-Type": "application/json" } } }
{"queryString":"Select firstname, lastname, workphone, id, accountId from myinfo}
{ "request": { "method": "POST", "url": "/v1/action/query", "bodyPatterns" : [ { "contains": "queryString=from myinfo" } ] }, "response": { "status": 200, "bodyFileName": "myinfo.json", "headers": { "Content-Type": "application/json" } } }
Now I have same URL for both request. I have to verify if in request body if we are getting table "from myinfo" inside queryString Json key . then myinfo file returned. and if we have "from Mydetails" then my details one called.
Do we have any suggestion for same?
You can use the
matchingJsonPath
functionality to match one or the other.Assuming a JSON Mapping...
The exact JsonPath query might need to be fixed, that's just a rough estimate of what I think it would be