Search in sources :

Example 1 with DbFinal1DeepObject

use of org.simpleflatmapper.test.beans.DbFinal1DeepObject in project SimpleFlatMapper by arnaudroger.

the class CsvMapperBuilderSubObjectTest method testMapDbFinalObject.

@Test
public void testMapDbFinalObject() throws Exception {
    CsvMapperBuilder<DbFinal1DeepObject> builder = new CsvMapperBuilder<DbFinal1DeepObject>(DbFinal1DeepObject.class);
    addDbObjectFields(builder);
    CsvMapper<DbFinal1DeepObject> mapper = builder.mapper();
    List<DbFinal1DeepObject> list = mapper.forEach(db1deepObjectCsvReader(), new ListCollector<DbFinal1DeepObject>()).getList();
    assertEquals(1, list.size());
    DbFinal1DeepObject o = list.get(0);
    assertEquals(1234, o.getId());
    assertEquals("val!", o.getValue());
    DbHelper.assertDbObjectMapping(o.getDbObject());
}
Also used : ListCollector(org.simpleflatmapper.util.ListCollector) CsvMapperBuilder(org.simpleflatmapper.csv.CsvMapperBuilder) DbFinal1DeepObject(org.simpleflatmapper.test.beans.DbFinal1DeepObject) Test(org.junit.Test)

Example 2 with DbFinal1DeepObject

use of org.simpleflatmapper.test.beans.DbFinal1DeepObject in project SimpleFlatMapper by arnaudroger.

the class AbstractMapperBuilderTest method testDbFinal1DeepObject.

@Test
public void testDbFinal1DeepObject() throws Exception {
    ClassMeta<DbFinal1DeepObject> classMeta = ReflectionService.newInstance().<DbFinal1DeepObject>getClassMeta(DbFinal1DeepObject.class);
    Mapper<Object[], DbFinal1DeepObject> mapper = new SampleMapperBuilder<DbFinal1DeepObject>(classMeta).addMapping("id").addMapping("value").addMapping("dbObject_id").addMapping("dbObject_name").mapper();
    DbFinal1DeepObject map = mapper.map(new Object[] { 1, "vvv", 2l, "wwww" });
    assertEquals(1, map.getId());
    assertEquals("vvv", map.getValue());
    assertEquals(2l, map.getDbObject().getId());
    assertEquals("wwww", map.getDbObject().getName());
}
Also used : DbFinal1DeepObject(org.simpleflatmapper.test.beans.DbFinal1DeepObject) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DbFinal1DeepObject (org.simpleflatmapper.test.beans.DbFinal1DeepObject)2 CsvMapperBuilder (org.simpleflatmapper.csv.CsvMapperBuilder)1 ListCollector (org.simpleflatmapper.util.ListCollector)1