AvailabilityPostFilter implements FacetValuesMapFilter { @Override public void filter(FacetValuesMap map) { fields.forEach(field -> reduceAvailabilityForField(map, field)); } AvailabilityPostFilter(String... field);  AvailabilityPostFilter(List<String> fields); @Override void filter(FacetValuesMap map);  }
@Test public void testFilterSimple() { final FacetValuesMap map = new FacetValuesMap(); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("PUB", "und"), true, true)); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("RES", "und"), true, true)); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("ACA", "und"), true, true)); instance.filter(map); final List<ValueSet> availability = map.get("availability"); assertEquals(1, availability.size()); assertEquals("RES", availability.get(0).getValue()); }
@Test public void testFilterOtherTag() { final FacetValuesMap map = new FacetValuesMap(); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("BLA", "und"), true, true)); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("VLA", "und"), true, true)); instance.filter(map); final List<ValueSet> availability = map.get("availability"); assertEquals(2, availability.size()); final Iterator<ValueSet> iterator = availability.iterator(); assertEquals("BLA", iterator.next().getValue()); assertEquals("VLA", iterator.next().getValue()); }
@Test public void testFilterMixed() { final FacetValuesMap map = new FacetValuesMap(); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("PUB", "und"), true, true)); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("BLA", "und"), true, true)); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("RES", "und"), true, true)); map.addToTarget(new ValueSet(0, null, availabilityTargetFacet, Pair.of("VLA", "und"), true, true)); instance.filter(map); final List<ValueSet> availability = map.get("availability"); assertEquals(3, availability.size()); final Iterator<ValueSet> iterator = availability.iterator(); assertEquals("RES", iterator.next().getValue()); assertEquals("BLA", iterator.next().getValue()); assertEquals("VLA", iterator.next().getValue()); }