0

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.

Anton
  • 761
  • 17
  • 40
  • do you have any error? or what does it mean `doesn't work` ? – daggett Nov 06 '18 at 20:08
  • 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. – Anton Nov 06 '18 at 20:12

1 Answers1

1

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");
Anton
  • 761
  • 17
  • 40