HistoryFileManager extends AbstractService { @VisibleForTesting protected static List<FileStatus> scanDirectory(Path path, FileContext fc, PathFilter pathFilter) throws IOException { path = fc.makeQualified(path); List<FileStatus> jhStatusList = new ArrayList<FileStatus>(); try { RemoteIterator<FileStatus> fileStatusIter = fc.listStatus(path); while (fileStatusIter.hasNext()) { FileStatus fileStatus = fileStatusIter.next(); Path filePath = fileStatus.getPath(); if (fileStatus.isFile() && pathFilter.accept(filePath)) { jhStatusList.add(fileStatus); } } } catch (FileNotFoundException fe) { LOG.error("Error while scanning directory " + path, fe); } return jhStatusList; } HistoryFileManager(); @Override void serviceStop(); Collection<HistoryFileInfo> getAllFileInfo(); HistoryFileInfo getFileInfo(JobId jobId);  }
@Test public void testScanDirectory() throws Exception { Path p = new Path("any"); FileContext fc = mock(FileContext.class); when(fc.makeQualified(p)).thenReturn(p); when(fc.listStatus(p)).thenThrow(new FileNotFoundException()); List<FileStatus> lfs = HistoryFileManager.scanDirectory(p, fc, null); Assert.assertNotNull(lfs); }