use of io.helidon.dbclient.DbRow in project helidon by oracle.
the class InitIT method testListPokemonTypes.
/**
* Verify that database contains properly initialized pokemon types relation.
*/
@Test
public void testListPokemonTypes() {
Multi<DbRow> rows = DB_CLIENT.execute(exec -> exec.namedQuery("select-pokemons"));
assertThat(rows, notNullValue());
List<DbRow> rowsList = rows.collectList().await();
assertThat(rowsList, not(empty()));
for (DbRow row : rowsList) {
Integer pokemonId = row.column(1).as(Integer.class);
String pokemonName = row.column(2).as(String.class);
Pokemon pokemon = POKEMONS.get(pokemonId);
assertThat(pokemonName, POKEMONS.get(pokemonId).getName().equals(pokemonName));
Multi<DbRow> typeRows = DB_CLIENT.execute(exec -> exec.namedQuery("select-poketypes", pokemonId));
List<DbRow> typeRowsList = typeRows.collectList().await();
assertThat(typeRowsList.size(), equalTo(pokemon.getTypes().size()));
for (DbRow typeRow : typeRowsList) {
Integer typeId = typeRow.column(2).as(Integer.class);
assertThat(pokemon.getTypes(), hasItem(TYPES.get(typeId)));
}
}
}
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));
}
}
Aggregations