public static Collection<File> getFileResourcesFromDirectory(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 getFileResourcesFromDirectory(elem, pattern).stream();
                            } else {
                                try {
                                    if (pattern.matcher(elem.getCanonicalPath()).matches()) {
                                        return Stream.of(elem);
                                    }
                                } catch (final IOException e) {
                                    throw new RuntimeException("Failed to retrieve resources from directory " + directory.getAbsolutePath() + " with pattern " + pattern.pattern(), e);
                                }
                            }
                            return Stream.empty();
                        })
                .collect(Collectors.toSet());
    }
@Test
    public void getResourcesFromDirectoryNotExisting() {
        File directory = new File("." + File.separator + "target" + File.separator + "test-classes");
        Pattern pattern = Pattern.compile(".*arg");
        final Collection<File> retrieved = getFileResourcesFromDirectory(directory, pattern);
        commonVerifyCollectionWithoutExpectedFile(retrieved);
    }