Forum Discussion

sushant99's avatar
sushant99
Occasional Contributor
14 years ago

comparing list of values in two arrays

Hi there,

I am using SOAPUI Pro 3.5.1
I am trying to achieve the following with SOAPUI Pro. Please let me know your thoughts.

I have a datasource step where in a query fetches us a list of values. query (select columnname as result from tablename)
the result is rows of string values (expected results) -
"Risk is average"
"Risk is low"
"Risk is high"

Now the next step is the SOAP Request- Response. In the response I have a xsd string array node containing the values (actual results)
" Risk is low"
" Risk is high"

I want to compare to verify for each and every row in the expected results there is a match available in the actual results. If yes assert true else assert false.
I tried using the xpath assert on the soap response element and compare it with datasource attribute as expected result but it was picking only the first element value for comparison.

Please advice


Thanks,
Sushant

1 Reply

  • Tony_Sheng's avatar
    Tony_Sheng
    Occasional Contributor
    Hi Sushant,
    If I am not wrong you are trying to get inner node values present inside a parent node. If it is so you can use something like this in your groovy script:

    def requestName = 'YourSoap_RequestName';
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    holder = groovyUtils.getXmlHolder( requestName+"#Response" )

    def parentNode = "rim:RegistryPackage";
    arrItems = holder.getNodeValues( "//"+parentNode+"[1]/rim:ExternalIdentifier");
    size = arrItems.size();
    for(pos=1; pos<=size;pos++)
    {
    id = "${java.util.UUID.randomUUID()}";
    holder.setNodeValue( "//"+parentNode+"[1]/rim:ExternalIdentifier["+pos+"]/@registryObject", id);
    //holder.getNodeValue( "//"+parentNode+"[1]/rim:ExternalIdentifier["+pos+"]/@registryObject");
    holder.updateProperty();
    }

    Following is the node taken for example:

    <rim:RegistryPackage objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:RegistryPackage" status="Approved">
    <rim:ExternalIdentifier identificationScheme="urn:uuid:75df8f67-9973-4fbe-a900-df66cefecc5a" registryObject="urn:uuid:8203387f-d4b1-4109-9c9d-fd8ece712be0">
    <rim:Name>
    <rim:LocalizedString value="XDSFolder.uniqueId"/>
    </rim:Name>
    </rim:ExternalIdentifier>
    <rim:ExternalIdentifier identificationScheme="urn:uuid:f64ffdf0-4b97-4e06-b79f-a52b38ec2f8a" registryObject="urn:uuid:12345678-d4b1-4109-9c9d-fd8ece712be0">
    <rim:Name>
    <rim:LocalizedString value="XDSFolder.patientId"/>
    </rim:Name>
    </rim:ExternalIdentifier>
    </rim:RegistryPackage>

    Hope it might help you!

    Regards,
    Tony