### Question:
VisibilityFilter extends Filter implements OptionDescriber { public static void filterInvalidLabelsOnly(IteratorSetting setting, boolean featureEnabled) { setting.addOption(FILTER_INVALID_ONLY, Boolean.toString(featureEnabled)); }  @Override void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options,
      IteratorEnvironment env); @Override boolean accept(Key k, Value v); @Override IteratorOptions describeOptions(); static void setAuthorizations(IteratorSetting setting, Authorizations auths); static void filterInvalidLabelsOnly(IteratorSetting setting, boolean featureEnabled);  }### Answer:
@Test public void testAllowValidLabelsOnly() throws IOException { IteratorSetting is = new IteratorSetting(1, VisibilityFilter.class); VisibilityFilter.filterInvalidLabelsOnly(is, true); TreeMap<Key,Value> source = createPollutedSource(1, 2); verify(source, 3, is.getOptions(), GOOD, GOOD, GOOD_VIS, 1); source = createPollutedSource(30, 500); verify(source, 530, is.getOptions(), GOOD, GOOD, GOOD_VIS, 30); source = createPollutedSource(1000, 500); verify(source, 1500, is.getOptions(), GOOD, GOOD, GOOD_VIS, 1000); }
@Test public void testAllowBadLabelsOnly() throws IOException { IteratorSetting is = new IteratorSetting(1, VisibilityFilter.class); VisibilityFilter.setNegate(is, true); VisibilityFilter.filterInvalidLabelsOnly(is, true); TreeMap<Key,Value> source = createPollutedSource(1, 2); verify(source, 3, is.getOptions(), BAD, BAD, BAD_VIS, 2); source = createPollutedSource(30, 500); verify(source, 530, is.getOptions(), BAD, BAD, BAD_VIS, 500); source = createPollutedSource(1000, 500); verify(source, 1500, is.getOptions(), BAD, BAD, BAD_VIS, 500); }