Search in sources :

Example 1 with CsvMapperFactory

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

the class CsvMapperJoinTest method testDynamicProfessorField.

@Test
public void testDynamicProfessorField() throws IOException {
    final CsvMapperFactory mapperFactory = getCsvMapperFactory();
    final List<ProfessorField> professors = mapperFactory.newMapper(ProfessorField.class).forEach(new StringReader(HEADER_DATA), new ListCollector<ProfessorField>()).getList();
    JoinTest.validateProfessors(professors);
}
Also used : ListCollector(org.simpleflatmapper.util.ListCollector) StringReader(java.io.StringReader) CsvMapperFactory(org.simpleflatmapper.csv.CsvMapperFactory) ProfessorField(org.simpleflatmapper.test.beans.ProfessorField) Test(org.junit.Test) JoinTest(org.simpleflatmapper.test.jdbc.JoinTest)

Example 2 with CsvMapperFactory

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

the class CsvMapperJoinTest method testDynamicProfessorC.

@Test
public void testDynamicProfessorC() throws IOException {
    final CsvMapperFactory mapperFactory = getCsvMapperFactory();
    final List<ProfessorC> professors = mapperFactory.newMapper(ProfessorC.class).forEach(new StringReader(HEADER_DATA), new ListCollector<ProfessorC>()).getList();
    JoinTest.validateProfessors(professors);
}
Also used : ListCollector(org.simpleflatmapper.util.ListCollector) StringReader(java.io.StringReader) CsvMapperFactory(org.simpleflatmapper.csv.CsvMapperFactory) ProfessorC(org.simpleflatmapper.test.beans.ProfessorC) Test(org.junit.Test) JoinTest(org.simpleflatmapper.test.jdbc.JoinTest)

Example 3 with CsvMapperFactory

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

the class CsvMapperDateFormatDefinitionTest method testCustomDateFormatOnFactory.

@Test
public void testCustomDateFormatOnFactory() throws IOException, ParseException {
    CsvMapperFactory csvMapperFactory = CsvMapperFactory.newInstance();
    csvMapperFactory.addColumnDefinition("date0", CsvColumnDefinition.dateFormatDefinition(df1).addTimeZone(tz1));
    csvMapperFactory.addColumnDefinition("date1", CsvColumnDefinition.dateFormatDefinition(df2).addTimeZone(tz2));
    CsvMapper<Tuple2<Date, Date>> mapper = csvMapperFactory.newMapper(Tuples.typeDef(Date.class, Date.class));
    Tuple2<Date, Date> next = mapper.iterator(new StringReader("date0,date1\n20140909,091409")).next();
    assertEquals(sdf1.parse("20140909"), next.first());
    assertEquals(sdf2.parse("091409"), next.second());
}
Also used : Tuple2(org.simpleflatmapper.tuple.Tuple2) StringReader(java.io.StringReader) CsvMapperFactory(org.simpleflatmapper.csv.CsvMapperFactory) Date(java.util.Date) Test(org.junit.Test)

Example 4 with CsvMapperFactory

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

the class CsvMapperJoinTest method testDynamicProfessorGS.

@Test
public void testDynamicProfessorGS() throws IOException {
    final CsvMapperFactory mapperFactory = getCsvMapperFactory();
    final List<ProfessorGS> professors = mapperFactory.newMapper(ProfessorGS.class).forEach(new StringReader(HEADER_DATA), new ListCollector<ProfessorGS>()).getList();
    JoinTest.validateProfessors(professors);
}
Also used : ProfessorGS(org.simpleflatmapper.test.beans.ProfessorGS) ListCollector(org.simpleflatmapper.util.ListCollector) StringReader(java.io.StringReader) CsvMapperFactory(org.simpleflatmapper.csv.CsvMapperFactory) Test(org.junit.Test) JoinTest(org.simpleflatmapper.test.jdbc.JoinTest)

Example 5 with CsvMapperFactory

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

the class CsvMapperJoinTest method testDynamicProfessorGSSharding.

@Test
public void testDynamicProfessorGSSharding() throws IOException {
    final CsvMapperFactory mapperFactory = getCsvShardingMapperFactory();
    final List<ProfessorGS> professors = mapperFactory.newMapper(ProfessorGS.class).forEach(new StringReader(HEADER_DATA), new ListCollector<ProfessorGS>()).getList();
    JoinTest.validateProfessors(professors);
}
Also used : ProfessorGS(org.simpleflatmapper.test.beans.ProfessorGS) ListCollector(org.simpleflatmapper.util.ListCollector) StringReader(java.io.StringReader) CsvMapperFactory(org.simpleflatmapper.csv.CsvMapperFactory) Test(org.junit.Test) JoinTest(org.simpleflatmapper.test.jdbc.JoinTest)

Aggregations

StringReader (java.io.StringReader)6 Test (org.junit.Test)6 CsvMapperFactory (org.simpleflatmapper.csv.CsvMapperFactory)6 JoinTest (org.simpleflatmapper.test.jdbc.JoinTest)5 ListCollector (org.simpleflatmapper.util.ListCollector)5 ProfessorC (org.simpleflatmapper.test.beans.ProfessorC)2 ProfessorGS (org.simpleflatmapper.test.beans.ProfessorGS)2 Date (java.util.Date)1 ProfessorField (org.simpleflatmapper.test.beans.ProfessorField)1 Tuple2 (org.simpleflatmapper.tuple.Tuple2)1