@Test void filterParentFolderNoParents() { List<Folder> parentFolders = FolderFilter.parentFolders("my/folder/path", FilterTestUtils.getBundle()); assertEquals(1, parentFolders.size()); assertTrue(parentFolders.stream().anyMatch(f -> "Root Node".equals(f.getName()))); }
@SuppressWarnings("squid:S1075") public static List<Folder> parentFolders(String folderPath, Bundle bundle) { String folderPathWithSuffix = folderPath + "/"; Stream<Folder> folderStream = bundle.getFolderTree().stream() .filter(f -> { String path = bundle.getFolderTree().getFormattedPath(f); return folderPathWithSuffix.startsWith("/" + path + "/"); }); return Stream.concat(Stream.of(bundle.getFolderTree().getRootFolder()), folderStream).collect(Collectors.toList()); }
FolderFilter implements EntityFilter<Folder> { @SuppressWarnings("squid:S1075") public static List<Folder> parentFolders(String folderPath, Bundle bundle) { String folderPathWithSuffix = folderPath + "/"; Stream<Folder> folderStream = bundle.getFolderTree().stream() .filter(f -> { String path = bundle.getFolderTree().getFormattedPath(f); return folderPathWithSuffix.startsWith("/" + path + "/"); }); return Stream.concat(Stream.of(bundle.getFolderTree().getRootFolder()), folderStream).collect(Collectors.toList()); } }
FolderFilter implements EntityFilter<Folder> { @SuppressWarnings("squid:S1075") public static List<Folder> parentFolders(String folderPath, Bundle bundle) { String folderPathWithSuffix = folderPath + "/"; Stream<Folder> folderStream = bundle.getFolderTree().stream() .filter(f -> { String path = bundle.getFolderTree().getFormattedPath(f); return folderPathWithSuffix.startsWith("/" + path + "/"); }); return Stream.concat(Stream.of(bundle.getFolderTree().getRootFolder()), folderStream).collect(Collectors.toList()); }  }
FolderFilter implements EntityFilter<Folder> { @SuppressWarnings("squid:S1075") public static List<Folder> parentFolders(String folderPath, Bundle bundle) { String folderPathWithSuffix = folderPath + "/"; Stream<Folder> folderStream = bundle.getFolderTree().stream() .filter(f -> { String path = bundle.getFolderTree().getFormattedPath(f); return folderPathWithSuffix.startsWith("/" + path + "/"); }); return Stream.concat(Stream.of(bundle.getFolderTree().getRootFolder()), folderStream).collect(Collectors.toList()); }  @Override @NotNull Collection<Class<? extends EntityFilter>> getDependencyEntityFilters(); @Override List<Folder> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle); @SuppressWarnings("squid:S1075") static List<Folder> parentFolders(String folderPath, Bundle bundle); }
FolderFilter implements EntityFilter<Folder> { @SuppressWarnings("squid:S1075") public static List<Folder> parentFolders(String folderPath, Bundle bundle) { String folderPathWithSuffix = folderPath + "/"; Stream<Folder> folderStream = bundle.getFolderTree().stream() .filter(f -> { String path = bundle.getFolderTree().getFormattedPath(f); return folderPathWithSuffix.startsWith("/" + path + "/"); }); return Stream.concat(Stream.of(bundle.getFolderTree().getRootFolder()), folderStream).collect(Collectors.toList()); }  @Override @NotNull Collection<Class<? extends EntityFilter>> getDependencyEntityFilters(); @Override List<Folder> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle); @SuppressWarnings("squid:S1075") static List<Folder> parentFolders(String folderPath, Bundle bundle);  }