This test fails with: expected: <java.lang.Integer> but was: <java.lang.String>
@Test
public void testSetTypeOfColumns() throws IOException {
String data = "ID,NAME" + System.lineSeparator() + "2,Chris";
InputStream csvStream = new ByteArrayInputStream(data.getBytes());
CsvParser parser = new CsvParser(new CsvParserSettings() {
{
setHeaderExtractionEnabled(true);
}
});
parser.beginParsing(csvStream);
parser.getRecordMetadata().setTypeOfColumns(Integer.class, "ID");
parser.getRecordMetadata().setTypeOfColumns(String.class, "NAME");
Record record = parser.parseNextRecord();
Map<String, Object> map = record.toFieldObjectMap();
assertEquals(Integer.class, map.get("ID").getClass());
}
Is there something wrong in my code is this a bug?
http://docs.univocity.com/parsers/2.7.2/index.html?com/univocity/parsers/common/record/Record.html
Have a look at their tutorial how to map to a simple POJO.
https://www.univocity.com/pages/univocity_parsers_tutorial#using-annotations-to-map-your-java-beans