Thursday, November 17, 2011

Verifying pagination ids don't overlap (page 1 ends at 25, page two starts at 26)


(run your search step)

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def holder = groovyUtils.getXmlHolder( context.expand( '${User 1 - Search Tracks Keyword - ticket 8816 - 1st page#ResponseAsXml}' ));
def nodeValue = holder.getNodeValue( "//ns1:Response[1]/ns1:search[1]/ns1:results[1]/ns1:e[1]/ns1:result[1]/ns1:tracks[1]/ns1:e[1]/ns1:track[1]/ns1:track_id[1]/text()" );
def i = 1;

return_string = nodeValue;

while ( nodeValue != null ) {
    if ( ! return_string.contains( nodeValue ) ) {
        return_string = return_string + "," + nodeValue;
    }
    i++;
    nodeValue = holder.getNodeValue( "//ns1:Response[1]/ns1:search[1]/ns1:results[1]/ns1:e[1]/ns1:result[1]/ns1:tracks[1]/ns1:e[" + i.toString() + "]/ns1:track[1]/ns1:track_id[1]/text()" );
}

return return_string;


(run your property transfer based on script result)

(run your search step with offset - this is your scripted assertion)



def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def holder = groovyUtils.getXmlHolder( context.expand( '${User 1 - Search Tracks Keyword - ticket 8816 - 2nd page#ResponseAsXml}' ));
def nodeValue = holder.getNodeValue( "//ns1:Response[1]/ns1:search[1]/ns1:results[1]/ns1:e[1]/ns1:result[1]/ns1:tracks[1]/ns1:e[1]/ns1:track[1]/ns1:track_id[1]/text()" );
def i = 1;

// Setup compare string (all the page 1 id's)
compare_string = context.expand( '${#ticket_8816_documents}' )

log.info( "nodeValue: " + nodeValue )
log.info( "compare_string: " + compare_string )

while ( nodeValue != null ) {
    // Verify that no page 2 id is in page 1 id's
    assert compare_string.contains( nodeValue ) != true
    i++;
    nodeValue = holder.getNodeValue( "//ns1:Response[1]/ns1:search[1]/ns1:results[1]/ns1:e[1]/ns1:result[1]/ns1:tracks[1]/ns1:e[" + i.toString() + "]/ns1:track[1]/ns1:track_id[1]/text()" );
}