### Question:
ChainedFileSource implements FileSource { public File getFile(String path) { File file; for (DescendantFileSource curLocator : chain) { file = curLocator.getFile(path); if (file != null) return file; } return null; } ChainedFileSource(List<DescendantFileSource> chain); File getFile(String path); @Override String toString();  }### Answer:
@Test public void testNewGivenNonexistentDirectory() { List<DescendantFileSource> chain = new ArrayList<DescendantFileSource>(); DescendantFileSource contentSource = new BasicDescendantFileSource(contentDir); DescendantFileSource publicSource = new BasicDescendantFileSource(publicDir); DescendantFileSource contentMinusPublicSource = new BasicWithExclusionsDescendantFileSource(contentDir, Collections.singletonList("public")); DescendantFileSource iddSource = new BasicDescendantFileSource(iddDir); DescendantFileSource mlodeSource = new BasicDescendantFileSource(mlodeDir); chain.add(contentMinusPublicSource); chain.add(iddSource); chain.add(mlodeSource); ChainedFileSource configChain = new ChainedFileSource(chain); assertNotNull(configChain); File myCat = configChain.getFile("myCat.xml"); assertNotNull(myCat); assertTrue(contentSource.isDescendant(myCat)); assertFalse(publicSource.isDescendant(myCat)); assertFalse(iddSource.isDescendant(myCat)); assertFalse(mlodeSource.isDescendant(myCat)); File myDirCat = configChain.getFile("myDir/myCat.xml"); assertNotNull(myDirCat); assertTrue(contentSource.isDescendant(myDirCat)); assertFalse(publicSource.isDescendant(myDirCat)); assertFalse(iddSource.isDescendant(myDirCat)); assertFalse(mlodeSource.isDescendant(myDirCat)); File myPublicCat = configChain.getFile("myPublicCat.xml"); assertNull(myPublicCat); File iddCat = configChain.getFile("iddCat.xml"); assertNotNull(iddCat); assertFalse(contentSource.isDescendant(iddCat)); assertFalse(publicSource.isDescendant(iddCat)); assertTrue(iddSource.isDescendant(iddCat)); assertFalse(mlodeSource.isDescendant(iddCat)); File mlodeCat = configChain.getFile("mlodeCat.xml"); assertNotNull(mlodeCat); assertFalse(contentSource.isDescendant(mlodeCat)); assertFalse(publicSource.isDescendant(mlodeCat)); assertFalse(iddSource.isDescendant(mlodeCat)); assertTrue(mlodeSource.isDescendant(mlodeCat)); }