I am using GSON to serialise and deserialise JSON response while supplying as payload and mapping response to the data model.
Now, here id is auto-incremented from DB so we don't need to pass when creating payload.
JSON payload: (updateCustomer) {"first_name":"test", "last_name":"user"}
public class Address {
@SerializedName("id")
private Integer id;
@SerializedName("first_name")
private String firstname;
@SerializedName("last_name")
private String lastname;
....
}
Test:
Response response =
given()
.filter(new RequestLoggingFilter(this.requestCapture))
.filter(new ResponseLoggingFilter(this.responseCapture))
.filter(new ErrorLoggingFilter(this.errorCapture))
.header("Authorization", getSession().getToken())
.body(updateCustomer)
.when()
.put(Resource.UPDATE_CUSTOMER)
.then()
.extract().response();
Expected Response in response instance {"id":2234545, "first_name":"test", "last_name":"user"}
Response.toString() returns io.restassured.internal.RestAssuredResponseImpl@46320c9a instead of Response body string.
I've tried response.body().toString(),
@Expose(deserialize = false)
@SerializedName("id")
private Integer id;
but no luck.
Expecting the response body as the string so that I can map using GSON to Java objects to perform the validation but getting io.restassured.internal.RestAssuredResponseImpl@46320c9a
I appreciate if someone can please direct me on this issue.
Many thanks,