I've this in script assertion
def holder = new XmlHolder( messageExchange.responseContentAsXml )
value of holder is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns0:SOME_SEARCHResponse xmlns:ns0="urn:AA:BBB:CCC:some_WS">
<ns0:some_ID>22222</ns0:Some_ID>
<ns0:some_ID>33333</ns0:Some_ID>
<ns0:Status>OK</ns0:Response>
...
...
below is assertions method, which is in a script lib
def assertions(xmlHolder, String... StringToAssert){
StringToAssert.each{
return xmlHolder.containsKey(StringToAssert)
}
}
I am calling assertions method like below from script assertion
assert true==context.Change.assertions(holder,"//ns0:Some_ID")
but receiving below error and I couldn't understand where the error is coming from.
net.sf.saxon.trans.XPathException: XPath syntax error at char 1 on line 2 in {\n[Ljava.lang.String}: Unexpected token "[" in path expression
EDIT Final version after @albciff comments looks like below
def assertions(xmlHolder,String... stringToAssert){
def results = stringToAssert.collect{ element ->
return xmlHolder.containsKey(element)
}
return results.every{it==true}
//return results.contains(true)
}
assertionsfunction. - albciffString... StringToAssert- tim_yates