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);  }
@Test public void testGetConfigPathsFromSpecificFolder() { List<String> result = underTest.getConfigPathsFromSpecificFolder("test/path", "*TestPattern"); verify(fileUtils).listFilesWithFilter(Mockito.any(File.class), Mockito.anyString()); Assert.assertEquals(result, expectedFilePaths); }
@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); }
@Test public void testGetConfigPathsFromSpecificFolderWhenThePatternIsASpecificFileNameAndThisIsInTheRootFolder() { expectedFilePaths = new ArrayList<>(); expectedFilePaths.add("TestPattern"); List<String> result = underTest.getConfigPathsFromSpecificFolder("", "TestPattern"); Assert.assertEquals(result, expectedFilePaths); }