I'm having a little issue with arrays in groovy. I am performing a data driven test where I am using a CSV and I am iterating through groovy script steps. What I am trying to do is for each iteration of my soap request, i should receive two flight ids. I want to place each set of the two flights ids in an array, so the array should just keep adding flight ids in the array:
Example:
After Iteration 1: [[123, 321]]
After Iteration 2: [[123.321. 454, 345]]
The problem I am having is that it is not adding into the array but instead replacing the values already in the array. So it looks like below:
After Iteration 1: [[123, 321]]
After Iteration 2: [[454, 345]]
How can I append the flightids in the array?
Below is the code:
import groovy.xml.XmlUtil
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def response = context.expand( '${SOAP Request#Response}' )
def parsedxml = new XmlSlurper().parseText(response)
def flights = parsedxml.'**'.findAll { it.name() == 'FlightId'}[[0],[1]]
def flightsarray = [];
flightsarray.push(flights)
context.setProperty('flights', flights)
context.setProperty('flightsarray', flightsarray)
log.error flightsarray.toString()
FYI I tried replacing flightsarray.push(flights) with flightsarray << flights but it does the same thing.