use of io.restassured.path.json.mapper.factory.Jackson2ObjectMapperFactory in project pyramus by otavanopisto.
the class AbstractRESTServiceTest method setupRestAssured.
@Before
public void setupRestAssured() {
RestAssured.baseURI = getAppUrl(true) + "/1";
RestAssured.port = getPortHttps();
RestAssured.authentication = certificate(getKeystoreFile(), getKeystorePass());
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(ObjectMapperConfig.objectMapperConfig().jackson2ObjectMapperFactory(new Jackson2ObjectMapperFactory() {
@Override
public com.fasterxml.jackson.databind.ObjectMapper create(Type cls, String charset) {
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
objectMapper.registerModule(new JSR310Module());
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
return objectMapper;
}
}));
}
use of io.restassured.path.json.mapper.factory.Jackson2ObjectMapperFactory in project mod-source-record-storage by folio-org.
the class AbstractRestVerticleTest method setUpClass.
@BeforeClass
public static void setUpClass(final TestContext context) throws Exception {
Async async = context.async();
vertx = Vertx.vertx();
String[] hostAndPort = cluster.getBrokerList().split(":");
System.setProperty(KAFKA_HOST, hostAndPort[0]);
System.setProperty(KAFKA_PORT, hostAndPort[1]);
System.setProperty(OKAPI_URL_ENV, OKAPI_URL);
okapiPort = NetworkUtils.nextFreePort();
String okapiUrl = "http://localhost:" + okapiPort;
useExternalDatabase = System.getProperty("org.folio.source.storage.test.database", "embedded");
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(new ObjectMapperConfig().jackson2ObjectMapperFactory(new Jackson2ObjectMapperFactory() {
@Override
public ObjectMapper create(Type arg0, String arg1) {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper;
}
}));
switch(useExternalDatabase) {
case "environment":
System.out.println("Using environment settings");
break;
case "external":
String postgresConfigPath = System.getProperty("org.folio.source.storage.test.config", "/postgres-conf-local.json");
PostgresClientFactory.setConfigFilePath(postgresConfigPath);
break;
case "embedded":
postgresSQLContainer = new PostgreSQLContainer<>(POSTGRES_IMAGE);
postgresSQLContainer.start();
Envs.setEnv(postgresSQLContainer.getHost(), postgresSQLContainer.getFirstMappedPort(), postgresSQLContainer.getUsername(), postgresSQLContainer.getPassword(), postgresSQLContainer.getDatabaseName());
break;
default:
String message = "No understood database choice made." + "Please set org.folio.source.storage.test.database" + "to 'external', 'environment' or 'embedded'";
throw new Exception(message);
}
TenantClient tenantClient = new TenantClient(okapiUrl, "diku", "dummy-token");
DeploymentOptions restVerticleDeploymentOptions = new DeploymentOptions().setConfig(new JsonObject().put("http.port", okapiPort));
vertx.deployVerticle(RestVerticle.class.getName(), restVerticleDeploymentOptions, res -> {
try {
TenantAttributes tenantAttributes = new TenantAttributes();
tenantAttributes.setModuleTo(ModuleName.getModuleName());
tenantAttributes.setParameters(Collections.singletonList(new Parameter().withKey(LOAD_SAMPLE_PARAMETER).withValue("true")));
tenantClient.postTenant(tenantAttributes, res2 -> {
if (res2.result().statusCode() == 204) {
return;
}
if (res2.result().statusCode() == 201) {
tenantClient.getTenantByOperationId(res2.result().bodyAsJson(TenantJob.class).getId(), 60000, context.asyncAssertSuccess(res3 -> {
context.assertTrue(res3.bodyAsJson(TenantJob.class).getComplete());
String error = res3.bodyAsJson(TenantJob.class).getError();
if (error != null) {
context.assertTrue(error.contains("EventDescriptor was not registered for eventType"));
}
}));
} else {
context.assertEquals("Failed to make post tenant. Received status code 400", res2.result().bodyAsString());
}
async.complete();
});
} catch (Exception e) {
e.printStackTrace();
async.complete();
}
});
}
use of io.restassured.path.json.mapper.factory.Jackson2ObjectMapperFactory in project mod-source-record-storage by folio-org.
the class AbstractLBServiceTest method setUpClass.
@BeforeClass
public static void setUpClass(TestContext context) throws Exception {
Async async = context.async();
vertx = Vertx.vertx();
String[] hostAndPort = cluster.getBrokerList().split(":");
System.setProperty(KAFKA_HOST, hostAndPort[0]);
System.setProperty(KAFKA_PORT, hostAndPort[1]);
System.setProperty(KAFKA_ENV, KAFKA_ENV_ID);
System.setProperty(KAFKA_MAX_REQUEST_SIZE, String.valueOf(KAFKA_MAX_REQUEST_SIZE_VAL));
System.setProperty(OKAPI_URL_ENV, OKAPI_URL);
kafkaConfig = KafkaConfig.builder().kafkaHost(hostAndPort[0]).kafkaPort(hostAndPort[1]).envId(KAFKA_ENV_ID).maxRequestSize(KAFKA_MAX_REQUEST_SIZE_VAL).build();
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(new ObjectMapperConfig().jackson2ObjectMapperFactory(new Jackson2ObjectMapperFactory() {
@Override
public ObjectMapper create(Type arg0, String arg1) {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper;
}
}));
PostgresClient.setPostgresTester(new PostgresTesterContainer());
JsonObject pgClientConfig = PostgresClient.getInstance(vertx).getConnectionConfig();
Envs.setEnv(pgClientConfig.getString(PostgresClientFactory.HOST), pgClientConfig.getInteger(PostgresClientFactory.PORT), pgClientConfig.getString(PostgresClientFactory.USERNAME), pgClientConfig.getString(PostgresClientFactory.PASSWORD), pgClientConfig.getString(PostgresClientFactory.DATABASE));
TenantClient tenantClient = new TenantClient(OKAPI_URL, TENANT_ID, TOKEN);
DeploymentOptions restVerticleDeploymentOptions = new DeploymentOptions().setConfig(new JsonObject().put("http.port", PORT));
vertx.deployVerticle(RestVerticle.class.getName(), restVerticleDeploymentOptions, deployResponse -> {
try {
tenantClient.postTenant(new TenantAttributes().withModuleTo("3.2.0"), res2 -> {
postgresClientFactory = new PostgresClientFactory(vertx);
if (res2.result().statusCode() == 204) {
return;
}
if (res2.result().statusCode() == 201) {
tenantClient.getTenantByOperationId(res2.result().bodyAsJson(TenantJob.class).getId(), 60000, context.asyncAssertSuccess(res3 -> {
context.assertTrue(res3.bodyAsJson(TenantJob.class).getComplete());
String error = res3.bodyAsJson(TenantJob.class).getError();
if (error != null) {
context.assertTrue(error.contains("EventDescriptor was not registered for eventType"));
}
}));
} else {
context.assertEquals("Failed to make post tenant. Received status code 400", res2.result().bodyAsString());
}
async.complete();
});
} catch (Exception e) {
e.printStackTrace();
async.complete();
}
});
}
Aggregations