FilterData extends DataWrapper<T> { public void setPredicate(@NonNull Predicate<? super T> predicate) { if (!equal(predicate, mPredicate)) { mPredicate = predicate; changeIndexRange(0, mData.size(), false, true, true); } } FilterData(@NonNull Data<? extends T> data);  FilterData(@NonNull Data<? extends T> data, @NonNull Predicate<? super T> predicate); @NonNull Predicate<? super T> getPredicate(); void setPredicate(@NonNull Predicate<? super T> predicate); @Override int size(); @NonNull @Override T get(int position, int flags);  }
@Test public void reassignFilter() { DataObserver observer = mock(DataObserver.class); mFilterData.registerDataObserver(observer); mFilterData.setPredicate(contains("a")); assertContains("bear", "cat", "bar", "baz"); verify(observer).onItemRangeInserted(1, 1); verifyNoMoreInteractions(observer); }
@Test public void reassignFilter2() { DataObserver observer = mock(DataObserver.class); mFilterData.registerDataObserver(observer); mFilterData.setPredicate(contains("f")); assertContains("foo", "fish"); verify(observer).onItemRangeRemoved(0, 1); verify(observer).onItemRangeInserted(0, 1); verify(observer, times(2)).onItemRangeRemoved(1, 1); verify(observer).onItemRangeInserted(1, 1); verifyNoMoreInteractions(observer); }