use of com.synopsys.integration.common.util.finder.SimpleFileFinder in project synopsys-detect by blackducksoftware.
the class SimpleFileFinderTest method testFindWithPredicate.
@Test
public void testFindWithPredicate() throws IOException {
File initialDirectory = initialDirectoryPath.toFile();
File subDir1 = new File(initialDirectory, "sub1");
subDir1.mkdirs();
File subDirChild1 = new File(subDir1, "child");
subDirChild1.createNewFile();
File subDir2 = new File(initialDirectory, "sub2");
subDir2.mkdirs();
File subDirChild2 = new File(subDir2, "child");
subDirChild2.createNewFile();
SimpleFileFinder fileFinder = new SimpleFileFinder();
Predicate<File> filter = file -> file.getName().startsWith("sub");
List<File> foundFiles = fileFinder.findFiles(initialDirectoryPath.toFile(), filter, false, 10);
assertEquals(2, foundFiles.size());
assertFalse(foundFiles.contains(subDirChild2));
}
Aggregations