### Question:
BloomFilterSessionBlacklist implements SessionBlacklist { @Override public boolean isBlacklisted(final Session session) throws SessionException { DEBUG.message("BloomFilterSessionBlacklist: checking blacklist"); boolean blacklisted = false; if (bloomFilter.mightContain(SessionBlacklistEntry.from(session, serviceConfig.getSessionBlacklistPurgeDelay(TimeUnit.MILLISECONDS)))) { blacklisted = delegate.isBlacklisted(session); } return blacklisted; } @VisibleForTesting  BloomFilterSessionBlacklist(final SessionBlacklist delegate,
                                final SessionServiceConfig serviceConfig,
                                final BloomFilter<SessionBlacklistEntry> bloomFilter);  BloomFilterSessionBlacklist(final SessionBlacklist delegate,
                                       final SessionServiceConfig serviceConfig); @Override void blacklist(final Session session); @Override boolean isBlacklisted(final Session session); @Override void subscribe(final Listener listener);  }### Answer:
@Test public void shouldNotCheckDelegateIfSessionNotInBloomFilter() throws Exception { String id = "testSession"; long expiryTime = 1234l; given(mockSession.getStableStorageID()).willReturn(id); given(mockSession.getBlacklistExpiryTime(PURGE_DELAY)).willReturn(expiryTime); given(mockBloomFilter.mightContain(new BloomFilterSessionBlacklist.SessionBlacklistEntry(id, expiryTime))) .willReturn(false); boolean result = testBlacklist.isBlacklisted(mockSession); assertThat(result).isFalse(); verify(mockDelegate, never()).isBlacklisted(any(Session.class)); }
@Test public void shouldCheckDelegateIfSessionIsInBloomFilter() throws Exception { String id = "testSession"; long expiryTime = 1234l; given(mockSession.getStableStorageID()).willReturn(id); given(mockSession.getBlacklistExpiryTime(PURGE_DELAY)).willReturn(expiryTime); given(mockBloomFilter.mightContain(new BloomFilterSessionBlacklist.SessionBlacklistEntry(id, expiryTime))) .willReturn(true); given(mockDelegate.isBlacklisted(mockSession)).willReturn(true); boolean result = testBlacklist.isBlacklisted(mockSession); assertThat(result).isTrue(); verify(mockDelegate).isBlacklisted(mockSession); }