### Question:
RealSourceFiles implements Reality<String, SourceFile> { @Override public Collection<String> getIds() { List<String> result = new ArrayList<>(); addPaths(new File(baseDir, generatedSourceDir + codeDir), result); addPaths(new File(baseDir, mainSourceSetDir + codeDir), result); Collections.sort(result); return result; } RealSourceFiles(File baseDir, String generatedSourceDir, String manualSourceDir,
      String codeDir, SourceCodeManagementSystem scm); @Override Collection<String> getIds(); @Override SourceFile get(String id); @Override void add(String path, SourceFile sourceFile); @Override void remove(String path); @Override void update(String path, SourceFile oldSourceFile, SourceFile newSourceFile);  }### Answer:
@Test public void returnsNoIdsForMissingDirectory() { IO.delete(baseDir); Collection<String> actual = reality.getIds(); assertTrue("Extra IDs: " + actual, actual.isEmpty()); }
@Test public void returnsCanonicalPathsOfExistingFilesAsIds() throws IOException { File file1 = ensureRandomFile(mainSourceSetDir, codeDir, "a"); File file2 = ensureRandomFile(generatedSourceSetDir, codeDir, "z"); List<String> expected = Arrays.asList(file2.getCanonicalPath(), file1.getCanonicalPath()); Collection<String> actual = reality.getIds(); TestUtil.assertCollectionEquals("IDs", expected, actual); }
@Test public void skipsFilesOutsideSourceSets() throws IOException { ensureRandomFile(RANDOM.string(), codeDir, RANDOM.string()); Collection<String> actual = reality.getIds(); assertTrue("Extra IDs: " + actual, actual.isEmpty()); }
@Test public void skipsFilesOutsidePackage() throws IOException { ensureRandomFile(mainSourceSetDir, RANDOM.string(), RANDOM.string()); Collection<String> actual = reality.getIds(); assertTrue("Extra IDs: " + actual, actual.isEmpty()); }