nmrao Your code works for me , groovy is new to me that's why understanding issue but finally :)
@groovy.transform.Canonical
class Model {
def caseid
def name
def buildJdbcData(row) {
row.with {
caseid = CASEID
name = NAME
}
}
def buildJsonData(root){
root.with {
caseid = CaseID
name = Name
}
}
}
def jdbcResponse = context.expand('${cases JDBC#ResponseAsXml}')
def jsonResponse = context.expand('${cases#ResponseAsXml}')
//Parsing the jdbc and build the jdbc model object list
def results = new XmlSlurper().parseText(jdbcResponse)
def jdbcDataObjects = []
results.ResultSet.Row.each { row ->
jdbcDataObjects.add(new Model().buildJdbcData(row))
}
//Parsing the json and build the json model object list
def Response = new XmlSlurper().parseText(jsonResponse)
def jsonDataObjects = []
Response.Root.e.each { root ->
jsonDataObjects.add(new Model().buildJsonData(root))
}
if (jdbcDataObjects.size() != jsonDataObjects.size()) {
log.info ("Jdbc resultset size is : ${jdbcDataObjects.size()} and Json result size is : ${jsonDataObjects.size()}")
}
assert jdbcDataObjects == jsonDataObjects, "Comparison of Jdbc and Json data is failed"