### Question:
CTSSessionBlacklist implements SessionBlacklist { @Override public void blacklist(final Session session) throws SessionException { DEBUG.message("CTSSessionBlacklist: Blacklisting session: {}", session); try { final Token token = new Token(session.getStableStorageID(), TokenType.SESSION_BLACKLIST); token.setExpiryTimestamp(timeOf(session.getBlacklistExpiryTime(purgeDelayMs))); token.setAttribute(BLACKLIST_TIME_FIELD, now()); token.setAttribute(SERVER_ID_FIELD, localServerId); cts.create(token); } catch (CoreTokenException ex) { DEBUG.error("CTSSessionBlacklist: Error blacklisting session", ex); throw new SessionException(ex); } notifyListeners(session); } @Inject  CTSSessionBlacklist(final CTSPersistentStore cts,
                               final @Named(CoreTokenConstants.CTS_SCHEDULED_SERVICE) ScheduledExecutorService scheduler,
                               final ThreadMonitor threadMonitor,
                               final SessionServerConfig serverConfig,
                               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 shouldStoreBlacklistedSessionsInCts() throws Exception { given(mockSession.getBlacklistExpiryTime(anyLong())).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); }
@Test(expectedExceptions = SessionException.class) public void shouldPropagateSessionExceptions() throws Exception { given(mockSession.getBlacklistExpiryTime(anyLong())).willThrow(new SessionException("test")); testBlacklist.blacklist(mockSession); }
@Test(expectedExceptions = SessionException.class) public void shouldConvertCtsExceptions() throws Exception { given(mockSession.getTimeLeft()).willReturn(3l); willThrow(new CoreTokenException("test")).given(mockCts).create(any(Token.class)); testBlacklist.blacklist(mockSession); }