### Question:
UtilFolder { public static List<File> getDirectories(File path) { Check.notNull(path); return Optional.ofNullable(path.listFiles()) .map(files -> Arrays.asList(files) .stream() .filter(File::isDirectory) .collect(Collectors.toList())) .orElseGet(Collections::emptyList); } 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 testGetDirectories() throws IOException { final Path dir = Files.createTempDirectory("temp"); final Path file = Files.createTempFile(dir, "temp", ".tmp"); final List<File> expected = new ArrayList<>(); for (int i = 0; i < 5; i++) { expected.add(Files.createTempDirectory(dir, "temp").toFile()); } Collections.sort(expected); final List<File> found = UtilFolder.getDirectories(dir.toFile()); Collections.sort(found); assertEquals(expected, found); Files.delete(file); for (final File current : expected) { assertTrue(current.delete()); } Files.delete(dir); }
@Test void testGetDirectoriesError() { assertTrue(UtilFolder.getDirectories(new File("null")).isEmpty()); }