### Question:
IncrementalRelativeFileSets { @NonNull public static ImmutableMap<RelativeFile, FileStatus> fromDirectory(@NonNull File directory) { Preconditions.checkArgument(directory.isDirectory(), "!directory.isDirectory()"); return ImmutableMap.copyOf( Maps.asMap( RelativeFiles.fromDirectory(directory), Functions.constant(FileStatus.NEW))); } private  IncrementalRelativeFileSets(); @NonNull static ImmutableMap<RelativeFile, FileStatus> fromDirectory(@NonNull File directory); @NonNull static ImmutableMap<RelativeFile, FileStatus> fromZip(@NonNull File zip); @NonNull static ImmutableMap<RelativeFile, FileStatus> fromZip(
            @NonNull File zip,
            FileStatus status); @NonNull static ImmutableMap<RelativeFile, FileStatus> fromZip(
            @NonNull File zip,
            @NonNull FileCacheByPath cache,
            @NonNull Set<Runnable> cacheUpdates); @NonNull static ImmutableMap<RelativeFile, FileStatus> union(
            @NonNull Iterable<ImmutableMap<RelativeFile, FileStatus>> sets); static int getBaseDirectoryCount(@NonNull ImmutableMap<RelativeFile, FileStatus> set); @NonNull static ImmutableMap<RelativeFile, FileStatus> fromZipsAndDirectories(
            @NonNull Iterable<File> files); @NonNull static ImmutableMap<RelativeFile, FileStatus> makeFromBaseFiles(
            @NonNull Collection<File> baseFiles,
            @NonNull Map<File, FileStatus> updates,
            @NonNull FileCacheByPath cache,
            @NonNull Set<Runnable> cacheUpdates,
            @NonNull FileDeletionPolicy fileDeletionPolicy);  }### Answer:
@Test public void readEmptyDirectory() { ImmutableMap<RelativeFile, FileStatus> set = IncrementalRelativeFileSets.fromDirectory(temporaryFolder.getRoot()); assertEquals(0, set.size()); }
@Test public void readDirectory() throws Exception { File a = temporaryFolder.newFolder("a"); File ab = new File(a, "ab"); @SuppressWarnings("unused") boolean ignored1 = ab.createNewFile(); File ac = new File(a, "ac"); @SuppressWarnings("unused") boolean ignored2 = ac.createNewFile(); File d = temporaryFolder.newFile("d"); RelativeFile expectedB = new RelativeFile(temporaryFolder.getRoot(), ab); RelativeFile expectedC = new RelativeFile(temporaryFolder.getRoot(), ac); RelativeFile expectedD = new RelativeFile(temporaryFolder.getRoot(), d); ImmutableMap<RelativeFile, FileStatus> set = IncrementalRelativeFileSets.fromDirectory(temporaryFolder.getRoot()); assertEquals(3, set.size()); assertTrue(set.containsKey(expectedB)); assertTrue(set.containsKey(expectedC)); assertTrue(set.containsKey(expectedD)); assertEquals(FileStatus.NEW, set.get(expectedB)); assertEquals(FileStatus.NEW, set.get(expectedC)); assertEquals(FileStatus.NEW, set.get(expectedD)); }
@Test public void makeFromDirectoryIgnoresDirectories() throws Exception { File foo = temporaryFolder.newFolder("foo"); File f0 = new File(foo, "f0"); assertTrue(f0.createNewFile()); File bar = new File(foo, "bar"); assertTrue(bar.mkdir()); File f1 = new File(bar, "f1"); assertTrue(f1.createNewFile()); RelativeFile expectedF0 = new RelativeFile(temporaryFolder.getRoot(), f0); RelativeFile expectedF1 = new RelativeFile(temporaryFolder.getRoot(), f1); ImmutableMap<RelativeFile, FileStatus> set = IncrementalRelativeFileSets.fromDirectory(temporaryFolder.getRoot()); assertEquals(2, set.size()); assertTrue(set.containsKey(expectedF0)); assertTrue(set.containsKey(expectedF1)); assertEquals(FileStatus.NEW, set.get(expectedF0)); assertEquals(FileStatus.NEW, set.get(expectedF1)); }