Thanks for the guidence. Actually I am querying directely. The whole this I am doing for the test data preparation. Allow me to explain what I am doing:
In Srep 1: I am searching some command which has certain type, state description and order state by using the below query, This is from database A
Stepname: JDBCRequestForGettingCommandInCoolingOff
Select top 1 COMMANDID
From Command with(nolock)
Where TypeName LIKE 'Provide%'
and commandstatedescription = 'CoolingOff'
and orderstatedescription = 'Processing'
and agentid=5
order by datereceived desc
Step 2: Step Name: JDBCRequestForCheckingCommandPropertyID
In this step from s differemt database "B", I am checking wherther the commandID i found in step 1 has CommandPropertyID in(61,276,605)
Below SQL I am using for this:
Step
select * from ORTCommandPropertyData
where CommandID in ('${JDBCRequestForGettingCommandInCoolingOff#ResponseAsXml#//Results[1]/ResultSet[1]/Row[9]/COMMANDID[1]}')
and CommandPropertyID in(61,276,605)
Because I am quering from two different databases so I have to dothis in two sepearte steps
Step 3: Groovy Scriprt
ArrayList ar = new ArrayList()
jdbcXml = context.expand('${JDBCRequestForCheckingCommandPropertyID#ResponseAsXml}')
def root = new XmlSlurper().parseText(jdbcXml)
root.ResultSet.Row.each{row->
ar.add(row["COMMANDPROPERTYID"])
}
ArrayList requiredField = new ArrayList()
requiredField.add(61)
requiredField.add(276)
requiredField.add(605)
for (j=0; j<requiredField.size();j++)
{
if (ar.contains(requiredField[j]))
{
testRunner.gotoStepByName("Update"+requiredField[j])
}
else
{
testRunner.gotoStepByName("Add"+requiredField[j])
}
}
As you could see this scripti has 3 logical parts
In the first part, I am parsing response xml generated in step2 and storing COMMANDPROPERTYID value in array ar.
I have test this step separately and works fine, I manage to print this array which returns the correct value
In the 2nd part I have cretaed another ArrayList requiredField with hardcode values , so quite strightforward
In the last step where I feeling pain on the back side I am checking whether elements of ar contains in requiredField,
this if (ar.contains(requiredField[j])) returning false every time
I didn't get why this is returnig false, within the else block , I printed both arrays and found that array ar also have one or more value from set (61, 276 ,605).
The whole thing I am doing is not complex but I am not sure why this giving me such a pain. :(
I appriciate your help and based on above explaining I hope you will identify my mistake or suggest me some alternate.
By the why i tried by playing with quotes both in ar.add(row["COMMANDPROPERTYID"]) and requiredField.add(61) statements though might be its because of datatype mismatch if statement returning false.