It seems that the groovy matcher cannot find an equal float value. What I am exactly doing is ensuring that there is a map with exact values in the response body.
Here is the code
Float purchaseAmount = (Float) ((Map) travelSharedData.bookingPackage.get("total")).get("amount");
response.then().body(String.format("response.cashbacks.find() {it.purchaseAmount.amount == %.2f}", purchaseAmount), is(notNullValue()));
JSON
{
"response": {
"cashbacks": [
{
"date": "09-08-2017T12:56:39.000Z",
"purchaseAmount": {
"amount": 4963.91,
"currency": "USD"
},
"cashbackAmount": {
"amount": 99.28,
"currency": "USD"
},
"description": "Tulip House Boutique Hotel Bratislava",
"estimatedAvailable": "10-28-2017T00:00:00.000Z",
"status": "pending",
"eventType": "transaction"
}
]}}
Error
java.lang.AssertionError: 1 expectation failed.
JSON path response.cashbacks.find() {it.purchaseAmount.amount == 4963.91 && it.description == 'Tulip House Boutique Hotel Bratislava'} doesn't match.
Expected: is not null
Actual: null
Of course I can convert the values but I would like to know why exactly it fails.