FileWriterServices { public Writer getFileObjectWriter(String path, String filename) throws IOException { File dir = new File(path); if (!dir.exists()) { dir.mkdirs(); } return new FileWriter(new File(dir, filename)); } FileWriterServices(Messager messager, Filer filer); void copyResourceToClassesOutput(String path, String filename); void copyResourceToDir(String path, String filename, String dir); Writer getFileObjectWriterInClassOutput(String pkg, String name); Writer getFileObjectWriter(String path, String filename);  }
@Test public void testGetFileObjectWriter() throws Exception { System.out.println("getFileObjectWriter"); String path = "/tmp/ocelot"; String filename = "test.js"; File file = new File(path, filename); if(file.exists()) { file.delete(); } assertThat(file).doesNotExist(); Messager messager = mock(Messager.class); Filer filer = mock(Filer.class); FileWriterServices instance = spy(new FileWriterServices(messager, filer)); Writer result = instance.getFileObjectWriter(path, filename); assertThat(result).isNotNull(); assertThat(file).exists(); file.delete(); file = new File(path); if(file.exists()) { file.delete(); } }