WidgetFileHelper { public static void deleteConcatenateFile(Path folder){ try (Stream<Path> files = Files.list(folder)) { files.filter(p -> p.getFileName().toString().startsWith(FILENAME_PREFIX) && !Files.isDirectory(p)) .forEach(p ->deleteFile(p)); } catch (IOException e) { String error = String.format("Error while filter file in folder " + folder.toString()); logger.error(error, e); throw new GenerationException(error, e); } }  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_delete_files_if_exists() throws Exception { File assetsFolder = temporaryFolder.newFolder("maPage", "js"); File expectFileDeleted = temporaryFolder.newFile("maPage/js/widgets-4576.min.js"); WidgetFileHelper.deleteConcatenateFile(assetsFolder.toPath()); assertThat(expectFileDeleted).doesNotExist(); }