这是请求
并请求 { "accountNumber": "00000000000000041477514", "prodCodeFilter": "Y", "pageNumber": 0, "pageSize": 100 }
When 方法 Post
这是 api 的响应
{
"accounts": {
"linkedLEAccount": {
"accountNumber": "6541245045",
"bic": "CHASLUY",
"branchId": "000000055",
"branchName": "S.A",
"cbdNumber": "854321",
"leAccountType": "NEW",
"status": "DORMANT"
},
"migrationWave": "5",
"searchedLEAccount": {
"accountNumber": "41477514",
"bic": "CHASGBXxX",
"branchId": "000000071",
"branchName": "LONDON",
"cbdNumber": "12345678",
"leAccountType": "OLD",
"poolAccount": "Y",
"status": "DORMANT",
"sweepMasterAccount": "Y"
},
"transferDate": 1549429200000
},
"pageNumber": 0,
"pageSize": 100,
"requestTime": 1545426348945,
"responseCode": 0,
"responseMessage": "Success",
"responseTime": 1545426348949,
"serviceName": "Legal Entity account for given input account.",
"timeTaken": 4
}
我想要实现的是从我的请求到响应的断言
类似于 And assert accountNumber(request) == accountNumber(response)
最佳答案
我认为您应该花更多时间阅读文档和示例。但是你去吧:
* def payload = { "accountNumber": "00000000000000041477514" , "prodCodeFilter": "Y" , "pageNumber" : 0, "pageSize" : 100 }
* def response =
"""
{
"serviceName":"Legal Entity account for given input account.",
"requestTime":1545426348945,
"responseTime":1545426348949,
"timeTaken":4,
"responseCode":0,
"responseMessage":"Success",
"pageSize":100,
"pageNumber":0,
"accounts":{
"transferDate":1549429200000,
"migrationWave":"5",
"searchedLEAccount":{
"accountNumber":"41477514",
"cbdNumber":"12345678",
"bic":"CHASGBXxX",
"poolAccount":"Y",
"sweepMasterAccount":"Y",
"status":"DORMANT",
"branchId":"000000071",
"branchName":"LONDON",
"leAccountType":"OLD"
},
"linkedLEAccount":{
"accountNumber":"6541245045",
"cbdNumber":"854321",
"bic":"CHASLUY",
"status":"DORMANT",
"branchId":"000000055",
"branchName":"S.A",
"leAccountType":"NEW"
}
}
}
"""
* match payload.accountNumber contains response.accounts.searchedLEAccount.accountNumber
关于javascript - 从请求到响应的 Karate dsl 断言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53898996/