Help with JSON Negative Assertion
This goes with a prior thread that it seems I can no longer update.... https://community.smartbear.com/t5/SoapUI-NG/Help-with-JSON-Negative-Assertion/m-p/126958#M29266
I have messed with this for a while and cannot find what I'm doing wrong. I modified the example you provided above and attempted to use it for another scenario, but I am struggling. For this test case I want to make sure none of my responses contain submitCount": "1" or submitCount": "4" Acceptable values are 2 or 3
{"getResubmittedReturnsResult": {"getResubmittedReturnsIdentificationOut": [
{
"meid": 671,
"transID": 92556,
"status": "Resubmitted",
"submitCount": "2",
"addedTime": "09/23/2016 14:28:49"
},
{
"meid": 671,
"transID": 92558,
"status": "Resubmitted",
"submitCount": "3",
"addedTime": "09/23/2016 14:28:52"
}
]}}
This is what I modified it to...
import groovy.json.JsonSlurper
def str = '''{
"getResubmittedReturnsResult":{
"getResubmittedReturnsIdentificationOut":[
{
"submitCount": "2"
}
]
}
}'''
def json = new JsonSlurper().parseText(str)
def existingsubmitCount = json.getResubmittedReturnsResult.getResubmittedReturnsIdentificationOut.submitCount
def shouldNotBePresent = [1,4]
assert [] == existingsubmitCount.intersect(shouldNotBePresent), "There are submitCounts of 1 present which is incorrect"
I should mention, the data set that comes back will contain hundreds of transactions so it needs to loop through all of them. They key is to make sure that none of them contain a anything other than a 2 or 3. Can you please help me?
Thanks!