### Question:
BloomFilterBlacklist implements Blacklist<T> { @Override public boolean isBlacklisted(T entry) throws BlacklistException { DEBUG.message("BloomFilterBlacklist: checking blacklist"); boolean blacklisted = false; if (bloomFilter.mightContain(BlacklistEntry.from(entry, purgeDelayMs))) { blacklisted = delegate.isBlacklisted(entry); } return blacklisted; } @VisibleForTesting  BloomFilterBlacklist(Blacklist<T> delegate, long purgeDelayMs, final BloomFilter<BlacklistEntry> bloomFilter);  BloomFilterBlacklist(Blacklist<T> delegate, long purgeDelayMs); @Override void blacklist(T entry); @Override boolean isBlacklisted(T entry); @Override void subscribe(Listener listener);  }### Answer:
@Test public void shouldNotCheckDelegateIfSessionNotInBloomFilter() throws Exception { String id = "testSession"; long expiryTime = 1234l; given(mockSession.getStableStorageID()).willReturn(id); given(mockSession.getBlacklistExpiryTime()).willReturn(expiryTime); given(mockBloomFilter.mightContain(new BloomFilterBlacklist.BlacklistEntry(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()).willReturn(expiryTime); given(mockBloomFilter.mightContain(new BloomFilterBlacklist.BlacklistEntry(id, expiryTime + PURGE_DELAY))) .willReturn(true); given(mockDelegate.isBlacklisted(mockSession)).willReturn(true); boolean result = testBlacklist.isBlacklisted(mockSession); assertThat(result).isTrue(); verify(mockDelegate).isBlacklisted(mockSession); }