### Question:
AbstractTextAccessLogPublisher extends AccessLogPublisher<T> { protected final boolean isRequestLoggable(final Operation o) { return filter.isRequestLoggable(o); }  @Override final void close(); @Override final DN getDN();  }### Answer:
@Test public void testCriteriaFilterDefault() throws Exception { final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); final CriteriaFilter filter = new CriteriaFilter(cfg); final Operation operation = mockAnonymousSearchOperation(); assertThat(filter.isRequestLoggable(operation)).isTrue(); }
@Test public void testCriteriaFilterRequestTargetDNEqualTo() throws Exception { final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); when(cfg.getRequestTargetDNEqualTo()).thenReturn(newTreeSet("dc=com")); final CriteriaFilter filter = new CriteriaFilter(cfg); final SearchOperation operation = mockAnonymousSearchOperation(); when(operation.getBaseDN()).thenReturn(dn("dc=com"), dn("dc=org")); assertThat(filter.isRequestLoggable(operation)).isTrue(); assertThat(filter.isRequestLoggable(operation)).isFalse(); }
@Test public void testCriteriaFilterRequestTargetDNNotEqualTo() throws Exception { final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); when(cfg.getRequestTargetDNNotEqualTo()).thenReturn(newTreeSet("dc=com")); final CriteriaFilter filter = new CriteriaFilter(cfg); final SearchOperation operation = mockAnonymousSearchOperation(); when(operation.getBaseDN()).thenReturn(dn("dc=com"), dn("dc=org")); assertThat(filter.isRequestLoggable(operation)).isFalse(); assertThat(filter.isRequestLoggable(operation)).isTrue(); }
@Test public void testCriteriaFilterUserDNEqualTo() throws Exception { final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); when(cfg.getUserDNEqualTo()) .thenReturn(newTreeSet(dnOfUserInGroup().toString())); final CriteriaFilter filter = new CriteriaFilter(cfg); final SearchOperation operation1 = mockAuthenticatedSearchOperation(dnOfUserInGroup()); assertThat(filter.isRequestLoggable(operation1)).isTrue(); final SearchOperation operation2 = mockAuthenticatedSearchOperation(dnOfUserNotInGroup()); assertThat(filter.isRequestLoggable(operation2)).isFalse(); }
@Test public void testCriteriaFilterUserDNNotEqualTo() throws Exception { final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); when(cfg.getUserDNNotEqualTo()).thenReturn( newTreeSet(dnOfUserInGroup().toString())); final CriteriaFilter filter = new CriteriaFilter(cfg); final SearchOperation operation1 = mockAuthenticatedSearchOperation(dnOfUserInGroup()); assertThat(filter.isRequestLoggable(operation1)).isFalse(); final SearchOperation operation2 = mockAuthenticatedSearchOperation(dnOfUserNotInGroup()); assertThat(filter.isRequestLoggable(operation2)).isTrue(); }
@Test public void testCriteriaFilterUserIsMemberOf() throws Exception { final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); when(cfg.getUserIsMemberOf()).thenReturn(newTreeSet(dnOfGroup())); final CriteriaFilter filter = new CriteriaFilter(cfg); final SearchOperation operation1 = mockAuthenticatedSearchOperation(dnOfUserInGroup()); assertThat(filter.isRequestLoggable(operation1)).isTrue(); final SearchOperation operation2 = mockAuthenticatedSearchOperation(dnOfUserNotInGroup()); assertThat(filter.isRequestLoggable(operation2)).isFalse(); }
@Test public void testCriteriaFilterUserIsNotMemberOf() throws Exception { final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); when(cfg.getUserIsNotMemberOf()).thenReturn(newTreeSet(dnOfGroup())); final CriteriaFilter filter = new CriteriaFilter(cfg); final SearchOperation operation1 = mockAuthenticatedSearchOperation(dnOfUserInGroup()); assertThat(filter.isRequestLoggable(operation1)).isFalse(); final SearchOperation operation2 = mockAuthenticatedSearchOperation(dnOfUserNotInGroup()); assertThat(filter.isRequestLoggable(operation2)).isTrue(); }