Forum Discussion
davecoleman
3 years agoContributor
if i changed the JSON response to:
{
"parent": [
{
"country": "RO",
"statusCode": "NotFound"
},
{
"country": "UK",
"statusCode": "Found",
"foundEntity": [ {
"respondingArea": "Authority",
"entityDetails": {
"NameDetails": {
"familyName": "Smith",
"firstName": "John"
},
"respondingArea": "Authority2",
"entityDetails": {
"NameDetails": {
"familyName": "Daniels",
"firstName": "Mike"
}
}
} }
]
}
]
}i tried the following Script Assertion but no joy iterating through the fields to find the FamilyName based on it being within the "UK/Found" parent. comes back with null continuously 😞
import com.eviware.soapui.support.JsonPathFacade
def found = 0
def jpf = new JsonPathFacade(messageExchange.responseContent)
def testArray = jpf.readObjectValue("parent")
log.info (testArray)
testArray.each {
def country= it.get("country")
def statusCode = it.get("statusCode")
def familyName = it.get("foundEntity.entityDetails.NameDetails.familyName)
log.info ("country: " +country)
log.info ("FamilyName: " +familyName)
if(country.contains("UK") && statusCode.contains("Found") && familyName.contains("Smith")) {
log.info("matching record: $country")
found++
}
}
assert found > 0: "*****Assertion of data combination. did not find***"o the child elements.