columnDescriptions.add(new ColumnDescription("i2", ValueType.TEXT, null));
columnDescriptions.add(new ColumnDescription("i3", ValueType.DATE, null));
dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, false);
assertEquals(3, dataTable.getNumberOfRows());
assertEquals(3, dataTable.getNumberOfColumns());
assertEquals(new NumberValue(1), dataTable.getRow(0).getCell(0).getValue());
assertEquals(new TextValue("a"), dataTable.getRow(0).getCell(1).getValue());
assertEquals(DateValue.getNullValue(), dataTable.getRow(0).getCell(2).getValue());
assertEquals(new NumberValue(4), dataTable.getRow(1).getCell(0).getValue());
assertEquals(new TextValue("x13a"), dataTable.getRow(1).getCell(1).getValue());
assertEquals(DateValue.getNullValue(), dataTable.getRow(1).getCell(2).getValue());
assertEquals(new NumberValue(1400), dataTable.getRow(2).getCell(0).getValue());
assertEquals(new TextValue("4"), dataTable.getRow(2).getCell(1).getValue());
assertEquals(DateValue.getNullValue(), dataTable.getRow(2).getCell(2).getValue());
// Working example with a table description filled only with types.
reader = new StringReader("1,a,2004-03-01\n4,x13a,2005-04-02\n1400,4,2006-05-03");
columnDescriptions = Lists.newArrayList();
columnDescriptions.add(new ColumnDescription("i1", ValueType.NUMBER, null));
columnDescriptions.add(new ColumnDescription("i2", ValueType.TEXT, null));
columnDescriptions.add(new ColumnDescription("i3", ValueType.DATE, null));
dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, false);
assertEquals(3, dataTable.getNumberOfRows());
assertEquals(3, dataTable.getNumberOfColumns());
assertEquals(new NumberValue(1), dataTable.getRow(0).getCell(0).getValue());
assertEquals(new TextValue("a"), dataTable.getRow(0).getCell(1).getValue());
assertEquals(new DateValue(2004, 2, 1), dataTable.getRow(0).getCell(2).getValue());
assertEquals(new NumberValue(4), dataTable.getRow(1).getCell(0).getValue());
assertEquals(new TextValue("x13a"), dataTable.getRow(1).getCell(1).getValue());
assertEquals(new DateValue(2005, 3, 2), dataTable.getRow(1).getCell(2).getValue());
assertEquals(new NumberValue(1400), dataTable.getRow(2).getCell(0).getValue());
assertEquals(new TextValue("4"), dataTable.getRow(2).getCell(1).getValue());
assertEquals(new DateValue(2006, 4, 3), dataTable.getRow(2).getCell(2).getValue());
assertEquals("i1", dataTable.getColumnDescription(0).getId());
assertEquals("Column0", dataTable.getColumnDescription(0).getLabel());
assertEquals("i2", dataTable.getColumnDescription(1).getId());
assertEquals("Column1", dataTable.getColumnDescription(1).getLabel());
assertEquals("i3", dataTable.getColumnDescription(2).getId());
assertEquals("Column2", dataTable.getColumnDescription(2).getLabel());
// Working example with header rows.
reader = new StringReader("1,a,2004-03-01\n4,x13a,2005-04-02\n1400,4,2006-05-03");
columnDescriptions = Lists.newArrayList();
columnDescriptions.add(new ColumnDescription("i1", ValueType.NUMBER, null));
columnDescriptions.add(new ColumnDescription("i2", ValueType.TEXT, null));
columnDescriptions.add(new ColumnDescription("i3", ValueType.DATE, null));
dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, true);
assertEquals(2, dataTable.getNumberOfRows());
assertEquals(3, dataTable.getNumberOfColumns());
assertEquals(new NumberValue(4), dataTable.getRow(0).getCell(0).getValue());
assertEquals(new TextValue("x13a"), dataTable.getRow(0).getCell(1).getValue());
assertEquals(new DateValue(2005, 3, 2), dataTable.getRow(0).getCell(2).getValue());
assertEquals(new NumberValue(1400), dataTable.getRow(1).getCell(0).getValue());
assertEquals(new TextValue("4"), dataTable.getRow(1).getCell(1).getValue());
assertEquals(new DateValue(2006, 4, 3), dataTable.getRow(1).getCell(2).getValue());
assertEquals("i1", dataTable.getColumnDescription(0).getId());
assertEquals("1", dataTable.getColumnDescription(0).getLabel());
assertEquals("i2", dataTable.getColumnDescription(1).getId());