### Question:
CompositePathIterable implements Iterable<T> { public static <S> Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory) throws IOException { if (!fs.exists(path)){ throw new IOException("No files found to materialize at: " + path); } FileStatus[] stati = null; try { stati = fs.listStatus(path, FILTER); } catch (FileNotFoundException e) { stati = null; } if (stati == null) { throw new IOException("No files found to materialize at: " + path); } if (stati.length == 0) { return Collections.emptyList(); } else { return new CompositePathIterable<S>(stati, fs, readerFactory); } } private  CompositePathIterable(FileStatus[] stati, FileSystem fs, FileReaderFactory<T> readerFactory); static Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory); @Override Iterator<T> iterator();  }### Answer:
@Test public void testCreate_FilePresent() throws IOException{ String inputFilePath = FileHelper.createTempCopyOf("set1.txt"); Configuration conf = new Configuration(); LocalFileSystem local = FileSystem.getLocal(conf); Iterable<String> iterable = CompositePathIterable.create(local, new Path(inputFilePath), new TextFileReaderFactory<String>(Writables.strings(), conf)); assertEquals(Lists.newArrayList("b", "c", "a", "e"), Lists.newArrayList(iterable)); }
@Test public void testCreate_DirectoryPresentButNoFiles() throws IOException{ String inputFilePath = Files.createTempDir().getAbsolutePath(); Configuration conf = new Configuration(); LocalFileSystem local = FileSystem.getLocal(conf); Iterable<String> iterable = CompositePathIterable.create(local, new Path(inputFilePath), new TextFileReaderFactory<String>(Writables.strings(), conf)); assertTrue(Lists.newArrayList(iterable).isEmpty()); }
@Test(expected=IOException.class) public void testCreate_DirectoryNotPresent() throws IOException{ File inputFileDir = Files.createTempDir(); inputFileDir.delete(); assertFalse(inputFileDir.exists()); Configuration conf = new Configuration(); LocalFileSystem local = FileSystem.getLocal(conf); CompositePathIterable.create(local, new Path(inputFileDir.getAbsolutePath()), new TextFileReaderFactory<String>(Writables.strings(), conf)); }