ResourceHelper { static Stream<String> internalGetResources(String path, Pattern pattern) { final File file = new File(path); if (!file.isDirectory()) { return Stream.empty(); } return getResourcesFromDirectory(file, pattern); } private  ResourceHelper(); static Stream<String> getResourcesByExtension(String extension); static Stream<String> getResourcesFromDirectory(File directory, Pattern pattern);  }
@Test public void internalGetResourcesTest() { List<String> classPathElements = Arrays.asList(getClassPathElements()); Optional<String> testFolder = classPathElements.stream().filter(elem -> elem.contains("test-classes")).findFirst(); assertTrue(testFolder.isPresent()); File dir = new File(testFolder.get()); List<String> filesFound = internalGetResources(testFolder.get(), Pattern.compile(".*\\.txt$")).collect(Collectors.toList()); assertEquals(1, filesFound.size()); assertEquals(0, internalGetResources(filesFound.get(0), Pattern.compile(".*\\.txt$")).count()); }