Rest Assured: JSON path body doesn't match doubles

476rick :

I'm trying to test a API with Rest Assured. There is an AssertionError when I'm checking a double value.

The code for checking the double:

given().body(getTest()).contentType("application/json\r\n").
            when()
            .port(port)
            .basePath("/fff/test")
            .post("insert")
            .then()
            .assertThat()
            .statusCode(200)
            .body("versie", equalTo(11.0));

This is the output:

java.lang.AssertionError: 1 expectation failed.
JSON path versie doesn't match.
Expected: <11.0>
  Actual: 11.0

When I change the line with .body to:

.body("versie", equalTo(""+11.0));

The output is:

java.lang.AssertionError: 1 expectation failed.
JSON path versie doesn't match.
Expected: 11.0
  Actual: 11.0

Does anyone know how I can fix this? Because I really don't know how to solve this.

EDIT
The JSON:

{ 
  "id": 1,
  "naam": "Test X",
  "versie": 11.0
}
476rick :
.body("versie", equalTo(11.0f));

This did work for me.
The answer is based on a comment from @StanislavL.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=433666&siteId=1