fr.close();
}
@Test
public void testWithFactory() throws Exception {
CSVReaderBuilder rbf = new CSVReaderBuilder();
rbf.write("FIELD", "COLUMNS", "EMPTYACTION", "MAPPINGS");
rbf.write("ID", "1", "COMPLAIN", "");
rbf.write("FIRSTNAME", "la la {2}", "IGNORE", ".+ ::");
rbf.write("LASTNAME", "2 ;", "IGNORE", " .+::");
rbf.write("BIRTHDATE", "3", "IGNORE", "(.*)\\.(.*)\\.(.*)::$3-$2-$1");
rbf.write("DESCRIPTION", "This is ({2}) who was born on ({3}) with id ({1}).", "COMPLAIN", "");
FieldSourceFactory fsf = new FieldSourceFactory(rbf.toReader());
fsf.getReader().computeFieldSourcesFromName(EmptyAction.IGNORE);
fsf.getReader().readHeader(false);
Map<TestFields, FieldSource> fs = fsf.createFieldSources(TestFields.values());
CSVReaderBuilder rb = new CSVReaderBuilder();
rb.write("ID", "LAST FIRST", "DOB");
rb.write("000000", "", "");
rb.write("123456", "Doe John", "");
rb.write("123457", "Doe ", "29.03.2001");
EnumFieldReader<TestFields, Object> fr = new EnumFieldReader<TestFields, Object>(TestFields.values(), rb.toReader());
fr.setFieldSources(fs);
fr.readHeader(true);
Map<TestFields, Object> record;
int counter = 0;
while ((record = fr.read()) != null) {