Forum Discussion

ssharma's avatar
ssharma
Contributor
14 years ago

[Resolved] soapUI and multiplication symbol

Hi I have a simple script that reads from the xml datasource and multiplies the two attributes . The multiplication symbol * does not work .

eg. The line is attr 1 = attr 2 * 1.06 but it always returns the value of attr2 .
  • Hello,

    can you please copy/paste the entire script verbatim ?
    I'm guessing it's just a syntax issue, but we'll see once you add the script.

    Regards,
    Vladimir
    SmartBear Software
  • import com.eviware.soapui.support.XmlHolder
    def groovyutils = new com.eviware.soapui.support.GroovyUtils(context)
    def holder = new XmlHolder( messageExchange.responseContentAsXml )
    holder.namespaces["tns"] = "http://pss.com/PartSelect-v1"
    holder.namespaces["psi"] = "http://pss.com/PartSelect/2011-07-21"

    def quart = context.expand( '${Validate Fluid#Quarts}' ) //get value from datasource
    def liter = context.expand( '${Validate Fluid#Liters}' ) // get value from datasource

    //log.info liter
    //log.info quart

    if (quart == (liter * 1.05))
    {assert true }
    else
    {assert false }

    } // end of node1.each
  • Hi,

    you might need to convert these values to their corresponding number types, ie


    def quart = Float.parseFloat(context.expand( '${Validate Fluid#Quarts}' )) //get value from datasource
    def liter = Float.parseFloat( context.expand( '${Validate Fluid#Liters}' )) // get value from datasource

    (or whatever type is appropriate)

    Does that help?

    regards!

    /Ole
    SmartBear Software