lundi 6 août 2018

RestAssured: is it possible to compare body as object in rest-assured short-style?

So currently I test my rest service like this:

@Test
public void findByLogin() {
    Response response = configureRequest()
            .when()
            .get(String.format("/%s", userToEdit.getLogin()));
    response.then()
            .statusCode(HttpServletResponse.SC_OK);

    User responseUser = response.getBody().as(User.class);
    assertEquals(userToEdit, responseUser);
}

And what I'm interested in, if I can to achieve something like this:

@Test
public void findByLogin() {
    Response response = configureRequest()
            .when()
            .get(String.format("/%s", userToEdit.getLogin()));
    response.then()
            .statusCode(HttpServletResponse.SC_OK)
            .body(is(userToEdit));
}

Currently it gives me Json object (map I guess) and it's failed.

Aucun commentaire:

Enregistrer un commentaire