### Question:
UtilFolder { public static void deleteDirectory(File element) { Check.notNull(element); if (element.isDirectory()) { Optional.ofNullable(element.listFiles()) .map(Arrays::asList) .ifPresent(files -> files.forEach(UtilFolder::deleteDirectory)); try { Files.delete(element.toPath()); } catch (final IOException exception) { Verbose.exception(exception, ERROR_DELETE_DIRECTORY, element.getAbsolutePath()); } } else if (element.isFile()) { try { Files.delete(element.toPath()); } catch (final IOException exception) { Verbose.exception(exception, ERROR_DELETE_FILE, element.getAbsolutePath()); } } } private  UtilFolder(); static List<File> getDirectories(File path); static String getPath(String... path); static String getPathSeparator(String separator, String... path); static void deleteDirectory(File element); static boolean isDirectory(String path);  }### Answer:
@Test void testDeleteDirectory() throws IOException { final Path directory = Files.createTempDirectory("temp"); final Path file = Files.createTempFile(directory, "temp", ".tmp"); final Path dir1 = Files.createTempFile(directory, "temp", ".tmp"); assertTrue(Files.exists(directory)); assertTrue(Files.exists(file)); assertTrue(Files.exists(dir1)); UtilFolder.deleteDirectory(directory.toFile()); assertTrue(Files.notExists(directory)); assertTrue(Files.notExists(file)); assertTrue(Files.notExists(dir1)); }
@Test void testDeleteDirectoryWarning() throws IOException { Verbose.info("*********************************** EXPECTED VERBOSE ***********************************"); UtilFolder.deleteDirectory(new File("void")); UtilFolder.deleteDirectory(new File("warn") { @Override public boolean isDirectory() { return true; } @Override public boolean delete() { return false; } @Override public File[] listFiles() { return new File[] { new File("warn") { @Override public boolean isFile() { return true; } @Override public boolean delete() { return false; } } }; } }); UtilFolder.deleteDirectory(new File("null") { @Override public boolean isDirectory() { return true; } @Override public boolean delete() { return false; } @Override public File[] listFiles() { return null; } }); Verbose.info("****************************************************************************************"); }