US_20
6 years agoOccasional Contributor
Assertions with conditions
Hi,
I am new to SOAP UI, I have a JDBC request which is a select query and it returns an XML response.
JDBC request (say Request B)==> In response, there is a field, Order total which returns 0 ...
- 6 years ago
I mocked up a rest request with the response you provided, but I ran into a problem mocking out a JDBC request since I don't have ready access to a database. Still, I was able to put together a groovy script that will compare a value returned by the rest request in the morphOnlyNetAmount in the response against a REFUNDABLE_AMOUNT if the latter is a postive integer. You'll need to adjust the script to your own uses, but it should be a good start.
package json import com.eviware.soapui.support.XmlHolder import groovy.json.* // Cna use the right-click Get-Data menu here to get the rest request response. def restResponse = context.expand( '${REST Request#Response}' ) log.info(restResponse); def r = new JsonSlurper().parseText(restResponse) // Gets the morphOnlyNetAmount from response and converts to float. def restValue = r.morphOnlyNetAmount.toFloat(); // You need to use the right-click Get-Data menu here to ensure it works as expected. Without a fully formed JDBC response, I cannot fully mock this out. def jdbcResponse = context.expand( '${JDBC Requests#Response#//REFUNDABLE_AMOUNT[1]}' ).toFloat(); if (jdbcResponse > 0) { assert (jdbcResponse == restValue) }