@Test void multipleTest() throws IOException { Output output1 = new Output("multiple1.md", "# First multiple test\n\nIf you can read this, the test was probably successful.\n"); Output output2 = new Output("multiple2", "You may delete these files (but not before the test finishes ;) )"); FileConsumer fileConsumer = new FileConsumer(tempDir); fileConsumer.consumeOutput(Arrays.asList(output1, output2)); Path expectedFilePath1 = Paths.get(tempDir.toString(), output1.getName()); assertThat(expectedFilePath1.toFile().exists()).isTrue(); String file1Content = new String(Files.readAllBytes(expectedFilePath1), StandardCharsets.UTF_8); assertThat(file1Content).isEqualTo(output1.getData()); Path expectedFilePath2 = Paths.get(tempDir.toString(), output2.getName()); assertThat(expectedFilePath2.toFile().exists()).isTrue(); String file2Content = new String(Files.readAllBytes(expectedFilePath2), StandardCharsets.UTF_8); assertThat(file2Content).isEqualTo(output2.getData()); }
@Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } } }
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } } FileConsumer(Path directory);  FileConsumer(@NonNull Path directory, FileOutputStreamProvider fileOutputStreamProvider); }
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } } FileConsumer(Path directory);  FileConsumer(@NonNull Path directory, FileOutputStreamProvider fileOutputStreamProvider); @Override void consumeOutput(List<Output> outputs); }
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.createStream(outfile); OutputStreamWriter writer = new OutputStreamWriter(outStream, StandardCharsets.UTF_8); writer.write(output.getData()); writer.close(); } } catch (IOException e) { throw new RuntimeException(e); } } FileConsumer(Path directory);  FileConsumer(@NonNull Path directory, FileOutputStreamProvider fileOutputStreamProvider); @Override void consumeOutput(List<Output> outputs);  }