So I tried a few differant combos that were mentioned above. Below I just commented out the each statement and just tried to compare via assert the parsedJsonFiltered (which I have limited down to just one of the criteria I need to look for, there are others but for the purpose of this debug I've just limited it to one) with the expected results. The Assert fails as if the compare between parsedJsonFiltered and expectedResults don't match but when I log the output or even look at the assert error the results do match. Can't figure out what the issue is..????
------------------------
Script:
def responseMsg = messageExchange.response.responseContent
def parsedJson = new groovy.json.JsonSlurper().parseText(context.response)
//new variable to reduce the response list specific to levelOfCareName == 'Hospital_Level_of_Care'
def parsedJsonFiltered = parsedJson.criteria_LIST.findAll{it.programName == 'Hospital_Level_of_Care' && it.criteriaName == 'Impact_On_Functioning'}
//def expectedResults Array
def expectedResults = [
[criteriaName: "Impact_On_Functioning", levelOfCareName: "Hospital_Level_of_Care", outcome: "Met", parentCriteria: "null", parentCriteriaName: "null", programName: "Hospital_Level_of_Care"]
// [levelOfCareName: "Hospital_Level_of_Care", criteriaName: "Impact_On_Functioning", outcome: "Met"],
// [levelOfCareName: "Hospital_Level_of_Care", criteriaName: "Physician_Determined", outcome: "Met"],
// [levelOfCareName: "Hospital_Level_of_Care", criteriaName: "Specialized_Support_Need", outcome: "Met"],
// [levelOfCareName: "Hospital_Level_of_Care", criteriaName: "Clinical_Monitoring", outcome: "Met"],
// [levelOfCareName: "Hospital_Level_of_Care", criteriaName: "Vulnerability_Requiring_24_Hour_Plan_Of_Care", outcome: "Met"]
]
log.info "ParsedJson Filtered: ${parsedJsonFiltered}"
log.info "expectedResults: ${expectedResults}"
assert parsedJsonFiltered == expectedResults
//go through each and assert
//expectedResults.each
//assert parsedJsonFiltered[0] == expectedResults
//assert parsedJsonFiltered[1] == expectedResults[0]
//assert parsedJsonFiltered[2] == expectedResults[1]
//assert parsedJsonFiltered[3] == expectedResults[2]
//assert parsedJsonFiltered[4] == expectedResults[4]
//show filtered json in log
//log.info "parsedJsonFiltered[0]: ${parsedJsonFiltered[0]}"
//log.info "expectedResults[0]: ${expectedResults}"
//log.info "parsedJsonFiltered[1]: ${parsedJsonFiltered[1]}}"
//log.info "parsedJsonFiltered[2]: ${parsedJsonFiltered[2]}}"
//log.info "parsedJsonFiltered[3]: ${parsedJsonFiltered[3]}}"
//log.info "parsedJsonFiltered[4]: ${parsedJsonFiltered[4]}}"
----------------------------------
log output:
Thu Sep 27 07:34:00 CDT 2018:INFO:ParsedJson Filtered: [[criteriaName:Impact_On_Functioning, levelOfCareName:Hospital_Level_of_Care, outcome:Met, parentCriteria:null, parentCriteriaName:null, programName:Hospital_Level_of_Care]]
Thu Sep 27 07:34:00 CDT 2018:INFO:expectedResults: [[criteriaName:Impact_On_Functioning, levelOfCareName:Hospital_Level_of_Care, outcome:Met, parentCriteria:null, parentCriteriaName:null, programName:Hospital_Level_of_Care]]
-------------------------------------
Assert Error:
assert parsedJsonFiltered == expectedResults | | | | | [[criteriaName:Impact_On_Functioning, levelOfCareName:Hospital_Level_of_Care, outcome:Met, parentCriteria:null, parentCriteriaName:null, programName:Hospital_Level_of_Care]] | false [[criteriaName:Impact_On_Functioning, levelOfCareName:Hospital_Level_of_Care, outcome:Met, parentCriteria:null, parentCriteriaName:null, programName:Hospital_Level_of_Care]]
-------------------------------------