use of org.simpleflatmapper.jooq.SfmRecordMapperProvider in project SimpleFlatMapper by arnaudroger.
the class Issue318Test method testLocalDateTimeFromTimestamp.
// IFJAVA8_START
@SuppressWarnings("unchecked")
@Test
public void testLocalDateTimeFromTimestamp() throws SQLException {
SfmRecordMapperProvider recordMapperProvider = new SfmRecordMapperProvider();
RecordType<Record> rt = mock(RecordType.class);
Field[] fields = new Field[] { createField("t", Timestamp.class), createField("id", String.class) };
when(rt.size()).thenReturn(fields.length);
when(rt.fields()).thenReturn(fields);
RecordMapper<Record, Issue318> mapper = recordMapperProvider.provide(rt, Issue318.class);
assertNotNull(mapper);
}
use of org.simpleflatmapper.jooq.SfmRecordMapperProvider in project SimpleFlatMapper by arnaudroger.
the class Issue486Test method testIssue.
// IFJAVA8_START
@Test
public void testIssue() {
SfmRecordMapperProvider recordMapperProvider = new SfmRecordMapperProvider();
RecordType<Record> rt = mock(RecordType.class);
Field[] fields = new Field[] { createField("t", Timestamp.class), createField("id", String.class) };
when(rt.size()).thenReturn(fields.length);
when(rt.fields()).thenReturn(fields);
RecordMapper<Record, Issue486Test.Issue486> mapper = recordMapperProvider.provide(rt, Issue486Test.Issue486.class);
assertNotNull(mapper);
}
use of org.simpleflatmapper.jooq.SfmRecordMapperProvider in project SimpleFlatMapper by arnaudroger.
the class JooqMapperTest method testCacheMapper.
@Test
@SuppressWarnings("unchecked")
public void testCacheMapper() {
SfmRecordMapperProvider recordMapperProvider = new SfmRecordMapperProvider();
RecordType rt = mock(RecordType.class);
Field field1 = mock(Field.class);
when(field1.getName()).thenReturn("id");
when(field1.getType()).thenReturn(long.class);
when(rt.size()).thenReturn(1);
when(rt.fields()).thenReturn(new Field[] { field1 });
JooqRecordMapperWrapper provider1 = (JooqRecordMapperWrapper) recordMapperProvider.<Record, DbObject>provide(rt, DbObject.class);
JooqRecordMapperWrapper provider2 = (JooqRecordMapperWrapper) recordMapperProvider.<Record, DbObject>provide(rt, DbObject.class);
assertSame(provider1.getMapper(), provider2.getMapper());
}
use of org.simpleflatmapper.jooq.SfmRecordMapperProvider in project SimpleFlatMapper by arnaudroger.
the class JooqMapperTest method testMapperDbObject.
@Test
public void testMapperDbObject() throws Exception {
Connection conn = DbHelper.objectDb();
DSLContext dsl = DSL.using(new DefaultConfiguration().set(conn).set(SQLDialect.HSQLDB).set(new SfmRecordMapperProvider()));
List<DbObject> list = dsl.select().from("TEST_DB_OBJECT").fetchInto(DbObject.class);
assertEquals(2, list.size());
DbHelper.assertDbObjectMapping(list.get(0));
}
use of org.simpleflatmapper.jooq.SfmRecordMapperProvider in project mapping-benchmark by arnaudroger.
the class JooqSfmBenchmark method init.
@Setup
public void init() throws Exception {
ConnectionParam cp = new ConnectionParam();
cp.db = db;
cp.init();
dsl = DSL.using(new DefaultConfiguration().set(cp.dataSource).set(JooqMapperBenchmark.getSqlDialect(db)).set(new SfmRecordMapperProvider()));
select4 = dsl.selectFrom(TestSmallBenchmarkObject.TEST_SMALL_BENCHMARK_OBJECT);
select16 = dsl.selectFrom(TestBenchmarkObject_16.TEST_BENCHMARK_OBJECT_16);
}
Aggregations