@Test public void writeReleaseListToCSVFileTest() throws IOException { List<Artifact> artifacts = new ArrayList<>(); artifacts.add(mkArtifact("test", false)); artifacts.add(mkArtifact("test1", false) .addCoordinate(new Coordinate("pkg:maven/test/test1@1.2.3")) .addCoordinate(new Coordinate("pkg:p2/test/test1@1.2.3"))); CSVArtifactMapper csvArtifactMapper = new CSVArtifactMapper(csvFile.toPath(), StandardCharsets.UTF_8, DELIMITER, csvFile.getParentFile().toPath()); csvArtifactMapper.writeArtifactsToCsvFile(artifacts); assertThat(csvFile.exists()).isTrue(); List<CSVRecord> records = parseCsvFile(); assertThat(records.size()).isEqualTo(3); }
public Path writeArtifactsToCsvFile(Collection<Artifact> artifacts) { try (BufferedWriter writer = Files.newBufferedWriter(csvFile); CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader(COLUMN_NAMES)) ) { for (Artifact artifact : artifacts) { csvPrinter.printRecords(makeCsvRecordsFromArtifact(artifact)); } csvPrinter.flush(); return csvFile.toAbsolutePath(); } catch (IOException e) { LOGGER.error("Error when writing the csv file", e); return null; } }
CSVArtifactMapper { public Path writeArtifactsToCsvFile(Collection<Artifact> artifacts) { try (BufferedWriter writer = Files.newBufferedWriter(csvFile); CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader(COLUMN_NAMES)) ) { for (Artifact artifact : artifacts) { csvPrinter.printRecords(makeCsvRecordsFromArtifact(artifact)); } csvPrinter.flush(); return csvFile.toAbsolutePath(); } catch (IOException e) { LOGGER.error("Error when writing the csv file", e); return null; } } }
CSVArtifactMapper { public Path writeArtifactsToCsvFile(Collection<Artifact> artifacts) { try (BufferedWriter writer = Files.newBufferedWriter(csvFile); CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader(COLUMN_NAMES)) ) { for (Artifact artifact : artifacts) { csvPrinter.printRecords(makeCsvRecordsFromArtifact(artifact)); } csvPrinter.flush(); return csvFile.toAbsolutePath(); } catch (IOException e) { LOGGER.error("Error when writing the csv file", e); return null; } } CSVArtifactMapper(Path csvFile, Charset encoding, char delimiter, Path baseDir); }
CSVArtifactMapper { public Path writeArtifactsToCsvFile(Collection<Artifact> artifacts) { try (BufferedWriter writer = Files.newBufferedWriter(csvFile); CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader(COLUMN_NAMES)) ) { for (Artifact artifact : artifacts) { csvPrinter.printRecords(makeCsvRecordsFromArtifact(artifact)); } csvPrinter.flush(); return csvFile.toAbsolutePath(); } catch (IOException e) { LOGGER.error("Error when writing the csv file", e); return null; } } CSVArtifactMapper(Path csvFile, Charset encoding, char delimiter, Path baseDir); Path writeArtifactsToCsvFile(Collection<Artifact> artifacts); Collection<Artifact> createArtifactsList(); }
CSVArtifactMapper { public Path writeArtifactsToCsvFile(Collection<Artifact> artifacts) { try (BufferedWriter writer = Files.newBufferedWriter(csvFile); CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader(COLUMN_NAMES)) ) { for (Artifact artifact : artifacts) { csvPrinter.printRecords(makeCsvRecordsFromArtifact(artifact)); } csvPrinter.flush(); return csvFile.toAbsolutePath(); } catch (IOException e) { LOGGER.error("Error when writing the csv file", e); return null; } } CSVArtifactMapper(Path csvFile, Charset encoding, char delimiter, Path baseDir); Path writeArtifactsToCsvFile(Collection<Artifact> artifacts); Collection<Artifact> createArtifactsList();  }