Forum Discussion
ReshmaSachdev
13 years agoContributor
Hi,
Rather than comparing like -> assert (TrnType.each{it} in ["Debit", "Credit", "Check"])
you should use -> assert (TrnType.each{it} == ["Debit", "Credit", "Check"]) if the order of fields returned are 'Debit', 'Credit' and 'Check' and if TrnType is holding 3 values.
If it contains one value
ie while fetching -> TrnType = holder.getNodeValues("//ns:BankAcctTrnRec[1]//ns:TrnType") say from 1st node
and it could be any of 'Debit', 'Credit' and 'Check' that can be checked by following:
log.info "TrnType : " + TrnType.each{it}
TrnType = TrnType.toString()
len = TrnType.length()
TrnType = TrnType.substring(1,len-1) // this is needed to trim off '[' and ']' from returned string
log.info "TrnType : to string " + TrnType.each{it}
assert (TrnType in ["Debit", "Credit", "Check"])
Hope it helps...
Rather than comparing like -> assert (TrnType.each{it} in ["Debit", "Credit", "Check"])
you should use -> assert (TrnType.each{it} == ["Debit", "Credit", "Check"]) if the order of fields returned are 'Debit', 'Credit' and 'Check' and if TrnType is holding 3 values.
If it contains one value
ie while fetching -> TrnType = holder.getNodeValues("//ns:BankAcctTrnRec[1]//ns:TrnType") say from 1st node
and it could be any of 'Debit', 'Credit' and 'Check' that can be checked by following:
log.info "TrnType : " + TrnType.each{it}
TrnType = TrnType.toString()
len = TrnType.length()
TrnType = TrnType.substring(1,len-1) // this is needed to trim off '[' and ']' from returned string
log.info "TrnType : to string " + TrnType.each{it}
assert (TrnType in ["Debit", "Credit", "Check"])
Hope it helps...