Forum Discussion

Subratsingh's avatar
Subratsingh
Occasional Contributor
11 years ago

trim zeros after retrieving val from db query

Hi,

My db query returns say val like, '86523.110000' and my soap response has a node value like '86523.11' which i need to assert. I need to remove the zeros after I retrieve the val from db and assert with the soap response node val. How can I do this?

Thank you!

6 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Have you tried trimming zeros from while getting value from db?
  • Subratsingh's avatar
    Subratsingh
    Occasional Contributor
    Want to do that, but not knowing how to do this as I'm new to this SoapUI and groovy scripting.
  • JimLin's avatar
    JimLin
    Occasional Contributor
    I use this in a Groovy step. You can adjust the number of digits by increasing or decreasing the -3:

    // Remove trailing zeros
    def firstDepositMinusZero = firstDeposit[0..-3] as int
  • Subratsingh's avatar
    Subratsingh
    Occasional Contributor
    Thanks Jim that worked for me. Sorry, was on vacation hence the delay in response

    I need your thoughts on this,

    I've a requirement where in I need to assert the XML response node val. The val basically is the average of 3 column values fethched from a DB query. To be precise, the 3 column values are fetched from 3 different queries. I need to assert the average of these 3 column vals and assert with the xml node respose. How to do this, I understand I need to fetch these 3 column values to 3 variables and then do the script assertion to calculate the average and assert. But not knowing the steps in SoapUI pro, can you please suggest? Thank you!