WidgetFileHelper { public static Path writeFile(byte[] content, Path folderPath, String suffix) { Path path = folderPath.resolve(FILENAME_PREFIX + suffix + ".js"); if (!Files.exists(path)) { writeFile(content, path); } return path; }  static Path writeFile(byte[] content, Path folderPath, String suffix); static void deleteOldConcatenateFiles(Path path, String suffix); static void deleteConcatenateFile(Path folder);  }
@Test public void should_write_content_at_path() throws Exception { byte[] content = "Mon content".getBytes(); Path path = WidgetFileHelper.writeFile(content,temporaryFolder.toPath(),"f8a4574"); assertThat(path.toFile()).exists(); assertThat(path.getFileName().toString()).isEqualTo("widgets-f8a4574.js"); }
@Test(expected = GenerationException.class) public void should_throw_generation_exception_if_not_exist_folder_path_when_write_a_file() throws Exception { Path unexistingFile = temporaryFolder.toPath().resolve("FileNotFound"); WidgetFileHelper.writeFile("Mon content".getBytes(), unexistingFile, "notUsedForThisTest"); }