FilterListAdapter extends TypedFilterAdapterBase<FilterList> implements UnsupportedStatusCollector<FilterList> { @Override public FilterSupportStatus isFilterSupported(FilterAdapterContext context, FilterList filter) { List<FilterSupportStatus> unsupportedSubfilters = new ArrayList<>(); try (ContextCloseable ignored = context.beginFilterList(filter)) { collectUnsupportedStatuses(context, filter, unsupportedSubfilters); } if (unsupportedSubfilters.isEmpty()) { return FilterSupportStatus.SUPPORTED; } else { return FilterSupportStatus.newCompositeNotSupported(unsupportedSubfilters); } } FilterListAdapter(FilterAdapter subFilterAdapter); @Override Filters.Filter adapt(FilterAdapterContext context, FilterList filter); @Override FilterSupportStatus isFilterSupported(FilterAdapterContext context, FilterList filter); @Override void collectUnsupportedStatuses(
      FilterAdapterContext context,
      FilterList filter,
      List<FilterSupportStatus> unsupportedStatuses); @Override RangeSet<RowKeyWrapper> getIndexScanHint(FilterList filter);  }
@Test public void compositeFilterSupportStatusIsReturnedForUnsupportedChildFilters() { FilterListAdapter filterListAdapter = new FilterListAdapter( new FilterAdapter() { @Override public void collectUnsupportedStatuses( FilterAdapterContext context, Filter filter, List<FilterSupportStatus> statuses) { Assert.assertEquals( "FilterListDepth should be incremented in isFilterSupported.", 1, context.getFilterListDepth()); statuses.add(FilterSupportStatus.newNotSupported("Test")); } }); FilterList filterList = makeFilterList(Operator.MUST_PASS_ALL); FilterSupportStatus status = filterListAdapter.isFilterSupported(emptyScanContext, filterList); Assert.assertFalse( "collectUnsupportedStatuses should have been invoked returning unsupported statuses.", status.isSupported()); }
@Test public void collectUnsupportedStatusesStartsANewContext() { FilterListAdapter filterListAdapter = new FilterListAdapter( new FilterAdapter() { @Override public void collectUnsupportedStatuses( FilterAdapterContext context, Filter filter, List<FilterSupportStatus> statuses) { Assert.assertEquals( "FilterListDepth should be incremented in isFilterSupported.", 1, context.getFilterListDepth()); statuses.add(FilterSupportStatus.newNotSupported("Test")); } }); Assert.assertEquals("Initial depth should be 0.", 0, emptyScanContext.getFilterListDepth()); FilterList filterList = makeFilterList(Operator.MUST_PASS_ALL); FilterSupportStatus status = filterListAdapter.isFilterSupported(emptyScanContext, filterList); Assert.assertFalse( "collectUnsupportedStatuses should have been invoked returning unsupported statuses.", status.isSupported()); }