Search in sources :

Example 1 with CsvMapperBuilder

use of org.simpleflatmapper.csv.CsvMapperBuilder in project SimpleFlatMapper by arnaudroger.

the class CsvMapperImplTest method testStringRoot.

@Test
public void testStringRoot() throws IOException {
    CsvMapperBuilder<String> builder = new CsvMapperBuilder<String>(String.class);
    builder.addMapping("c1");
    CsvMapper<String> mapper = builder.mapper();
    assertEquals("0", mapper.iterator(new StringReader("0")).next());
}
Also used : CsvMapperBuilder(org.simpleflatmapper.csv.CsvMapperBuilder) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 2 with CsvMapperBuilder

use of org.simpleflatmapper.csv.CsvMapperBuilder in project SimpleFlatMapper by arnaudroger.

the class CsvMapperBuilderSubObjectTest method testMapDbPartialObject.

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

Example 3 with CsvMapperBuilder

use of org.simpleflatmapper.csv.CsvMapperBuilder in project SimpleFlatMapper by arnaudroger.

the class CsvMapperBuilderSubObjectTest method testMapDbObject.

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

Example 4 with CsvMapperBuilder

use of org.simpleflatmapper.csv.CsvMapperBuilder in project SimpleFlatMapper by arnaudroger.

the class CsvMapperBuilderSubObjectTest method testMapDbPartialObjectNoAsm.

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

Example 5 with CsvMapperBuilder

use of org.simpleflatmapper.csv.CsvMapperBuilder in project SimpleFlatMapper by arnaudroger.

the class CsvMapperImplTest method testEnumRoot.

@Test
public void testEnumRoot() throws IOException {
    CsvMapperBuilder<TypeRoot> builder = new CsvMapperBuilder<TypeRoot>(TypeRoot.class);
    builder.addMapping("c1");
    CsvMapper<TypeRoot> mapper = builder.mapper();
    assertEquals(TypeRoot.type1, mapper.iterator(new StringReader("0")).next());
}
Also used : CsvMapperBuilder(org.simpleflatmapper.csv.CsvMapperBuilder) StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 CsvMapperBuilder (org.simpleflatmapper.csv.CsvMapperBuilder)7 ListCollector (org.simpleflatmapper.util.ListCollector)4 StringReader (java.io.StringReader)3 Db1DeepObject (org.simpleflatmapper.test.beans.Db1DeepObject)2 Db1DeepPartialObject (org.simpleflatmapper.test.beans.Db1DeepPartialObject)2 CsvColumnDefinition (org.simpleflatmapper.csv.CsvColumnDefinition)1 ParsingContext (org.simpleflatmapper.csv.ParsingContext)1 DbFinal1DeepObject (org.simpleflatmapper.test.beans.DbFinal1DeepObject)1