Danny Paniagua
03/20/2023, 1:31 PM#eq
block - whatever I have setup now is always returning with the false condition. The simplified object coming in is
{
lender-type: 'installment',
cuId: '1234'
}
The goal is to use response templating to choose which json file to return. I have these sections in my mapping file:
"bodyPatterns": [{
"mathesJsonPath": "[?($.lenderId == 'installment')]"
}]
and then further down:
"response": {
"bodyFileName": "{{#eq (jsonPath request.body '$.cuId') '1234'}}respseon_file_A.json{{else}}response_file_B.json{{/eq}}"
}
The matchesJsonPath
bit seems to work fine as I know I am getting into this mapping file. The problem I'm running into as stated further up above is that when I try to test this logic, the #eq
block is always returning response_file_B.json
, no matter what cuId
field is getting passed. I'm assuming I have some bad character spacing in the handlebars syntax and not to sure how to debug it. Is there anything obvious that I'm doing wrong?Aaron
03/20/2023, 1:53 PMcuId
value.matchesJsonPath
part is working, and you aren’t matching a separate mapping?Danny Paniagua
03/20/2023, 1:54 PMwiremock-jre3-standalone
2.35.0
Aaron
03/20/2023, 1:57 PMDanny Paniagua
03/20/2023, 1:58 PMAaron
03/20/2023, 1:59 PMDanny Paniagua
03/20/2023, 2:01 PM{
"name": "installment_mapping",
"request": {
"method": "POST",
"url": "/lender",
"headers": {
"Content-Type": {
"equalTo": "application/json"
}
},
"bodyPatterns": [
{
"matchesJsonPath": "[?($.lender-type== 'installment')]"
}
]
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"bodyFileName": "{{#eq (jsonPath request.body '$.cuId') '1234'}}response_file_A.json{{else}}response_file_B.json{{/eq}}"
}
}
Was actually about to ask if the full mapping file might help 😂
The request body is
<http://localhost:8080/partner-service/lender>
{
"firstName": "Danman",
"lastName": "Mandan",
"lender-type": "installment",
"cuId": 1234
}
cuId
from int to string in the request payload triggers the correct response 🤦Aaron
03/20/2023, 2:11 PMDanny Paniagua
03/20/2023, 2:14 PM