@Test public void testGetConfigPathsFromSpecificFolderWhenThePatternIsASpecificFileNameAndThisIsInASpecificFolder() { expectedFilePaths = new ArrayList<>(); expectedFilePaths.add(FilenameUtils.separatorsToSystem("test/path/TestPattern")); List<String> result = underTest.getConfigPathsFromSpecificFolder("test/path", "TestPattern"); Assert.assertEquals(result, expectedFilePaths); }
public List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern) { List<String> resultPaths = new ArrayList<>(); if (!pattern.contains("*")) { String specificFilePath; if ("".equals(sourceFolderPath)) { specificFilePath = pattern; } else { specificFilePath = FilenameUtils.separatorsToSystem(sourceFolderPath + "/" + pattern); } resultPaths.add(specificFilePath); } else { File folder = new File(sourceFolderPath); folder = folder.getAbsoluteFile(); int cutFromHere = pattern.indexOf("*") + 1; String endOfFiles = pattern.substring(cutFromHere); for (File file : fileUtils.listFilesWithFilter(folder, "^(.+)" + endOfFiles + "$")) { resultPaths.add(file.getPath()); } } return resultPaths; }
StubConfigPathProvider { public List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern) { List<String> resultPaths = new ArrayList<>(); if (!pattern.contains("*")) { String specificFilePath; if ("".equals(sourceFolderPath)) { specificFilePath = pattern; } else { specificFilePath = FilenameUtils.separatorsToSystem(sourceFolderPath + "/" + pattern); } resultPaths.add(specificFilePath); } else { File folder = new File(sourceFolderPath); folder = folder.getAbsoluteFile(); int cutFromHere = pattern.indexOf("*") + 1; String endOfFiles = pattern.substring(cutFromHere); for (File file : fileUtils.listFilesWithFilter(folder, "^(.+)" + endOfFiles + "$")) { resultPaths.add(file.getPath()); } } return resultPaths; } }
StubConfigPathProvider { public List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern) { List<String> resultPaths = new ArrayList<>(); if (!pattern.contains("*")) { String specificFilePath; if ("".equals(sourceFolderPath)) { specificFilePath = pattern; } else { specificFilePath = FilenameUtils.separatorsToSystem(sourceFolderPath + "/" + pattern); } resultPaths.add(specificFilePath); } else { File folder = new File(sourceFolderPath); folder = folder.getAbsoluteFile(); int cutFromHere = pattern.indexOf("*") + 1; String endOfFiles = pattern.substring(cutFromHere); for (File file : fileUtils.listFilesWithFilter(folder, "^(.+)" + endOfFiles + "$")) { resultPaths.add(file.getPath()); } } return resultPaths; }  }
StubConfigPathProvider { public List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern) { List<String> resultPaths = new ArrayList<>(); if (!pattern.contains("*")) { String specificFilePath; if ("".equals(sourceFolderPath)) { specificFilePath = pattern; } else { specificFilePath = FilenameUtils.separatorsToSystem(sourceFolderPath + "/" + pattern); } resultPaths.add(specificFilePath); } else { File folder = new File(sourceFolderPath); folder = folder.getAbsoluteFile(); int cutFromHere = pattern.indexOf("*") + 1; String endOfFiles = pattern.substring(cutFromHere); for (File file : fileUtils.listFilesWithFilter(folder, "^(.+)" + endOfFiles + "$")) { resultPaths.add(file.getPath()); } } return resultPaths; }  List<String> getConfigPathsFromCache(final String cachePath); List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern); }
StubConfigPathProvider { public List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern) { List<String> resultPaths = new ArrayList<>(); if (!pattern.contains("*")) { String specificFilePath; if ("".equals(sourceFolderPath)) { specificFilePath = pattern; } else { specificFilePath = FilenameUtils.separatorsToSystem(sourceFolderPath + "/" + pattern); } resultPaths.add(specificFilePath); } else { File folder = new File(sourceFolderPath); folder = folder.getAbsoluteFile(); int cutFromHere = pattern.indexOf("*") + 1; String endOfFiles = pattern.substring(cutFromHere); for (File file : fileUtils.listFilesWithFilter(folder, "^(.+)" + endOfFiles + "$")) { resultPaths.add(file.getPath()); } } return resultPaths; }  List<String> getConfigPathsFromCache(final String cachePath); List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern);  }