use of org.jdbi.v3.core.mapper.JoinRowMapperTest.User in project jdbi by jdbi.
the class TestVavrMapCollectorWithDB method uniqueIndex.
/**
* from {@link org.jdbi.v3.core.mapper.MapEntryMapperTest}
*/
@Test
public void uniqueIndex() {
Handle h = dbRule.getSharedHandle();
h.execute("create table user (id int, name varchar)");
h.prepareBatch("insert into user (id, name) values (?, ?)").add(1, "alice").add(2, "bob").add(3, "cathy").add(4, "dilbert").execute();
Map<Integer, User> map = h.createQuery("select * from user").setMapKeyColumn("id").registerRowMapper(ConstructorMapper.factory(User.class)).collectInto(new GenericType<Map<Integer, User>>() {
});
assertThat(map).containsOnly(Tuple.of(1, new User(1, "alice")), Tuple.of(2, new User(2, "bob")), Tuple.of(3, new User(3, "cathy")), Tuple.of(4, new User(4, "dilbert")));
}
Aggregations