Filters { public Predicate<String> databaseFilter() { return databaseFilter; } Filters(Configuration config); Predicate<String> databaseFilter(); Predicate<CollectionId> collectionFilter(); FieldFilter fieldFilterFor(CollectionId id);  }
@Test public void shouldIncludeDatabaseCoveredByLiteralInWhitelist() { filters = build.includeDatabases("db1").createFilters(); assertThat(filters.databaseFilter().test("db1")).isTrue(); }
@Test public void shouldIncludeDatabaseCoveredByMultipleLiteralsInWhitelist() { filters = build.includeDatabases("db1,db2").createFilters(); assertThat(filters.databaseFilter().test("db1")).isTrue(); assertThat(filters.databaseFilter().test("db2")).isTrue(); }
@Test public void shouldIncludeDatabaseCoveredByWildcardInWhitelist() { filters = build.includeDatabases("db.*").createFilters(); assertThat(filters.databaseFilter().test("db1")).isTrue(); }
@Test public void shouldIncludeDatabaseCoveredByMultipleWildcardsInWhitelist() { filters = build.includeDatabases("db.*,mongo.*").createFilters(); assertThat(filters.databaseFilter().test("db1")).isTrue(); assertThat(filters.databaseFilter().test("mongo2")).isTrue(); }
@Test public void shouldExcludeDatabaseCoveredByLiteralInBlacklist() { filters = build.excludeDatabases("db1").createFilters(); assertThat(filters.databaseFilter().test("db1")).isFalse(); }
@Test public void shouldExcludeDatabaseCoveredByMultipleLiteralsInBlacklist() { filters = build.excludeDatabases("db1,db2").createFilters(); assertThat(filters.databaseFilter().test("db1")).isFalse(); assertThat(filters.databaseFilter().test("db2")).isFalse(); }
@Test public void shouldNotExcludeDatabaseNotCoveredByLiteralInBlacklist() { filters = build.excludeDatabases("db1").createFilters(); assertThat(filters.databaseFilter().test("db2")).isTrue(); }
@Test public void shouldExcludeDatabaseCoveredByWildcardInBlacklist() { filters = build.excludeDatabases("db.*").createFilters(); assertThat(filters.databaseFilter().test("db1")).isFalse(); }
@Test public void shouldExcludeDatabaseCoveredByMultipleWildcardsInBlacklist() { filters = build.excludeDatabases("db.*,mongo.*").createFilters(); assertThat(filters.databaseFilter().test("db1")).isFalse(); assertThat(filters.databaseFilter().test("mongo2")).isFalse(); }