use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class RowMapperFactoryTest method testMapToDbObject.
@Test
public void testMapToDbObject() throws Exception {
Jdbi dbi = Jdbi.create(DbHelper.getHsqlDataSource());
dbi.installPlugins();
Handle handle = dbi.open();
try {
DbObject dbObject = handle.createQuery(DbHelper.TEST_DB_OBJECT_QUERY).mapTo(DbObject.class).findFirst().get();
DbHelper.assertDbObjectMapping(dbObject);
} finally {
handle.close();
}
}
use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class SheetMapperBuilderTest method testMapDbObjectFromRow.
@Test
public void testMapDbObjectFromRow() {
SheetMapperBuilder<DbObject> builder = SheetMapperFactory.newInstance().newBuilder(DbObject.class);
builder.addMapping("id").addMapping("name").addMapping("email").addMapping("creation_time").addMapping("type_ordinal").addMapping("type_name");
RowMapper<DbObject> mapper = builder.mapper();
final DbObject dbObject = mapper.map(row);
assertEquals(13, dbObject.getId());
assertEquals("name", dbObject.getName());
assertEquals("email", dbObject.getEmail());
assertTrue(Math.abs(now.getTime() - dbObject.getCreationTime().getTime()) < 1000);
assertEquals(DbObject.Type.type2, dbObject.getTypeOrdinal());
assertEquals(DbObject.Type.type3, dbObject.getTypeName());
}
use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class QueryDSLTest method testMappingProjection.
@Test
public void testMappingProjection() throws Exception {
Connection conn = DbHelper.objectDb();
SQLQuery sqlquery = new SQLQuery(conn, new HSQLDBTemplates());
try {
List<DbObject> list = sqlquery.from(qTestDbObject).where(qTestDbObject.id.eq(1l)).list(new QueryDslMappingProjection<DbObject>(DbObject.class, qTestDbObject.id, qTestDbObject.name, qTestDbObject.email, qTestDbObject.creationTime, qTestDbObject.typeName, qTestDbObject.typeOrdinal));
assertEquals(1, list.size());
DbHelper.assertDbObjectMapping(list.get(0));
} finally {
conn.close();
}
}
Aggregations