ClustersFilter implements PathFilter { @Override public boolean accept(Path path) { String pathString = path.toString(); return pathString.contains("/clusters-") && pathString.endsWith(Cluster.FINAL_ITERATION_SUFFIX); }  @Override boolean accept(Path path);  }
@Test public void testAccept_notFinal() throws Exception { Path path0 = new Path(output, "clusters-0"); Path path1 = new Path(output, "clusters-1"); path0.getFileSystem(configuration).createNewFile(path0); path1.getFileSystem(configuration).createNewFile(path1); PathFilter clustersFilter = new ClustersFilter(); assertFalse(clustersFilter.accept(path0)); assertFalse(clustersFilter.accept(path1)); }
@Test public void testAccept_finalPath() throws IOException { Path path0 = new Path(output, "clusters-0"); Path path1 = new Path(output, "clusters-1"); Path path2 = new Path(output, "clusters-2"); Path path3Final = new Path(output, "clusters-3-final"); path0.getFileSystem(configuration).createNewFile(path0); path1.getFileSystem(configuration).createNewFile(path1); path2.getFileSystem(configuration).createNewFile(path2); path3Final.getFileSystem(configuration).createNewFile(path3Final); PathFilter clustersFilter = new ClustersFilter(); assertFalse(clustersFilter.accept(path0)); assertFalse(clustersFilter.accept(path1)); assertFalse(clustersFilter.accept(path2)); assertTrue(clustersFilter.accept(path3Final)); }