OpenCsvRecordMapper implements RecordMapper<String, T> { @Override public Record<T> processRecord(final Record<String> record) throws Exception { String payload = record.getPayload(); CSVReader openCsvReader = new CSVReader( new StringReader(payload), delimiter, qualifier, strictQualifiers); List<T> list = csvToBean.parse(strategy, openCsvReader); T mappedObject = list.get(0); openCsvReader.close(); return new GenericRecord<>(record.getHeader(), mappedObject); } OpenCsvRecordMapper(Class<T> recordClass, String... columns); @Override Record<T> processRecord(final Record<String> record); void setDelimiter(final char delimiter); void setQualifier(final char qualifier); void setStrictQualifiers(boolean strictQualifiers);  }
@Test public void testOpenCsvMapping() throws Exception { StringRecord fooRecord = new StringRecord(header, "foo,bar,15,true"); Record<Foo> actual = openCsvRecordMapper.processRecord(fooRecord); assertThat(actual.getHeader()).isEqualTo(header); Foo foo = actual.getPayload(); assertThat(foo).isNotNull(); assertThat(foo.getFirstName()).isEqualTo("foo"); assertThat(foo.getLastName()).isEqualTo("bar"); assertThat(foo.getAge()).isEqualTo(15); assertThat(foo.isMarried()).isTrue(); }