GPath testing for decimal value

122 Views Asked by At

Using Rest Assured in Java to test some APIs. Trying to use GPath to return a value.

Why does this work?

int i = response.path("Result.find{it.Amount>293.50 && it.Amount<293.52 && it.CreatedDate=='10/26/2018'}.Id");

But this doesn't?

int i = response.path("Result.find{it.Amount==293.51 && it.CreatedDate=='10/26/2018'}.Id");

Does GPath have some weird thing about decimal values? I'm new to GPath and have tried researching but can't find anything conclusive.

1

There are 1 best solutions below

0
On

An exceptionally bright co-worker found the answer for me. Posting here to help those of you trying to figure it out.

In order to test double values it should read:

int i = response.path("Result.find{it.Amount.toDouble()==293.51 && it.CreatedDate=='10/26/2018'}.Id");