@Test public void testCorrectTerms() { final ArrayList<RefactoringPageRow> rows = new ArrayList<>(); doReturn(rows).when(refactoringQueryService).query(eq(FindAllLibraryAssetsQuery.NAME), anySet()); final org.uberfire.java.nio.file.Path root = fileSystemProvider.getPath(URI.create("default: final List<Path> list = fileLoader.loadPaths(Paths.convert(root), "txt"); assertTrue(list.isEmpty()); verify(refactoringQueryService).query(eq(FindAllLibraryAssetsQuery.NAME), termsCaptor.capture()); final Set<ValueIndexTerm> terms = termsCaptor.getValue(); assertEquals(2, terms.size()); testLibraryValueFileExtensionIndexTerm(terms); testLibraryValueRepositoryRootIndexTerm(terms); }
public List<Path> loadPaths(final Path path, final String suffix) { PortablePreconditions.checkNotNull("path", path); PortablePreconditions.checkNotNull("suffix", suffix); org.uberfire.java.nio.file.Path nioPath = Paths.convert(path); final List<Path> items = new ArrayList<>(); if (!Files.exists(nioPath)) { return items; } if (!Files.isDirectory(nioPath)) { nioPath = nioPath.getParent(); } final Set<ValueIndexTerm> queryTerms = new HashSet<>(); final ArrayList<String> extensions = new ArrayList<>(); extensions.add(suffix); queryTerms.add(new LibraryValueRepositoryRootIndexTerm(Paths.convert(nioPath).toURI(), ValueIndexTerm.TermSearchType.NORMAL)); queryTerms.add(new LibraryValueFileExtensionIndexTerm(extensions)); final List<RefactoringPageRow> rows = refactoringQueryService.query(FindAllLibraryAssetsQuery.NAME, queryTerms); for (RefactoringPageRow row : rows) { items.add((Path) row.getValue()); } return items; }
FileLoader { public List<Path> loadPaths(final Path path, final String suffix) { PortablePreconditions.checkNotNull("path", path); PortablePreconditions.checkNotNull("suffix", suffix); org.uberfire.java.nio.file.Path nioPath = Paths.convert(path); final List<Path> items = new ArrayList<>(); if (!Files.exists(nioPath)) { return items; } if (!Files.isDirectory(nioPath)) { nioPath = nioPath.getParent(); } final Set<ValueIndexTerm> queryTerms = new HashSet<>(); final ArrayList<String> extensions = new ArrayList<>(); extensions.add(suffix); queryTerms.add(new LibraryValueRepositoryRootIndexTerm(Paths.convert(nioPath).toURI(), ValueIndexTerm.TermSearchType.NORMAL)); queryTerms.add(new LibraryValueFileExtensionIndexTerm(extensions)); final List<RefactoringPageRow> rows = refactoringQueryService.query(FindAllLibraryAssetsQuery.NAME, queryTerms); for (RefactoringPageRow row : rows) { items.add((Path) row.getValue()); } return items; } }
FileLoader { public List<Path> loadPaths(final Path path, final String suffix) { PortablePreconditions.checkNotNull("path", path); PortablePreconditions.checkNotNull("suffix", suffix); org.uberfire.java.nio.file.Path nioPath = Paths.convert(path); final List<Path> items = new ArrayList<>(); if (!Files.exists(nioPath)) { return items; } if (!Files.isDirectory(nioPath)) { nioPath = nioPath.getParent(); } final Set<ValueIndexTerm> queryTerms = new HashSet<>(); final ArrayList<String> extensions = new ArrayList<>(); extensions.add(suffix); queryTerms.add(new LibraryValueRepositoryRootIndexTerm(Paths.convert(nioPath).toURI(), ValueIndexTerm.TermSearchType.NORMAL)); queryTerms.add(new LibraryValueFileExtensionIndexTerm(extensions)); final List<RefactoringPageRow> rows = refactoringQueryService.query(FindAllLibraryAssetsQuery.NAME, queryTerms); for (RefactoringPageRow row : rows) { items.add((Path) row.getValue()); } return items; }  }
FileLoader { public List<Path> loadPaths(final Path path, final String suffix) { PortablePreconditions.checkNotNull("path", path); PortablePreconditions.checkNotNull("suffix", suffix); org.uberfire.java.nio.file.Path nioPath = Paths.convert(path); final List<Path> items = new ArrayList<>(); if (!Files.exists(nioPath)) { return items; } if (!Files.isDirectory(nioPath)) { nioPath = nioPath.getParent(); } final Set<ValueIndexTerm> queryTerms = new HashSet<>(); final ArrayList<String> extensions = new ArrayList<>(); extensions.add(suffix); queryTerms.add(new LibraryValueRepositoryRootIndexTerm(Paths.convert(nioPath).toURI(), ValueIndexTerm.TermSearchType.NORMAL)); queryTerms.add(new LibraryValueFileExtensionIndexTerm(extensions)); final List<RefactoringPageRow> rows = refactoringQueryService.query(FindAllLibraryAssetsQuery.NAME, queryTerms); for (RefactoringPageRow row : rows) { items.add((Path) row.getValue()); } return items; }  List<Path> loadPaths(final Path path,
                                final String suffix); }
FileLoader { public List<Path> loadPaths(final Path path, final String suffix) { PortablePreconditions.checkNotNull("path", path); PortablePreconditions.checkNotNull("suffix", suffix); org.uberfire.java.nio.file.Path nioPath = Paths.convert(path); final List<Path> items = new ArrayList<>(); if (!Files.exists(nioPath)) { return items; } if (!Files.isDirectory(nioPath)) { nioPath = nioPath.getParent(); } final Set<ValueIndexTerm> queryTerms = new HashSet<>(); final ArrayList<String> extensions = new ArrayList<>(); extensions.add(suffix); queryTerms.add(new LibraryValueRepositoryRootIndexTerm(Paths.convert(nioPath).toURI(), ValueIndexTerm.TermSearchType.NORMAL)); queryTerms.add(new LibraryValueFileExtensionIndexTerm(extensions)); final List<RefactoringPageRow> rows = refactoringQueryService.query(FindAllLibraryAssetsQuery.NAME, queryTerms); for (RefactoringPageRow row : rows) { items.add((Path) row.getValue()); } return items; }  List<Path> loadPaths(final Path path,
                                final String suffix);  }