use of io.helidon.tests.integration.tools.service.RemoteTestException in project helidon by oracle.
the class TransactionUpdateService method executeTest.
// Common test execution code
private JsonObject executeTest(final ServerRequest request, final ServerResponse response, final String testName, final TestFunction test) {
LOGGER.fine(() -> String.format("Running SimpleUpdateService.%s on server", testName));
try {
String name = param(request, QUERY_NAME_PARAM);
String idStr = param(request, QUERY_ID_PARAM);
int id = Integer.parseInt(idStr);
Pokemon srcPokemon = Pokemon.POKEMONS.get(id);
Pokemon updatedPokemon = new Pokemon(id, name, srcPokemon.getTypesArray());
test.apply(updatedPokemon).thenAccept(result -> response.send(AppResponse.okStatus(Json.createValue(result)))).exceptionally(t -> {
response.send(exceptionStatus(t));
return null;
});
} catch (RemoteTestException | NumberFormatException ex) {
LOGGER.fine(() -> String.format("Error in SimpleUpdateService.%s on server", testName));
response.send(exceptionStatus(ex));
}
return null;
}
use of io.helidon.tests.integration.tools.service.RemoteTestException in project helidon by oracle.
the class HealthCheckService method testHealthCheckWithCustomDML.
// Verify health check implementation using custom DML statement.
private void testHealthCheckWithCustomDML(final ServerRequest request, final ServerResponse response) {
LOGGER.fine(() -> "Running test HealthCheckService.testHealthCheckWithCustomDML on server");
Config cfgStatement = dbConfig.get("statements.ping-dml");
if (!cfgStatement.exists()) {
response.send(exceptionStatus(new RemoteTestException("Missing statements.ping-dml configuration parameter.")));
return;
}
Thread thread = new Thread(new HealthCheckThread(request, response, DbClientHealthCheck.builder(dbClient()).dml().statement(cfgStatement.as(String.class).get()).build()));
thread.start();
}
use of io.helidon.tests.integration.tools.service.RemoteTestException in project helidon by oracle.
the class HealthCheckService method testHealthCheckWithCustomQuery.
// Verify health check implementation using custom query statement.
private void testHealthCheckWithCustomQuery(final ServerRequest request, final ServerResponse response) {
LOGGER.fine(() -> "Running test HealthCheckService.testHealthCheckWithCustomQuery on server");
Config cfgStatement = dbConfig.get("statements.ping-query");
if (!cfgStatement.exists()) {
response.send(exceptionStatus(new RemoteTestException("Missing statements.ping-query configuration parameter.")));
return;
}
Thread thread = new Thread(new HealthCheckThread(request, response, DbClientHealthCheck.builder(dbClient()).query().statement(cfgStatement.as(String.class).get()).build()));
thread.start();
}
use of io.helidon.tests.integration.tools.service.RemoteTestException in project helidon by oracle.
the class SimpleInsertService method executeTest.
// Common test execution code
private void executeTest(final ServerRequest request, final ServerResponse response, final String testName, final String pokemonName, final List<Type> pokemonTypes, final TestFunction test) {
LOGGER.fine(() -> String.format("Running SimpleInsertService.%s on server", testName));
try {
String idStr = param(request, QUERY_ID_PARAM);
int id = Integer.parseInt(idStr);
Pokemon pokemon = new Pokemon(id, pokemonName, pokemonTypes);
test.apply(pokemon).thenAccept(result -> response.send(AppResponse.okStatus(pokemon.toJsonObject()))).exceptionally(t -> {
response.send(AppResponse.exceptionStatus(t));
return null;
});
} catch (RemoteTestException | NumberFormatException ex) {
LOGGER.fine(() -> String.format("Error in SimpleInsertService.%s on server", testName));
response.send(AppResponse.exceptionStatus(ex));
}
}
use of io.helidon.tests.integration.tools.service.RemoteTestException in project helidon by oracle.
the class QueryStatementService method executeTest.
// Common test execution code
private JsonObject executeTest(final ServerRequest request, final ServerResponse response, final String testName, final TestFunction test) {
LOGGER.fine(() -> String.format("Running SimpleQueryService.%s on server", testName));
try {
String fromIdStr = param(request, QUERY_FROM_ID_PARAM);
int fromId = Integer.parseInt(fromIdStr);
String toIdStr = param(request, QUERY_TO_ID_PARAM);
int toId = Integer.parseInt(toIdStr);
Multi<DbRow> future = test.apply(fromId, toId);
final JsonArrayBuilder jab = Json.createArrayBuilder();
future.forEach(dbRow -> jab.add(dbRow.as(JsonObject.class))).onComplete(() -> response.send(okStatus(jab.build()))).exceptionally(t -> {
response.send(exceptionStatus(t));
return null;
});
} catch (NumberFormatException | RemoteTestException ex) {
LOGGER.fine(() -> String.format("Error in SimpleQueryService.%s on server", testName));
response.send(exceptionStatus(ex));
}
return null;
}
Aggregations