CsvFormatter extends AbstractFormatter { @Override public void write(final Datenpaket datenpaket) throws IOException { buildHead(datenpaket); this.writeHead(); this.writeBody(datenpaket); } CsvFormatter();  CsvFormatter(Writer writer);  CsvFormatter(OutputStream ostream); @Override void write(final Datenpaket datenpaket); @Override void write(Satz satz);  }
@Test public void testWriteDatenpaket() throws IOException { File output = new File("target", "musterdatei.csv"); try (Writer writer = new OutputStreamWriter(new FileOutputStream(output), StandardCharsets.ISO_8859_1)) { CsvFormatter formatter = new CsvFormatter(writer); formatter.write(MUSTER_DATENPAKET); } List<String> lines = FileUtils.readLines(output, StandardCharsets.ISO_8859_1); for (int i = 0; i < MUSTER_DATENPAKET.getDatensaetze().size(); i++) { Datensatz datensatz = MUSTER_DATENPAKET.getDatensaetze().get(i); String[] columns = lines.get(i+2).split(";"); assertEquals("line " + (i+2), datensatz.getSatzart(), Integer.parseInt(columns[0])); } }