### Question:
ChangesFilter implements Predicate<Changes> { @NonNull public static Flowable<Changes> applyForTags(@NonNull Flowable<Changes> changes, @NonNull Set<String> tags) { checkNotNull(tags, "Set of tags can not be null"); return changes .filter(new ChangesFilter(null, tags)); } private  ChangesFilter(@Nullable Set<String> tables, @Nullable Set<String> tags); @NonNull static Flowable<Changes> applyForTables(@NonNull Flowable<Changes> changes, @NonNull Set<String> tables); @NonNull static Flowable<Changes> applyForTags(@NonNull Flowable<Changes> changes, @NonNull Set<String> tags); @NonNull static Flowable<Changes> applyForTablesAndTags(
            @NonNull Flowable<Changes> changes,
            @NonNull Set<String> tables,
            @NonNull Set<String> tags
    ); @Override boolean test(@NonNull Changes changes);  }### Answer:
@Test public void applyForTables_throwsIfTagsNull() { expectedException.expect(NullPointerException.class); expectedException.expectMessage(equalTo("Set of tags can not be null")); expectedException.expectCause(nullValue(Throwable.class)); ChangesFilter.applyForTags(Flowable.<Changes>empty(), null); }
@Test public void applyForTags_shouldFilterRequiredTag() { final TestSubscriber<Changes> testSubscriber = new TestSubscriber<Changes>(); ChangesFilter .applyForTags( Flowable.just( Changes.newInstance("table1", "tag1"), Changes.newInstance("table2", "tag2"), Changes.newInstance("table3")), singleton("tag1")) .subscribe(testSubscriber); testSubscriber.assertValue(Changes.newInstance("table1", "tag1")); testSubscriber.dispose(); }
@Test public void applyForTags_shouldFilterRequiredTagWhichIsPartOfSomeChanges() { final TestSubscriber<Changes> testSubscriber = new TestSubscriber<Changes>(); Changes changes = Changes.newInstance( new HashSet<String>() {{ add("table1"); }}, new HashSet<String>() {{ add("tag1"); add("tag2"); }} ); ChangesFilter .applyForTags( Flowable.just( changes, Changes.newInstance("table3", "tag3"), Changes.newInstance("table4")), singleton("tag1")) .subscribe(testSubscriber); testSubscriber.assertValue(changes); testSubscriber.dispose(); }