Premier2k
9 years agoOccasional Contributor
Looping through a resultset
Hi all,
I'm trying to loop through a result set and add the results to a map, I have done this already with some JSON output and I'm trying to do the same for the database resultset but it's only returning the first row in the results.
This is what I have so far;
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) import com.eviware.soapui.support.XmlHolder import groovy.json.* def responseJSON = testRunner.testCase.testSteps["Retrieve case data from GW"].testRequest.response.responseContent def response = new JsonSlurper().parseText(responseJSON) def responseXML = new XmlHolder (testRunner.testCase.testSteps["Retrieve household data from staging"].testRequest.response.responseContent) def gatewayMap = [ (response.householdExpenditure.expenditureType.each{}) : response.householdExpenditure.expenditureAmount.each{} ] def stagingMap = [ (responseXML.getNodeValue("//Results/ResultSet/Row/EXPENDITURETYPE").each{}) : Math.round(responseXML.getNodeValue("//Results/ResultSet/Row/EXPENDITUREAMOUNT").each{}.toFloat()) ] log.info gatewayMap log.info stagingMap
The output from the log shows only the first row, it doesn't seem to be iterating through the rows. I believe I'm missing something after /Row[something here?]/EXPENDITURETYPE but I'm not sure what?
The gatewayMap works as expected, it's just the stagingMap that's causing me problems.
Premier2k