use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class SqlParameterSourceTest method getDbObject.
protected DbObject getDbObject() {
DbObject dbObject = new DbObject();
dbObject.setId(12345);
dbObject.setName("name");
dbObject.setEmail("email");
return dbObject;
}
use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class SqlParameterSourceTest method testMapping.
protected void testMapping(SqlParameterSourceFactory<DbObject> sqlParameterSourceFactory) {
DbObject dbObject = getDbObject();
SqlParameterSource parameterSource = sqlParameterSourceFactory.newSqlParameterSource(dbObject);
assertEquals(12345l, parameterSource.getValue("id"));
assertEquals("name", parameterSource.getValue("name"));
assertEquals("email", parameterSource.getValue("email"));
assertEquals(Types.BIGINT, parameterSource.getSqlType("id"));
assertEquals(Types.VARCHAR, parameterSource.getSqlType("name"));
assertEquals(null, parameterSource.getTypeName("id"));
assertEquals(null, parameterSource.getTypeName("name"));
}
use of org.simpleflatmapper.test.beans.DbObject 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.test.beans.DbObject 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.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class JooqMapperTest method testIgnoreFields.
@Test
public void testIgnoreFields() throws Exception {
Connection conn = DbHelper.objectDb();
DSLContext dsl = DSL.using(new DefaultConfiguration().set(conn).set(SQLDialect.HSQLDB).set(SfmRecordMapperProviderFactory.newInstance().addAlias("id", "noId").ignorePropertyNotFound().newProvider()));
List<DbObject> list = dsl.select().from("TEST_DB_OBJECT").fetchInto(DbObject.class);
assertEquals(2, list.size());
assertEquals(0, list.get(0).getId());
list.get(0).setId(1);
DbHelper.assertDbObjectMapping(list.get(0));
}
Aggregations