In my tests a have a responses like this:
{
"commands": [
{
"type": "com.our.identity.patch",
"value": [
{
"op": "add",
"path": "/claims/gTwfQubKEl4r",
"value": [
"vcvWxlsLKV35"
]
},
{
"op": "add",
"path": "/claims/Jmq6zrG7LKoJ",
"value": [
"iiMQoOWKu2OI"
]
}
]
}
]
}
Where gTwfQubKEl4r and vcvWxlsLKV35 are key - value pair.
The same about Jmq6zrG7LKoJ and iiMQoOWKu2OI key - value pair.
The response can include many key - value pairs.
I need to be able to validate if some key and value are presented in the response or not.
I use restassured java so I know I can use a path like commands.value.path to get the key and commands.value.value to get the value with these methods I wrote:
public String getValueFromResponseBody(Response res, String key){
return res.body().jsonPath().getString(key);
}
public void validateParameterValueInResponseBodyEquals(Response res, String param, String expectedValue){
String value = getValueFromResponseBody(res,param);
Assert.assertEquals(value,expectedValue);
}
Where passed param is parameter path inside the response like commands.value.path.
But I think this will bring me the first node inside the response body matching the passed path while I need to check against all the nodes inside the response matching that path.
Is it possible?