GenericEntityFilter implements EntityFilter<GenericEntity> { @Override public List<GenericEntity> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { List<GenericEntity> genericEntities = DependencyUtils.filterDependencies(GenericEntity.class, bundle, filteredBundle, e -> filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(e.getName())); DependencyUtils.validateEntitiesInList(genericEntities, filterConfiguration.getRequiredEntityNames(ENTITY_NAME), "Generic Entity(s)"); return genericEntities; }  @Override @NotNull Collection<Class<? extends EntityFilter>> getDependencyEntityFilters(); @Override List<GenericEntity> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle,
                                      Bundle filteredBundle); @Override String getFilterableEntityName();  }
@Test public void testFilter() { GenericEntityFilter genericEntityFilter = new GenericEntityFilter(); FilterConfiguration filterConfiguration = new FilterConfiguration(); Map<String, Collection<String>> entityFilters = new HashMap<>(); Collection<String> entityNames = new LinkedList<>(); entityNames.add(HTTP2_CLIENT_NAME); entityFilters.put(genericEntityFilter.getFilterableEntityName(), entityNames); filterConfiguration.setEntityFilters(entityFilters); List<GenericEntity> filteredEntities = genericEntityFilter.filter("/", filterConfiguration, getTestBundle(), new Bundle()); assertEquals(1, filteredEntities.size()); entityFilters.put(genericEntityFilter.getFilterableEntityName(), Collections.emptySet()); filterConfiguration.setEntityFilters(entityFilters); filteredEntities = genericEntityFilter.filter("/", filterConfiguration, getTestBundle(), new Bundle()); assertEquals(0, filteredEntities.size()); entityFilters.put(genericEntityFilter.getFilterableEntityName(), ImmutableSet.of("unknownClient")); filterConfiguration.setEntityFilters(entityFilters); try { genericEntityFilter.filter("/", filterConfiguration, getTestBundle(), new Bundle()); fail("Filter should have failed to validate the required generic entities"); } catch (EntityFilterException e) { assertEquals("Missing Generic Entity(s) with name: 'unknownClient'", e.getMessage()); } }