Search code examples
spring-bootwiremock

Wiremock request.query not working with a paramter that contains dots


I'm using sprint-boot with wiremock-jre8, what i'm trying to to is to get a value from URL params, but this value contains dots "product.productCharacteristic.value"

{
    "request": {
        "urlPath": "/exampleOfPath",
        "method": "GET",
        "queryParameters": {
            "product.productCharacteristic.name": {
                "equalTo": "MSISDN"
            },
            "product.productCharacteristic.value": {
                "matches": ".*"
            }
        }
    },
    "response": {
        "status": 200,
        "jsonBody": {
            "key": "the value should be here {{request.query['product.productCharacteristic.value']}}"
        },
        "transformers": [
            "response-template"
        ],
        "headers": {
            "Content-Type": "application/json"
        }
    }
}

i have tested all of those

  • {{request.query.['product.productCharacteristic.value']}}
  • {{request.query['product.productCharacteristic.value']}}
  • {{request.query['product%2EproductCharacteristic%2Evalue']}}
  • {{request.query.['product%2EproductCharacteristic%2Evalue']}}
  • {{request.query.product%2EproductCharacteristic%2Evalue}}
  • {{request.query.product.productCharacteristic.value}}
  • {{lookup request.query 'product.productCharacteristic.value'}}
  • {{lookup request.query 'product%2EproductCharacteristic%2Evalue'}}

Solution

  • You can use this format: {{request.query.[product.productCharacteristic.value]}}

    See WireMock - Response Templating - The request model:

    request.headers.[<key>] - Header with awkward characters e.g. request.headers.[$?blah]