Thanks for reply nmrao, I have updated your code as per my case.
@groovy.transform.Canonical
import groovy.json.JsonSlurper
class Model {
def caseID
def name
def description
def createdOn
def buildJdbcData(row) {
row.with {
caseID = CaseID
name = Name
description = Description
createdOn = CreatedOn
}
}
def buildJsonData(Root){
caseID = CaseID
name = Name
description = Description
createdOn = CreatedOn
}
}
def jdbcResponse = context.expand('${JDBC Request#Response}')
def restResponse = context.expand('${Cases#Response}')
//Parsing the jdbc and build the jdbc model object list
def results = new JsonSlurper().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 json = new JsonSlurper().parseText(restResponse)
def jsonDataObjects = []
json.Root.each { Root ->
jsonDataObjects.add(new Model().buildJsonData(Root))
}
if (jdbcDataObjects.size() != jsonDataObjects.size()) {
System.err.println("Jdbc resultset size is : ${jdbcDataObjects.size()} and Json result size is : ${jsonDataObjects.size()}")
}
assert jdbcDataObjects == jsonDataObjects, "Comparison of Jdbc and Json data is failed"
But I'm getting an error, Text must not be null .
Thanks,
Geeta