use of io.helidon.webserver.ServerResponse in project helidon by oracle.
the class MapperService method executeInsertTest.
private void executeInsertTest(final ServerRequest request, final ServerResponse response, final String testName, final String pokemonName, final List<Type> pokemonTypes, final TestDMLFunction test) {
LOGGER.fine(() -> String.format("Running Mapper.%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 Mapper.%s on server", testName));
response.send(exceptionStatus(ex));
}
}
use of io.helidon.webserver.ServerResponse in project helidon by oracle.
the class MapperService method executeDeleteTest.
private void executeDeleteTest(final ServerRequest request, final ServerResponse response, final String testName, final TestDMLFunction test) {
LOGGER.fine(() -> String.format("Running Mapper.%s on server", testName));
try {
String idStr = param(request, QUERY_ID_PARAM);
int id = Integer.parseInt(idStr);
Pokemon pokemon = Pokemon.POKEMONS.get(id);
test.apply(pokemon).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 Mapper.%s on server", testName));
response.send(exceptionStatus(ex));
}
}
use of io.helidon.webserver.ServerResponse in project helidon by oracle.
the class TransactionInsertService method executeTest.
// Common test execution code
private JsonObject 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));
}
return null;
}
use of io.helidon.webserver.ServerResponse in project helidon by oracle.
the class SimpleUpdateService 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.webserver.ServerResponse in project helidon by oracle.
the class DmlStatementService 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;
}
Aggregations