@Test public void listJsonFilePaths_should_list_all_json_files_in_zip() throws URISyntaxException, IOException { final ClassLoader classLoader = cut.getClass().getClassLoader(); final String zipName = "postman/files-in-folders.zip"; final URL zipUrl = classLoader.getResource(zipName); if (zipUrl == null) { throw new IOException("Cannot find given ZIP file " + zipName); } final Path zipPath = Paths.get(new File(zipUrl.toURI()).getPath()); final FileSystem zip = FileSystems.newFileSystem(zipPath, classLoader); final List<Path> paths = cut.listJsonFilePaths(zip); assertThat(paths.stream().map(Path::toString)).containsExactly( "/folder/sub-file1.json", "/folder/sub-file2.json", "/folder/sub-folder/sub-sub-file1.json", "/folder/sub-folder/sub-sub-file2.json", "/root-file1.json", "/root-file2.json"); }
List<Path> listJsonFilePaths(FileSystem zip) throws IOException { List<Path> jsonFilePaths = new ArrayList<>(); for (Path root : zip.getRootDirectories()) { try (final Stream<Path> walker = Files.walk(root)) { jsonFilePaths.addAll(walker .filter(path -> path.toString().endsWith(".json")) .sorted() .collect(Collectors.toList())); } } return jsonFilePaths; }
PostmanScenarioIndexerService { List<Path> listJsonFilePaths(FileSystem zip) throws IOException { List<Path> jsonFilePaths = new ArrayList<>(); for (Path root : zip.getRootDirectories()) { try (final Stream<Path> walker = Files.walk(root)) { jsonFilePaths.addAll(walker .filter(path -> path.toString().endsWith(".json")) .sorted() .collect(Collectors.toList())); } } return jsonFilePaths; } }
PostmanScenarioIndexerService { List<Path> listJsonFilePaths(FileSystem zip) throws IOException { List<Path> jsonFilePaths = new ArrayList<>(); for (Path root : zip.getRootDirectories()) { try (final Stream<Path> walker = Files.walk(root)) { jsonFilePaths.addAll(walker .filter(path -> path.toString().endsWith(".json")) .sorted() .collect(Collectors.toList())); } } return jsonFilePaths; }  }
PostmanScenarioIndexerService { List<Path> listJsonFilePaths(FileSystem zip) throws IOException { List<Path> jsonFilePaths = new ArrayList<>(); for (Path root : zip.getRootDirectories()) { try (final Stream<Path> walker = Files.walk(root)) { jsonFilePaths.addAll(walker .filter(path -> path.toString().endsWith(".json")) .sorted() .collect(Collectors.toList())); } } return jsonFilePaths; }  List<Scenario> extractScenarios(Source source, File zipFile); }
PostmanScenarioIndexerService { List<Path> listJsonFilePaths(FileSystem zip) throws IOException { List<Path> jsonFilePaths = new ArrayList<>(); for (Path root : zip.getRootDirectories()) { try (final Stream<Path> walker = Files.walk(root)) { jsonFilePaths.addAll(walker .filter(path -> path.toString().endsWith(".json")) .sorted() .collect(Collectors.toList())); } } return jsonFilePaths; }  List<Scenario> extractScenarios(Source source, File zipFile);  }