Search in sources :

Example 1 with SfmRecordMapperProvider

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);
}
Also used : SfmRecordMapperProvider(org.simpleflatmapper.jooq.SfmRecordMapperProvider) Test(org.junit.Test)

Example 2 with SfmRecordMapperProvider

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);
}
Also used : Issue318Test.createField(org.simpleflatmapper.jooq.test.Issue318Test.createField) Field(org.jooq.Field) SfmRecordMapperProvider(org.simpleflatmapper.jooq.SfmRecordMapperProvider) Record(org.jooq.Record) Test(org.junit.Test)

Example 3 with SfmRecordMapperProvider

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());
}
Also used : JooqRecordMapperWrapper(org.simpleflatmapper.jooq.JooqRecordMapperWrapper) DbObject(org.simpleflatmapper.test.beans.DbObject) SfmRecordMapperProvider(org.simpleflatmapper.jooq.SfmRecordMapperProvider) Test(org.junit.Test)

Example 4 with SfmRecordMapperProvider

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));
}
Also used : DbObject(org.simpleflatmapper.test.beans.DbObject) SfmRecordMapperProvider(org.simpleflatmapper.jooq.SfmRecordMapperProvider) Connection(java.sql.Connection) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Test(org.junit.Test)

Example 5 with SfmRecordMapperProvider

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);
}
Also used : SfmRecordMapperProvider(org.simpleflatmapper.jooq.SfmRecordMapperProvider) ConnectionParam(org.simpleflatmapper.db.ConnectionParam) DefaultConfiguration(org.jooq.impl.DefaultConfiguration)

Aggregations

SfmRecordMapperProvider (org.simpleflatmapper.jooq.SfmRecordMapperProvider)7 DefaultConfiguration (org.jooq.impl.DefaultConfiguration)4 Test (org.junit.Test)4 ConnectionParam (org.simpleflatmapper.db.ConnectionParam)3 DbObject (org.simpleflatmapper.test.beans.DbObject)2 Connection (java.sql.Connection)1 Field (org.jooq.Field)1 Record (org.jooq.Record)1 MappedObject4 (org.simpleflatmapper.beans.MappedObject4)1 TestSmallBenchmarkObjectRecord (org.simpleflatmapper.beans.tables.records.TestSmallBenchmarkObjectRecord)1 JooqRecordMapperWrapper (org.simpleflatmapper.jooq.JooqRecordMapperWrapper)1 Issue318Test.createField (org.simpleflatmapper.jooq.test.Issue318Test.createField)1