https://linen.dev logo
#help
Title
# help
j

Jayanth Culli

11/15/2023, 3:43 PM
I have the following wiremock JSON mapping
Copy code
{
  "mappings": [
    {
      "name": "get-credit-report-fail",
      "request": {
        "method": "GET",
        "urlPathPattern": "/pvt/v1/bureau/pan-number",
        "queryParameters": {
          "uuid": {
            "matches": ".*crs-fail"
          }
        }
      },
      "response": {
        "status": 500
      }
    },
    {
      "name": "get-credit-report-success",
      "request": {
        "method": "GET",
        "urlPathPattern": "/pvt/v1/bureau/pan-number"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "success": true,
          "data": {
            "panNumber": "ABCDE1234F",
            "vendor": "EQUIFAX"
          },
          "status_code": 200
        }
      }
    }
  ]
}
When I try to match it with curl
Copy code
curl --location 'localhost:8080/pvt/v1/bureau/pan-number?uuid=crs-fail'
it gives the below response
Copy code
{
  "success": true,
  "data": {
    "panNumber": "ABCDE1234F",
    "vendor": "EQUIFAX"
  },
  "status_code": 200
}
instead of 500 error
l

Lee Turner

11/15/2023, 4:16 PM
Hi. Would the following work for you:
Copy code
{
  "mappings": [
    {
      "name": "get-credit-report-fail",
      "request": {
        "method": "GET",
        "urlPattern": "/pvt/v1/bureau/pan-number\\?uuid=.*crs-fail"
      },
      "response": {
        "status": 500
      }
    },
    {
      "name": "get-credit-report-success",
      "request": {
        "method": "GET",
        "url": "/pvt/v1/bureau/pan-number"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "success": true,
          "data": {
            "panNumber": "ABCDE1234F",
            "vendor": "EQUIFAX"
          },
          "status_code": 200
        }
      }
    }
  ]
}
j

Jayanth Culli

11/17/2023, 7:07 PM
No I want to use queryParams. Not path. Also it worked for me by changing the order of "get-credit-report-fail", and "get-credit-report-success
l

Lee Turner

11/17/2023, 7:09 PM
Glad you got it working. The example I gave still uses the uuid parameter as a query parameter on the request not a path parameter. Doing it that way also meant you wouldn’t have to worry about the order of the mappings in the file.
j

Jayanth Culli

11/18/2023, 4:37 AM
ohh right. got it. thank you!
đź‘Ť 1