### Question:
Directories { @Nonnull public static List<Path> list(@Nonnull final Path dir) throws IOException { final List<Path> contents = new ArrayList<>(); try (final DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (final Path entry : stream) { contents.add(entry); } } catch (DirectoryIteratorException ex) { throw ex.getCause(); } return contents; } private  Directories(); @Nonnegative static int count(@Nonnull final Path dir); @Nonnull static List<Path> list(@Nonnull final Path dir);  }### Answer:
@Test public void list() throws IOException { List<Path> found; found = Directories.list(root); Assert.assertEquals(0, found.size()); tempDir.newFile("foo1"); found = Directories.list(root); Assert.assertEquals(1, found.size()); Assert.assertEquals(root.resolve("foo1"), found.get(0)); final File dir = tempDir.newFolder("dir"); found = Directories.list(root); Assert.assertEquals(2, found.size()); Collections.sort(found); Assert.assertEquals(root.resolve("dir"), found.get(0)); Assert.assertEquals(root.resolve("foo1"), found.get(1)); Assert.assertTrue(new File(dir, "foo2").createNewFile()); found = Directories.list(root); Assert.assertEquals(2, found.size()); Collections.sort(found); Assert.assertEquals(root.resolve("dir"), found.get(0)); Assert.assertEquals(root.resolve("foo1"), found.get(1)); }