use of io.restassured.mapper.factory.Jackson2ObjectMapperFactory in project snow-owl by b2ihealthcare.
the class RestExtensions method givenUnauthenticatedRequest.
public static RequestSpecification givenUnauthenticatedRequest(String api) {
if (INITIALIZE_ONCE.compareAndSet(false, true)) {
// change Base URI if defined as sysarg
final String serverLocation = System.getProperty("test.server.location");
if (!Strings.isNullOrEmpty(serverLocation)) {
RestAssured.baseURI = serverLocation;
}
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(ObjectMapperConfig.objectMapperConfig().jackson2ObjectMapperFactory(new Jackson2ObjectMapperFactory() {
@Override
public com.fasterxml.jackson.databind.ObjectMapper create(Type arg0, String arg1) {
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
mapper.registerModule(new JavaTimeModule());
// bbanfai: added date format
final StdDateFormat dateFormat = new StdDateFormat();
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
mapper.setDateFormat(dateFormat);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
return mapper;
}
})).logConfig(LogConfig.logConfig().enableLoggingOfRequestAndResponseIfValidationFails());
}
Preconditions.checkArgument(api.startsWith("/"), "Api param should start with a forward slash: '/'");
return given().port(getPort()).basePath(CONTEXT + api);
}
Aggregations