[英]check greater than or less than in wiremock
I have a situation where I need to check the amount and return the response accordingly. 我遇到需要检查金额并相应返回响应的情况。
If the amount is >=100, then response would be different, else for amount < 100, i need to send error response. 如果数量> = 100,则响应会有所不同,否则对于数量<100,我需要发送错误响应。
Please refer the sample json in request body. 请参考请求正文中的示例json。
{ "accountName":"ABCZYZ", "specialCode":"MYCODE", "amount":"100", "currencyType":"MYCURRENCY" }
{“ accountName”:“ ABCZYZ”,“ specialCode”:“ MYCODE”,“ amount”:“ 100”,“ currencyType”:“ MYCURRENCY”}
Below is my wiremock mapping file 下面是我的wiremock映射文件
{ "request": { "urlPattern": "/some/url", "method": "POST", "bodyPatterns" : [ { "matchesJsonPath" : " $[?(@.amount < 100)] " } ] },
{“ request”:{“ urlPattern”:“ / some / url”,“ method”:“ POST”,“ bodyPatterns”:[{“ matchesJsonPath”:“ $ [?(@。amount <100)] ”}] },
"response": { "status": 200, "body": "MY_REPONSE_IN_JSON_FORMAT" } }
“ response”:{“ status”:200,“ body”:“ MY_REPONSE_IN_JSON_FORMAT”}}
I am facing issue reagrding the above matching pattern. 我遇到了上述匹配模式的问题。
Could anyone please help me for the same? 有人可以帮我吗?
Thanks M 谢谢M
Try changing "100" to 100 尝试将“ 100”更改为100
tested like below : 测试如下:
Request : 要求:
{
"accountName": "ABCZYZ",
"specialCode": "MYCODE",
"amount": 100,
"currencyType": "MYCURRENCY"
}
JsonPath: JsonPath:
$[?(@.amount <= 100)]
Response: 响应:
[{"accountName":"ABCZYZ","specialCode":"MYCODE","amount":100,"currencyType":"MYCURRENCY"}]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.