Anton
Anton

Reputation: 920

GPath testing for decimal value

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.

Upvotes: 0

Views: 122

Answers (1)

Anton
Anton

Reputation: 920

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

Upvotes: 1

Related Questions