use of io.restassured.module.mockmvc.response.MockMvcResponse in project rest-assured by rest-assured.
the class ResponseConverter method toStandardResponse.
static Response toStandardResponse(MockMvcResponse response) {
if (!(response instanceof MockMvcRestAssuredResponseImpl)) {
throw new IllegalArgumentException(MockMvcResponse.class.getName() + " must be an instance of " + MockMvcRestAssuredResponseImpl.class.getName());
}
MockMvcRestAssuredResponseImpl mvc = (MockMvcRestAssuredResponseImpl) response;
RestAssuredResponseImpl std = new RestAssuredResponseImpl();
std.setConnectionManager(mvc.getConnectionManager());
std.setContent(mvc.getContent());
std.setContentType(mvc.getContentType());
std.setCookies(mvc.detailedCookies());
std.setDecoderConfig(mvc.getDecoderConfig());
std.setDefaultContentType(mvc.getDefaultContentType());
std.setHasExpectations(mvc.getHasExpectations());
std.setResponseHeaders(mvc.getResponseHeaders());
std.setSessionIdName(mvc.getSessionIdName());
std.setStatusCode(mvc.getStatusCode());
std.setStatusLine(mvc.getStatusLine());
std.setRpr(mvc.getRpr());
std.setFilterContextProperties(mvc.getFilterContextProperties());
std.setLogRepository(mvc.getLogRepository());
return std;
}
use of io.restassured.module.mockmvc.response.MockMvcResponse in project rest-assured by rest-assured.
the class ExtractTest method can_extract_rest_assureds_mock_mvc_response.
@Test
public void can_extract_rest_assureds_mock_mvc_response() {
MockMvcResponse response = RestAssuredMockMvc.given().standaloneSetup(new GreetingController()).param("name", "Johan").when().get("/greeting").then().statusCode(200).body("id", equalTo(1)).extract().response();
assertThat(response.path("content")).isEqualTo("Hello, Johan!");
}
Aggregations