use of io.restassured.module.mockmvc.internal.MockMvcRequestSpecificationImpl in project rest-assured by rest-assured.
the class RestAssuredMockMvc method enableLoggingOfRequestAndResponseIfValidationFails.
/**
* Enable logging of both the request and the response if REST Assureds test validation fails with the specified log detail.
* <p/>
* <p>
* This is just a shortcut for:
* </p>
* <pre>
* RestAssured.config = new RestAssuredMockMvcConfig().logConfig(logConfig().enableLoggingOfRequestAndResponseIfValidationFails(logDetail));
* </pre>
*
* @param logDetail The log detail to show in the log
*/
public static void enableLoggingOfRequestAndResponseIfValidationFails(LogDetail logDetail) {
config = config == null ? new RestAssuredMockMvcConfig() : config;
config = config.logConfig(logConfig().enableLoggingOfRequestAndResponseIfValidationFails(logDetail));
// Note that request spec also influence response spec when it comes to logging if validation fails due to the way filters work
if (requestSpecification != null && requestSpecification instanceof MockMvcRequestSpecificationImpl) {
RestAssuredMockMvcConfig restAssuredConfig = ((MockMvcRequestSpecificationImpl) requestSpecification).getRestAssuredMockMvcConfig();
if (restAssuredConfig == null) {
restAssuredConfig = config;
} else {
LogConfig logConfigForRequestSpec = restAssuredConfig.getLogConfig().enableLoggingOfRequestAndResponseIfValidationFails(logDetail);
restAssuredConfig = restAssuredConfig.logConfig(logConfigForRequestSpec);
}
requestSpecification.config(restAssuredConfig);
}
}
Aggregations