Generator<File> (String rootPath, FileFilter fileFilter, boolean useRouletteWheel) { FileFilter interestingIdeaFiles = child -> { String name = child.getName(); if (name.startsWith(".")) return false; if (child.isDirectory()) { return shouldGoInsiderDir(name); } return !FileTypeManager.getInstance().getFileTypeByFileName(name).isBinary() && fileFilter.accept(child) && child.length() < 500_000; }; File root = new File(rootPath); Function<GenerationEnvironment, File> generator = useRouletteWheel ? new RouletteWheelFileGenerator(root, interestingIdeaFiles) : new FileGenerator(root, interestingIdeaFiles); return Generator.from(generator) .suchThat(new Predicate<>() { @Override public boolean test(File file) { return file != null; } @Override public String toString() { return "can find a file under " + rootPath + " satisfying given filters"; } }) .noShrink(); }