### Question:
ChangesFilter implements Predicate<Changes> { @NonNull public static Flowable<Changes> applyForTables(@NonNull Flowable<Changes> changes, @NonNull Set<String> tables) { checkNotNull(tables, "Set of tables can not be null"); return changes .filter(new ChangesFilter(tables, null)); } 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_throwsIfTablesNull() { expectedException.expect(NullPointerException.class); expectedException.expectMessage(equalTo("Set of tables can not be null")); expectedException.expectCause(nullValue(Throwable.class)); ChangesFilter.applyForTables(Flowable.<Changes>empty(), null); }
@Test public void applyForTables_shouldFilterRequiredTable() { final TestSubscriber<Changes> testSubscriber = new TestSubscriber<Changes>(); ChangesFilter .applyForTables( Flowable.just(Changes.newInstance("table1"), Changes.newInstance("table2"), Changes.newInstance("table3")), singleton("table2")) .subscribe(testSubscriber); testSubscriber.assertValue(Changes.newInstance("table2")); testSubscriber.dispose(); }
@Test public void applyForTables_shouldFilterRequiredTableWhichIsPartOfSomeChanges() { final TestSubscriber<Changes> testSubscriber = new TestSubscriber<Changes>(); ChangesFilter .applyForTables( Flowable.just(Changes.newInstance("table1"), Changes.newInstance(new HashSet<String>() { { add("table1"); add("table2"); add("table3"); } })), singleton("table3")) .subscribe(testSubscriber); testSubscriber.assertValue(Changes.newInstance(new HashSet<String>() { { add("table1"); add("table2"); add("table3"); } })); testSubscriber.dispose(); }