Import Com.eviware.soapui.support.GroovyUtilsimport Com.eviware.soapui.support.XmlHolderimport Org.w3c.dom.Nodeimport org.apache.commons.lang.StringUtilsimport java.util.HashSetdef groovyutils = new Groovyutils ( context) def Xmlholder = Groovyutils.getxmlholder (Messageexchange.getresponsecontent ()) def activeenv = Context.expand (' ${#Project #activeenv} ') Log.info "The active environment is $ACTIVEENV" string[] fixclientidarray if (activeenv== "LIVE ") {Fixclientidarray = new string[2] fixclientidarray[0] =" 6E2BA3E9-68A4-4C8F-A164-F026E7239CF7 "fixClientIdArray[1 ] = "dfba4888-348a-4fb1-91f7-8a03fb6aa775"}if (activeenv== "QA") {Fixclientidarray = new string[3] fixclientidarray[0] = "6fe9b969-3711-4083-a8c4-186e75e6e9e7" fixclientidarray[1] = "43ec112f-cd57-4d84-a5e8-1d62e1f71244" fixClient IDARRAY[2] = "8c8e3e6a-0cb1-41d0-a07b-ca3fff506cee"}def fixset = new HashSet () for (String Clientid:fixclientidarray) {Fixset.add (ClientId)} String XPath = "//clients/client" node[] NodeArray = Xmlholder.getdomnodes (xPath) int actualcount = Nodearray.lengthint Expectedcount = Context.expand (' ${#Project # Clientcount} '). Tointeger () assert fixset.size () = = Expectedcountlog.info "Actual:nodeArray.length of" +xpath+ ":" +actu Alcountlog.info "Expected:nodeArray.length is:" +expectedcountassert actualcount==expectedcountstring Clientidpath = XPath + "/@id" string[] ValueArray = xmlholder.getnodevalues (clientidpath) log.info "Valuearray.length of" +clientidpath + ":" +valuearray.lengthassert valueArray! = null && valuearray.length>0for (String value:valuearray) { Log.info "Value:" +valueassert stringutils.isnotblank (value) assert Fixset.contains (value) fixset.remove (value)} Assert fixset.size () = = 0
[Groovy] Gets the current active environment, gets the name of the node in response and the value of the node