0
votes

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
do you have any error? or what does it mean doesn't work ? - daggett
I'm running it in Java. The error is just thrown on that particular line. If I use the greater than and less than operators that little 'query' returns the integer value that I'm expecting. If I use the '==' operator, when Java hits that line it just crashes. The '==' operator doesn't work like I thought it would. No integer value is returned. - Dig Dug Dude

1 Answers

1
votes

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");