@Test public void testAcceptWithCaseSensitiveAndNotExactMatch() throws Exception { filter.setPattern("a").setCaseSensitive(true); assertThat(filter.accept(docInfo("a", "/pot/")), Matchers.equalTo(true)); assertThat(filter.accept(docInfo("A", "/pot/")), Matchers.equalTo(false)); }
@Test public void testSetFullText() throws Exception { filter.setPattern("/pot/a").setFullText(true); assertThat(filter.accept(docInfo("a", "/pot/")), Matchers.equalTo(true)); assertThat(filter.accept(docInfo("a", "")), Matchers.equalTo(false)); }
@Test public void testSetPatternAgainWillClearPreviousPattern() throws Exception { filter.setPattern("a"); assertThat(filter.accept(docInfo("a", "/pot/")), Matchers.equalTo(true)); filter.setPattern("b"); assertThat(filter.accept(docInfo("b", "/pot/")), Matchers.equalTo(true)); assertThat(filter.accept(docInfo("a", "/pot/")), Matchers.equalTo(false)); }
@Test public void testAcceptWithCaseInsensitiveAndNotExactMatch() throws Exception { filter.setPattern("a,b b, c , , d"); assertThat(filter.accept(docInfo("a", "/pot/")), Matchers.equalTo(true)); assertThat(filter.accept(docInfo("b b", "/pot/")), Matchers.equalTo(true)); assertThat(filter.accept(docInfo("c", "/pot/")), Matchers.equalTo(true)); assertThat(filter.accept(docInfo("C", "/pot/")), Matchers.equalTo(true)); assertThat(filter.accept(docInfo("d", "/pot/")), Matchers.equalTo(true)); assertThat(filter.accept(docInfo("b", "/pot/")), Matchers.equalTo(false)); }
@Test public void alwaysAcceptIfNoPattern() { assertThat(filter.accept(docInfo("a", "/pot/")), Matchers.equalTo(true)); }