@Test public void testConstructor() { EqualsFilter filter = new EqualsFilter("a", "b"); NotFilter notFilter = new NotFilter(filter); assertThat(notFilter.encode()).isEqualTo("(!(a=b))"); }
@Test public void testPresentFilter() { PresentFilter filter = new PresentFilter("foo"); assertThat(filter.encode()).isEqualTo("(foo=*)"); NotFilter notFilter = new NotFilter(new PresentFilter("foo")); assertThat(notFilter.encode()).isEqualTo("(!(foo=*))"); AndFilter andFilter = new AndFilter(); andFilter.and(new PresentFilter("foo")); andFilter.and(new PresentFilter("bar")); assertThat(andFilter.encode()).isEqualTo("(&(foo=*)(bar=*))"); andFilter = new AndFilter(); andFilter.and(new PresentFilter("foo")); andFilter.and(new NotFilter(new PresentFilter("bar"))); assertThat(andFilter.encode()).isEqualTo("(&(foo=*)(!(bar=*)))"); }
@Test public void testNotPresentFilter() { NotPresentFilter filter = new NotPresentFilter("foo"); assertThat(filter.encode()).isEqualTo("(!(foo=*))"); NotFilter notFilter = new NotFilter(new NotPresentFilter("foo")); assertThat(notFilter.encode()).isEqualTo("(!(!(foo=*)))"); AndFilter andFilter = new AndFilter(); andFilter.and(new NotPresentFilter("foo")); andFilter.and(new NotPresentFilter("bar")); assertThat(andFilter.encode()).isEqualTo("(&(!(foo=*))(!(bar=*)))"); andFilter = new AndFilter(); andFilter.and(new NotPresentFilter("foo")); andFilter.and(new NotFilter(new NotPresentFilter("bar"))); assertThat(andFilter.encode()).isEqualTo("(&(!(foo=*))(!(!(bar=*))))"); }
@Test public void testHardcodedFilter() { HardcodedFilter filter = new HardcodedFilter("(foo=a*b)"); assertThat(filter.encode()).isEqualTo("(foo=a*b)"); NotFilter notFilter = new NotFilter(new HardcodedFilter("(foo=a*b)")); assertThat(notFilter.encode()).isEqualTo("(!(foo=a*b))"); AndFilter andFilter = new AndFilter(); andFilter.and(new HardcodedFilter("(foo=a*b)")); andFilter.and(new HardcodedFilter("(bar=a*b)")); assertThat(andFilter.encode()).isEqualTo("(&(foo=a*b)(bar=a*b))"); andFilter = new AndFilter(); andFilter.and(new HardcodedFilter("(foo=a*b)")); andFilter.and(new NotFilter(new HardcodedFilter("(bar=a*b)"))); assertThat(andFilter.encode()).isEqualTo("(&(foo=a*b)(!(bar=a*b)))"); }