use of org.jdbi.v3.core.generic.GenericType in project jdbi by jdbi.
the class TestVavrTupleRowMapperFactoryWithDB method testMapTuple3WithoutSpecifiedColumn_shouldFail.
@Test
public void testMapTuple3WithoutSpecifiedColumn_shouldFail() throws SQLException {
Handle handle = dbRule.getSharedHandle();
handle.registerRowMapper(new SomethingMapper());
assertThatThrownBy(() -> handle.createQuery("select * from something where id = 1").mapTo(new GenericType<Tuple3<Integer, Something, Integer>>() {
}).findOnly()).isInstanceOf(NoSuchMapperException.class).hasMessageContaining("TupleMappers config class");
}
use of org.jdbi.v3.core.generic.GenericType in project jdbi by jdbi.
the class TestVavrTupleRowMapperFactoryWithDB method testMapTuple3WithAllSpecifiedColumns_shouldRespectConfiguration.
@Test
public void testMapTuple3WithAllSpecifiedColumns_shouldRespectConfiguration() throws SQLException {
Handle handle = dbRule.getSharedHandle();
handle.configure(TupleMappers.class, c -> c.setColumn(1, "integerValue").setColumn(2, "intValue").setColumn(3, "id"));
Tuple3<Integer, Integer, Integer> result = handle.createQuery("select * from something where id = 1").mapTo(new GenericType<Tuple3<Integer, Integer, Integer>>() {
}).findOnly();
assertThat(result._1).isEqualTo(99);
assertThat(result._2).isEqualTo(100);
assertThat(result._3).isEqualTo(1);
}
use of org.jdbi.v3.core.generic.GenericType in project jdbi by jdbi.
the class TestVavrTupleRowMapperFactoryWithDB method testMapTuple3WithOnlyOneSpecifiedColumn_shouldFail.
@Test
public void testMapTuple3WithOnlyOneSpecifiedColumn_shouldFail() throws SQLException {
Handle handle = dbRule.getSharedHandle();
handle.registerRowMapper(new SomethingMapper());
handle.configure(TupleMappers.class, c -> c.setColumn(1, "integerValue"));
assertThatThrownBy(() -> handle.createQuery("select * from something where id = 1").mapTo(new GenericType<Tuple3<Integer, Something, Integer>>() {
}).findOnly()).isInstanceOf(NoSuchMapperException.class).isInstanceOf(NoSuchMapperException.class).hasMessageContaining("TupleMappers config class");
}
Aggregations