@Test public void testApacheCommonCsvMapping() throws Exception { StringReader stringReader = new StringReader("foo,bar,15,true"); CSVFormat csvFormat = CSVFormat.DEFAULT.withHeader("firstName", "lastName", "age", "married"); ApacheCommonCsvRecord record = getApacheCommonCsvRecord(stringReader, csvFormat); Foo foo = mapper.mapRecord(record); assertThat(foo).isNotNull(); assertThat(foo.getFirstName()).isEqualTo("foo"); assertThat(foo.getLastName()).isEqualTo("bar"); assertThat(foo.getAge()).isEqualTo(15); assertThat(foo.isMarried()).isTrue(); }
@Test public void testApacheCommonCsvQualifier() throws Exception { StringReader stringReader = new StringReader("'foo,s','bar,n'"); CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'').withHeader("firstName", "lastName", "age", "married"); ApacheCommonCsvRecord record = getApacheCommonCsvRecord(stringReader, csvFormat); Foo foo = mapper.mapRecord(record); assertThat(foo).isNotNull(); assertThat(foo.getFirstName()).isEqualTo("foo,s"); assertThat(foo.getLastName()).isEqualTo("bar,n"); assertThat(foo.getAge()).isEqualTo(0); assertThat(foo.isMarried()).isFalse(); }