Zoran
Zoran

Reputation: 499

Response does not match (although it match)

Could someone assist in asserting following:

String Givencoordinates = "[[-45.85112, 18.17335], [-45.85164, 18.173283], [-45.85283, 18.17247]]"

Want to assert above string with following code:

given()
    .get(apiUrl)
    .then()
    .assertThat()
    .body(“angle", equalTo(Collections.singletonList(120)))
    .body("coordinates", equalTo((Collections.singletonList(Givencoordinates)));

The first step (body - angle) is passing, but for a second, getting the following error:

JSON path coordinates doesn't match.
Expected: <[[-45.85112, 18.17335], [-45.85164, 18.173283], [-45.85283, 18.17247]]>
Actual: [[-45.85112, 18.17335], [-45.85164, 18.173283], [-45.85283, 18.17247]]

Tried with (Collections.singletonList(Givencoordinates) & with (Arrays.asList(Givencoordinates), in assertion, but getting same error.

What could be solution for this error? Thank you

Upvotes: 0

Views: 66

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191854

The Junit output is calling toString on your data

You should try to define the expected value as an actual list rather than putting a single string into a list of one element

Upvotes: 1

Related Questions