Comparing values using Assert that

Comparing result API response and value reading from Excel input file using:
assertThat(supplierItemPOSTResp.eachPrice).isEqualTo(suppItemEachPrice)

However it returned error:
org.junit.ComparisonFailure: expected:<1.8[0]> but was:<1.8[]>

The value should be correct, not sure why it is returning extra [] or [0]

Hi Belinda, Welcome to Katalon

try removing space ? sorry didn’t tried it
can you try printing both values in variable and compare ?

I think I got to understand [0] means. It’s because the string read from excel has extra 0 at the end i.e. 1.80 but the API response returns 1.8. That’s why using String compares fails.

In this case, if we use assertThat(x1).contains(x2) should work?

I tried convert the API response to Float using Floatparse, also doesn’t work. It will give me BigDecimal error.

Please help if you know any other alternative

Pls share the code … unable to say
Assert will also not work.
you have to print the Response via slurper

Response = WS.sendRequest(findTestObject(‘requestname’))
ResponseText = Response.getResponseText()
JsonSlurper slurper = new JsonSlurper()
Map parsedJson = slurper.parseText(ResponseText)

Then get both value in variable 

def x1 = value of response
def x2 = value 2 from response
To verify
println(x1)
println(x2)
 or another way to do check 
def x = 1.08 as Double
def y = 7.12 as Double

print 'Sum of x + y = ' + (x + y).round(2)

//Then try this
 assertThat(x1).contains(x2)