Hi,
I tried to use below:
def jdbcResponse = context.expand('${JDBC#ResponseAsXML#(//Results)}')
def results = new XmlSlurper().parseText(jdbcResponse)
.ResultSet.Row.collect{[transactionId: it.TRANSACTION_ID,
transactionDate: it.TRANSACTION_DATE_KEY,
transactionValue: it.TRANSACTION_VALUE,
totalDiscount: (it.TOTAL_DISCOUNT).toString(),
storeId: it.STORE_ID,
] }
log.info "JDBC -> " + results
def restResponse = context.expand('${Request#Response}')
def arrayOfTagInfo = new JsonSlurper().parseText(restResponse)
.transactions.collect{ [transactionId: it.transactionId,
transactionDate: it.transactionDate,
transactionValue: it.transactionValue,
totalDiscount:(it.totalDiscount).toString(),
storeId: it.storeId,
] }
log.info "JSON -> " + arrayOfTagInfo
assert results == arrayOfTagInfo
Now this is not able to compare values of - totalDiscount because in the values are :
JSON
"totalDiscount": -32.4
"totalDiscount": 0
JDBC XML
<TOTAL_DISCOUNT>-32.4</TOTAL_DISCOUNT>
<TOTAL_DISCOUNT/> ---------------------------------------> because from database, value of totaldiscount is null for this particular tag.
Please help!