### Question:
TemplateProcessor { public Writer createFileWriter(String fileToWrite) { try { Files.deleteIfExists(Paths.get(fileToWrite)); return new FileWriter(new File(fileToWrite), true); } catch (IOException e) { throw new UncheckedIOException(e); } }  void processDataModel(Map<String, Object> dataModel, Template fileTemplate, Writer fileWriter); Template getFileTemplate(String templateFile); Writer createFileWriter(String fileToWrite);  }### Answer:
@Test public void canCreateFileWriterForNewFile() { Path path = Paths.get(testFolder.getRoot().toString(), TEST_GENERATED_FILE); assertFalse(Files.exists(path)); TemplateProcessor.createFileWriter(path.toAbsolutePath().toString()); assertTrue(Files.exists(path)); }
@Test public void canCreateFileWriterForExistingFile() throws IOException { Path path = Paths.get(testFolder.getRoot().toString(), TEST_GENERATED_FILE); testFolder.newFile(TEST_GENERATED_FILE); assertTrue(Files.exists(path)); TemplateProcessor.createFileWriter(path.toAbsolutePath().toString()); assertTrue(Files.exists(path)); }