### Question:
GlobFileFinder { public List<Path> find(String pattern) { result = new ArrayList<Path>(); ioCount = 0; Path patternPath = FileSystems.getDefault().getPath(pattern); List<Path> plist = new ArrayList<Path>(); patternPath.forEach(plist::add); ListIterator<Path> pitr = plist.listIterator(); if (pitr.hasNext()) { Path current = patternPath.isAbsolute() ? patternPath.getRoot() : FileSystems.getDefault().getPath(""); findMatchingFiles(current, pitr); } return result; }  List<Path> find(String pattern); void setIoLimit(int ioLimit);  }### Answer:
@Test public void testEmpty() throws Exception { GlobFileFinder gff = new GlobFileFinder(); List<Path> l1 = gff.find(tempDir.resolve("*.txt").toString()); assertEquals(0, l1.size()); List<Path> l2 = gff.find(tempDir.resolve("..").toString()); assertEquals(0, l2.size()); }
@Test public void testAbsolute() throws Exception { GlobFileFinder gff = new GlobFileFinder(); List<Path> l1 = gff.find(tempDir.resolve("*").toString()); assertEquals(3, l1.size()); assertTrue(find(p_aa, l1)); assertTrue(find(p_a, l1)); assertTrue(find(p_b, l1)); List<Path> l2 = gff.find(tempDir.resolve("a*").toString()); assertEquals(2, l2.size()); assertTrue(find(p_aa, l2)); assertTrue(find(p_a, l2)); assertFalse(find(p_b, l2)); List<Path> l3 = gff.find(tempDir.resolve("c/*b*").toString()); assertEquals(3, l3.size()); assertTrue(find(p_c_abc, l3)); assertTrue(find(p_c_bbb, l3)); assertTrue(find(p_c_cbb, l3)); List<Path> l4 = gff.find(tempDir.resolve("c/[a-b]*").toString()); assertEquals(2, l4.size()); assertTrue(find(p_c_abc, l4)); assertTrue(find(p_c_bbb, l4)); }
@Test public void testRelative() throws Exception { GlobFileFinder gff = new GlobFileFinder(); StringBuilder sb = new StringBuilder(); Path cwd = path("").toAbsolutePath(); for (int i = 0; i < cwd.getNameCount(); i++) { sb.append("../"); } sb.append(tempDir.toString()).append("/*/a*"); List<Path> l1 = gff.find(sb.toString()); assertEquals(2, l1.size()); assertTrue(find(p_c_abc, l1)); assertTrue(find(p_d_abc, l1)); }