@Test void filter() { EncassFilter filter = new EncassFilter(); Bundle filteredBundle = new Bundle(); filteredBundle.addEntity(createPolicy("my-policy", "1", "", "", null, "")); Bundle bundle = FilterTestUtils.getBundle(); bundle.setDependencyMap( ImmutableMap.of( new Dependency("1", Policy.class, "my-policy", EntityTypes.POLICY_TYPE), Arrays.asList(new Dependency("2", Encass.class, "encass2", EntityTypes.ENCAPSULATED_ASSERTION_TYPE), new Dependency("3", Encass.class, "encass1", EntityTypes.ENCAPSULATED_ASSERTION_TYPE)), new Dependency("2", Policy.class, "my-policy2", EntityTypes.POLICY_TYPE), Collections.singletonList(new Dependency("4", Encass.class, "encass4", EntityTypes.ENCAPSULATED_ASSERTION_TYPE)))); bundle.addEntity(createEncass("encass1", "1", "", "zzz")); bundle.addEntity(createEncass("encass2", "2", "", "1")); bundle.addEntity(createEncass("encass3", "3", "", "1")); bundle.addEntity(createEncass("encass4", "4", "", "2")); List<Encass> filteredEntities = filter.filter("/my/folder/path", new FilterConfiguration(), bundle, filteredBundle); assertEquals(2, filteredEntities.size()); assertTrue(filteredEntities.stream().anyMatch(c -> "encass2".equals(c.getName()))); assertTrue(filteredEntities.stream().anyMatch(c -> "encass3".equals(c.getName()))); }
@Override public List<Encass> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Map<String, Policy> policies = filteredBundle.getPolicies(); return bundle.getEntities(Encass.class).values().stream() .filter(e -> policies.containsKey(e.getPolicyId())).collect(Collectors.toList()); }
EncassFilter implements EntityFilter<Encass> { @Override public List<Encass> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Map<String, Policy> policies = filteredBundle.getPolicies(); return bundle.getEntities(Encass.class).values().stream() .filter(e -> policies.containsKey(e.getPolicyId())).collect(Collectors.toList()); } }
EncassFilter implements EntityFilter<Encass> { @Override public List<Encass> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Map<String, Policy> policies = filteredBundle.getPolicies(); return bundle.getEntities(Encass.class).values().stream() .filter(e -> policies.containsKey(e.getPolicyId())).collect(Collectors.toList()); }  }
EncassFilter implements EntityFilter<Encass> { @Override public List<Encass> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Map<String, Policy> policies = filteredBundle.getPolicies(); return bundle.getEntities(Encass.class).values().stream() .filter(e -> policies.containsKey(e.getPolicyId())).collect(Collectors.toList()); }  @Override @NotNull Collection<Class<? extends EntityFilter>> getDependencyEntityFilters(); @Override List<Encass> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle); }
EncassFilter implements EntityFilter<Encass> { @Override public List<Encass> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Map<String, Policy> policies = filteredBundle.getPolicies(); return bundle.getEntities(Encass.class).values().stream() .filter(e -> policies.containsKey(e.getPolicyId())).collect(Collectors.toList()); }  @Override @NotNull Collection<Class<? extends EntityFilter>> getDependencyEntityFilters(); @Override List<Encass> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle);  }