I am creating cases with Wiremocks and I am generating a response mock.
I have a XML request like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xw="http://example.com">
<soapenv:Header/>
<soapenv:Body>
<xw:gen>
<xw:input>
<xw:element1>0100</xw:element1>
<xw:element2>741</xw:element2>
<xw:element3>JAVA</xw:element3>
<xw:element4>123</xw:element4>
</xw:input>
<xw:global>
<xw:obj1>
<xw:attr1>john</xw:attr1>
<xw:attr2>doe</xw:attr2>
</xw:obj1>
</xw:global>
</xw:gen>
</soapenv:Body>
</soapenv:Envelope>
I only have to validate that xw:input/xw:element1 = 0100, xw:input/xw:element2 = 741 and I need that the xw:global node has anything. The only condition for xw:global is not empty. (This node can be <xw:global></xw:global>
).
This is my mock in json:
{
"request" : {
"url" : "/myweb/myrequest.asmx",
"headers": {
"SOAPAction": {
"equalTo": "\"http://example.com/gen\""
}
},
"bodyPatterns" : [ {
"matchesXPath": "//xw:input[xw:element1=\"0100\" and xw:element2=\"741\" ]",
"xPathNamespaces" : {
"xw" : "http://example.com"
}
}]
},
"response" : {
"status" : 200,
"headers": {
"Content-Type": "text/xml;charset=UTF-8"
},
"body" : "<Abody>"
}
}
The question is: how I can validate that the node xw:global is not empty or is not null?
I tried with this matchesXPath but I didn't have lucky:
"matchesXPath": "//xw:input[xw:element1=\"0100\" and xw:element2=\"741\" ] and count(//xw:global) > 0"
.
Thanks.