use of io.helidon.dbclient.DbRow in project helidon by oracle.
the class InitIT method testListPokemons.
/**
* Verify that database contains properly initialized pokemons.
*/
@Test
public void testListPokemons() {
Multi<DbRow> rows = DB_CLIENT.execute(exec -> exec.namedQuery("select-pokemons"));
assertThat(rows, notNullValue());
List<DbRow> rowsList = rows.collectList().await();
assertThat(rowsList, not(empty()));
Set<Integer> ids = new HashSet<>(POKEMONS.keySet());
for (DbRow row : rowsList) {
Integer id = row.column(1).as(Integer.class);
String name = row.column(2).as(String.class);
assertThat(ids, hasItem(id));
ids.remove(id);
assertThat(name, POKEMONS.get(id).getName().equals(name));
}
}
use of io.helidon.dbclient.DbRow in project helidon by oracle.
the class InitIT method testListTypes.
/**
* Verify that database contains properly initialized pokemon types.
*/
@Test
public void testListTypes() {
Multi<DbRow> rows = DB_CLIENT.execute(exec -> exec.namedQuery("select-types"));
assertThat(rows, notNullValue());
List<DbRow> rowsList = rows.collectList().await(5, TimeUnit.SECONDS);
assertThat(rowsList, not(empty()));
Set<Integer> ids = new HashSet<>(TYPES.keySet());
for (DbRow row : rowsList) {
Integer id = row.column(1).as(Integer.class);
String name = row.column(2).as(String.class);
assertThat(ids, hasItem(id));
ids.remove(id);
assertThat(name, TYPES.get(id).getName().equals(name));
}
}
use of io.helidon.dbclient.DbRow in project helidon by oracle.
the class GetStatementIT method testGetMappedOrderParam.
/**
* Verify {@code indexedParam(Object parameters)} mapped parameters setting method.
*
* @throws ExecutionException when database query failed
* @throws InterruptedException if the current thread was interrupted
*/
@Test
public void testGetMappedOrderParam() throws ExecutionException, InterruptedException {
RangePoJo range = new RangePoJo(6, 8);
Optional<DbRow> maybeRow = DB_CLIENT.execute(exec -> exec.createNamedGet("select-pokemons-idrng-order-arg").indexedParam(range).execute()).toCompletableFuture().get();
verifyPokemonsIdRange(maybeRow, 6, 8);
}
use of io.helidon.dbclient.DbRow in project helidon by oracle.
the class QueryStatementIT method testQueryMappedNamedParam.
/**
* Verify {@code namedParam(Object parameters)} mapped parameters setting method.
*/
@Test
public void testQueryMappedNamedParam() {
RangePoJo range = new RangePoJo(1, 7);
Multi<DbRow> rows = DB_CLIENT.execute(exec -> exec.createNamedQuery("select-pokemons-idrng-named-arg").namedParam(range).execute());
verifyPokemonsIdRange(rows, 1, 7);
}
use of io.helidon.dbclient.DbRow in project helidon by oracle.
the class CheckIT method testDmlStatementExecution.
/**
* Simple test to verify that DML query execution works.
* Used before running database schema initialization.
*
* @throws ExecutionException when database query failed
* @throws InterruptedException if the current thread was interrupted
*/
@Test
public void testDmlStatementExecution() throws ExecutionException, InterruptedException {
Multi<DbRow> result = DB_CLIENT.execute(exec -> exec.namedQuery("ping-query"));
List<DbRow> rowsList = result.collectList().await(5, TimeUnit.SECONDS);
DbRow row = rowsList.get(0);
Double ok = row.column("ok").as(Double.class);
assertThat(ok, equalTo(1.0));
LOGGER.info(() -> String.format("Command ping row: %s", row.toString()));
}
Aggregations