use of org.simpleflatmapper.csv.CsvMapperBuilder in project SimpleFlatMapper by arnaudroger.
the class CsvMapperBuilderSubObjectTest method testMapDbObjectWithCustomReader.
@Test
public void testMapDbObjectWithCustomReader() throws Exception {
CsvMapperBuilder<Db1DeepObject> builder = new CsvMapperBuilder<Db1DeepObject>(Db1DeepObject.class, ReflectionService.newInstance(false));
CsvColumnDefinition columnDefinition = CsvColumnDefinition.customReaderDefinition(new CellValueReader<String>() {
@Override
public String read(char[] chars, int offset, int length, ParsingContext parsingContext) {
return "cv1";
}
});
builder.addMapping("db_Object_name", columnDefinition);
CsvMapper<Db1DeepObject> mapper = builder.mapper();
Db1DeepObject v1 = mapper.iterator(new StringReader("v1")).next();
assertEquals("cv1", v1.getDbObject().getName());
}
use of org.simpleflatmapper.csv.CsvMapperBuilder 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());
}
Aggregations