public static Collection<String> getResourcesFromDirectory(File directory, Pattern pattern) {
        if (directory == null || directory.listFiles() == null) {
            return Collections.emptySet();
        }
        return Arrays.stream(Objects.requireNonNull(directory.listFiles()))
                .flatMap(elem -> {
                    if (elem.isDirectory()) {
                        return getResourcesFromDirectory(elem, pattern)
                                .stream();
                    } else {
                        try {
                            String fileName = elem.getCanonicalPath();
                            if (pattern.matcher(fileName).matches()) {
                                return Stream.of(fileName);
                            } else {
                                return Stream.empty();
                            }
                        } catch (final IOException e) {
                            throw new RuntimeException("Impossible to access to resources", e);
                        }
                    }
                })
                .collect(Collectors.toSet());
    }
@Test
    public void getResourcesFromDirectoryTest() {
        List<String> classPathElements = Arrays.asList(ResourceHelper.getClassPathElements());
        Optional<String> testFolder =
                classPathElements.stream().filter(elem -> elem.contains("test-classes")).findFirst();
        assertThat(testFolder).isPresent();
        File dir = new File(testFolder.get());
        String regex = ".*" + TEST_FILE;
        Collection<String> filesFound = getResourcesFromDirectory(dir, Pattern.compile(regex));
        assertThat(filesFound).hasSize(2);

        assertThat(getResourcesFromDirectory(null, null)).isEmpty();
        assertThat(getResourcesFromDirectory(dir, Pattern.compile("noMatch"))).isEmpty();
    }