CommandDirectories { public List<Path> listFilesWithExtensionInSourceDirectory(String... extensions) throws CommandException { final List<Path> paths = new ArrayList<>(); final PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher(buildGlobPatternForFileWithExtensions(extensions)); SimpleFileVisitor<Path> extensionFileVisitor = new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (pathMatcher.matches(file)) { paths.add(file); } return FileVisitResult.CONTINUE; } }; try { Files.walkFileTree(sourceDirectoryPath, extensionFileVisitor); } catch (IOException ioe) { throw new CommandException("Error while listing the file for extension: " + Arrays.toString(extensions), ioe); } return paths; } CommandDirectories(String sourceDirectoryPathString);  CommandDirectories(String sourceDirectoryPathString, String targetDirectoryPathString); Path resolveWithTargetDirectory(Path pathInSourceDirectory); Path resolveWithTargetDirectoryAndCreateParentDirectories(Path pathInSourceDirectory); Path relativizeWithSourceDirectory(Path path); Path relativizeWithTargetDirectory(Path path); Path relativizeWithUserDirectory(Path path); List<Path> listFilesWithExtensionInSourceDirectory(String... extensions); Path getSourceDirectoryPath(); Path getTargetDirectoryPath();  }
@Test public void testListFilesWithExtensionInSourceDirectory() throws Exception { String extension = "xliff"; CommandDirectories instance = new CommandDirectories(getInputResourcesTestDir().toString(), getTargetTestDir().toString()); List<Path> expResult = new ArrayList<>(); Collections.sort(expResult); expResult.add(Paths.get(getInputResourcesTestDir().toString(), "file.xliff")); expResult.add(Paths.get(getInputResourcesTestDir().toString(), "sub/file.xliff")); List<Path> result = instance.listFilesWithExtensionInSourceDirectory(extension); Collections.sort(result); assertEquals(expResult, result); }