@Test public void example1_can_not_be_read_with_4_columns() throws Exception { expected.expect(IllegalStateException.class); File file = DeveloperToolsTestFileSupport.getTestfileSupport().createFileFromResourcePath("csv/example1-developer-admin-ui_mass-import_projects.csv"); importerToTest.importCSVFile(file, 2, 1); }
public List<CSVRow> importCSVFile(File file, int expectedColumnCount, int headlines) throws IOException { List<CSVRow> list = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(file));) { String line = null; int lineNr=0; while ((line = br.readLine()) != null) { lineNr++; CSVRow row = CSVRow.importRow(line); int columnCount = row.columns.size(); if (columnCount!=expectedColumnCount) { throw new IllegalStateException("Expected "+expectedColumnCount+" but got "+columnCount+" in line:"+lineNr); } if (lineNr>headlines) { list.add(row); } } } return list; }
SimpleCSVImporter { public List<CSVRow> importCSVFile(File file, int expectedColumnCount, int headlines) throws IOException { List<CSVRow> list = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(file));) { String line = null; int lineNr=0; while ((line = br.readLine()) != null) { lineNr++; CSVRow row = CSVRow.importRow(line); int columnCount = row.columns.size(); if (columnCount!=expectedColumnCount) { throw new IllegalStateException("Expected "+expectedColumnCount+" but got "+columnCount+" in line:"+lineNr); } if (lineNr>headlines) { list.add(row); } } } return list; } }
SimpleCSVImporter { public List<CSVRow> importCSVFile(File file, int expectedColumnCount, int headlines) throws IOException { List<CSVRow> list = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(file));) { String line = null; int lineNr=0; while ((line = br.readLine()) != null) { lineNr++; CSVRow row = CSVRow.importRow(line); int columnCount = row.columns.size(); if (columnCount!=expectedColumnCount) { throw new IllegalStateException("Expected "+expectedColumnCount+" but got "+columnCount+" in line:"+lineNr); } if (lineNr>headlines) { list.add(row); } } } return list; }  }
SimpleCSVImporter { public List<CSVRow> importCSVFile(File file, int expectedColumnCount, int headlines) throws IOException { List<CSVRow> list = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(file));) { String line = null; int lineNr=0; while ((line = br.readLine()) != null) { lineNr++; CSVRow row = CSVRow.importRow(line); int columnCount = row.columns.size(); if (columnCount!=expectedColumnCount) { throw new IllegalStateException("Expected "+expectedColumnCount+" but got "+columnCount+" in line:"+lineNr); } if (lineNr>headlines) { list.add(row); } } } return list; }  List<CSVRow> importCSVFile(File file, int expectedColumnCount, int headlines); }
SimpleCSVImporter { public List<CSVRow> importCSVFile(File file, int expectedColumnCount, int headlines) throws IOException { List<CSVRow> list = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(file));) { String line = null; int lineNr=0; while ((line = br.readLine()) != null) { lineNr++; CSVRow row = CSVRow.importRow(line); int columnCount = row.columns.size(); if (columnCount!=expectedColumnCount) { throw new IllegalStateException("Expected "+expectedColumnCount+" but got "+columnCount+" in line:"+lineNr); } if (lineNr>headlines) { list.add(row); } } } return list; }  List<CSVRow> importCSVFile(File file, int expectedColumnCount, int headlines);  }