vendredi 15 mai 2020

Wiremock BodyPattern matching Contains this or that

I am trying to configure Wiremock to return the same response from a text file if the request body contains this or that etc. Here is my working file for a single request:

{
  "priority": 1,
  "request": {
    "method": "POST",
    "urlPath": "/v1/retrieve-vehicle",
    "bodyPatterns" : [ {
      "contains" : "\"vehicleIdentifier\":\"EROR-103\""
    } ]
  },
  "response": {
    "status": 404,
    "bodyFileName": "JsonFiles/NoVinFound-Error103.json",
    "headers": {
      "Content-Type": "application/json;charset=UTF-8"
    }
  }
}

I have tried a few combinations of the bodyPatterns attribute (inspired by the documentation) but to no avail.

"bodyPatterns" : [ {
      "contains" : "\"vehicleIdentifier\":\"EROR-103\"",
      "contains" : "\"vehicleIdentifier\":\"EROR-103A\""
    } ]
"bodyPatterns" : [ {
      "contains" : "\"vehicleIdentifier\":\"EROR-103\""
      }, {
      "contains" : "\"vehicleIdentifier\":\"EROR-103A\""
    } ]
"multipartPatterns" : [ {
      "matchingType" : "ANY",
      "bodyPatterns" : [ {
        "contains" : "\"vehicleIdentifier\":\"EROR-103\"",
        "contains" : "\"vehicleIdentifier\":\"EROR-103A\""
      } ]
    } ]
"multipartPatterns" : [ {
      "matchingType" : "ANY",
      "bodyPatterns" : [ {
        "contains" : "\"vehicleIdentifier\":\"EROR-103\"" 
        }, {
        "contains" : "\"vehicleIdentifier\":\"EROR-103A\""
      } ]
    } ]

Please advise what I'm doing wrong. Thanks!

Aucun commentaire:

Enregistrer un commentaire