### Question:
CTSBlacklist implements Blacklist<T> { @Override public void blacklist(T entry) throws BlacklistException { DEBUG.message("CTSBlacklist: Blacklisting entry: {}", entry); try { final Token token = new Token(entry.getStableStorageID(), tokenType); token.setExpiryTimestamp(timeOf(entry.getBlacklistExpiryTime() + purgeDelayMs)); token.setAttribute(BLACKLIST_TIME_FIELD, now()); token.setAttribute(SERVER_ID_FIELD, localServerId); cts.create(token); } catch (CoreTokenException ex) { DEBUG.error("CTSBlacklist: Error blacklisting entry", ex); throw new BlacklistException(ex); } notifyListeners(entry); } @Inject  CTSBlacklist(CTSPersistentStore cts, TokenType tokenType,
            @Named(CoreTokenConstants.CTS_SCHEDULED_SERVICE) ScheduledExecutorService scheduler,
            ThreadMonitor threadMonitor, WebtopNamingQuery serverConfig, long purgeDelayMs, long pollIntervalMs); @Override void blacklist(T entry); @Override boolean isBlacklisted(T entry); @Override void subscribe(final Listener listener);  }### Answer:
@Test public void shouldStoreBlacklistedSessionsInCts() throws Exception { given(mockSession.getBlacklistExpiryTime()).willReturn(1234L); testBlacklist.blacklist(mockSession); ArgumentCaptor<Token> storedToken = ArgumentCaptor.forClass(Token.class); verify(mockCts).create(storedToken.capture()); assertThat(storedToken.getValue().getTokenId()).isEqualTo(SID); assertThat(storedToken.getValue().getType()).isEqualTo(TokenType.SESSION_BLACKLIST); assertThat(storedToken.getValue().getExpiryTimestamp().getTimeInMillis()).isEqualTo(1234L + PURGE_DELAY); }
@Test public void shouldPropagateSessionExceptions() throws Exception { given(mockSession.getBlacklistExpiryTime()).willThrow(new BlacklistException("test")); assertThatThrownBy( new ThrowableAssert.ThrowingCallable() { @Override public void call() throws Throwable { testBlacklist.blacklist(mockSession); } }) .isInstanceOf(BlacklistException.class); }
@Test public void shouldConvertCtsExceptions() throws Exception { given(mockSession.getTimeLeft()).willReturn(3L); willThrow(new CoreTokenException("test")).given(mockCts).create(any(Token.class)); assertThatThrownBy( new ThrowableAssert.ThrowingCallable() { @Override public void call() throws Throwable { testBlacklist.blacklist(mockSession); } }) .isInstanceOf(BlacklistException.class); }