### Question:
CsvLoader implements Loader { @Override public void loadData(List<Tuple<String, File>> files, Importer importer) throws InvalidFileException, IOException { for (Tuple<String, File> file : files) { CSVParser parser = format.parse(new FileReader(file.getRight())); String filename = file.getLeft(); if (filename.endsWith(".csv") || filename.endsWith(".tsv") || filename.endsWith(".txt")) { filename = filename.substring(0, filename.length() - 4); } importer.startCollection(filename); parser.getHeaderMap().forEach((name, column) -> importer.registerPropertyName(column, name)); parser.forEach(row -> { importer.startEntity(); for (int i = 0; i < row.size(); i++) { importer.setValue(i, row.get(i)); } importer.finishEntity(); }); importer.finishCollection(); } } @JsonCreator  CsvLoader(@JsonProperty("config") Map<String, String> config); @Override void loadData(List<Tuple<String, File>> files, Importer importer);  }### Answer:
@Test public void importCsv() throws Exception { File csvFile = new File(CsvLoaderTest.class.getResource("test.csv").toURI()); CsvLoader loader = new CsvLoader(new HashMap<>()); try { List<String> results = new ArrayList<>(); AtomicBoolean failure = new AtomicBoolean(false); loader.loadData(newArrayList(tuple("testcollection.csv", csvFile)), ImporterStubs.withCustomReporter(logline -> { if (logline.matches("failure.*")) { failure.set(true); } results.add(logline); })); if (failure.get()) { throw new RuntimeException("Failure during import: \n" + String.join("\n", results)); } } catch (InvalidFileException e) { throw new RuntimeException(e); } }