use of org.simpleflatmapper.reflect.getter.GetterFactory in project SimpleFlatMapper by arnaudroger.
the class JdbcMapperFactoryTest method testCustomGetterFactory.
@Test
public void testCustomGetterFactory() throws SQLException {
JdbcMapper<DbObject> mapper = JdbcMapperFactoryHelper.asm().getterFactory(new GetterFactory<ResultSet, JdbcColumnKey>() {
@SuppressWarnings("unchecked")
@Override
public <P> Getter<ResultSet, P> newGetter(Type target, JdbcColumnKey key, Object... properties) {
return new Getter() {
@Override
public Object get(Object target) throws Exception {
return "Hello!";
}
};
}
}).newBuilder(DbObject.class).addMapping("name").mapper();
ResultSet rs = mock(ResultSet.class);
when(rs.next()).thenReturn(true, false);
DbObject object = mapper.iterator(rs).next();
assertEquals("Hello!", object.getName());
}
Aggregations