alibaba82
15 years agoSuper Contributor
Script assertion using groovyutils acting funky
I have the following script assertion for my soap response (see attachment)
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "GetRecommendationItemsInList - Daily#Response" )
def AiringType = holder.getNodeValues("//ns1:GetRecommendationItemsInListResponse[1]/ns1:GetRecommendationItemsInListResult[1]/ns1:Airings[1]/ns1:Airing/ns1:AiringType[1]")
def CC = holder.getNodeValues("//ns1:GetRecommendationItemsInListResponse[1]/ns1:GetRecommendationItemsInListResult[1]/ns1:Airings[1]/ns1:Airing/ns1:CC[1]")
def StartDateTime = holder.getNodeValue("//ns1:GetRecommendationItemsInListResponse[1]/ns1:GetRecommendationItemsInListResult[1]/ns1:Airings[1]/ns1:Airing/ns1:StartDateTime[1]")
def EndDateTime = holder.getNodeValue("//ns1:GetRecommendationItemsInListResponse[1]/ns1:GetRecommendationItemsInListResult[1]/ns1:Airings[1]/ns1:Airing/ns1:EndDateTime[1]")
for (int j = 0; j < AiringType.size(); j++)
{
if(AiringType[j] == null || AiringType[j].equals(""))
throw new Exception("Error: AiringType @index[" + j + "] is empty")
if(CC[j] == null || CC[j].equals(""))
throw new Exception("Error: CC @index[" + j + "] is empty")
if(StartDateTime[j] == null || StartDateTime[j].equals(""))
throw new Exception("Error: StartDateTime @index[" + j + "] is empty")
if(EndDateTime[j] == null || EndDateTime[j].equals(""))
throw new Exception("Error: EndDateTime @index[" + j + "] is empty")
}
I am getting index out of range --> 21 when there are 23 items in the list. Not sure why this is happening.
Thanks
Ali
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "GetRecommendationItemsInList - Daily#Response" )
def AiringType = holder.getNodeValues("//ns1:GetRecommendationItemsInListResponse[1]/ns1:GetRecommendationItemsInListResult[1]/ns1:Airings[1]/ns1:Airing/ns1:AiringType[1]")
def CC = holder.getNodeValues("//ns1:GetRecommendationItemsInListResponse[1]/ns1:GetRecommendationItemsInListResult[1]/ns1:Airings[1]/ns1:Airing/ns1:CC[1]")
def StartDateTime = holder.getNodeValue("//ns1:GetRecommendationItemsInListResponse[1]/ns1:GetRecommendationItemsInListResult[1]/ns1:Airings[1]/ns1:Airing/ns1:StartDateTime[1]")
def EndDateTime = holder.getNodeValue("//ns1:GetRecommendationItemsInListResponse[1]/ns1:GetRecommendationItemsInListResult[1]/ns1:Airings[1]/ns1:Airing/ns1:EndDateTime[1]")
for (int j = 0; j < AiringType.size(); j++)
{
if(AiringType[j] == null || AiringType[j].equals(""))
throw new Exception("Error: AiringType @index[" + j + "] is empty")
if(CC[j] == null || CC[j].equals(""))
throw new Exception("Error: CC @index[" + j + "] is empty")
if(StartDateTime[j] == null || StartDateTime[j].equals(""))
throw new Exception("Error: StartDateTime @index[" + j + "] is empty")
if(EndDateTime[j] == null || EndDateTime[j].equals(""))
throw new Exception("Error: EndDateTime @index[" + j + "] is empty")
}
I am getting index out of range --> 21 when there are 23 items in the list. Not sure why this is happening.
Thanks
Ali