NotificationExpirationManagement implements RedisExpirationStrategy { @Override public void sessionDeleted(SessionData session) { long expireCleanupInstant = roundUpToNextMinute(session.expiresAt()); byte[] expireKey = getExpirationsKey(expireCleanupInstant); redis.srem(expireKey, repository.sessionKey(session.getId())); byte[] sessionExpireKey = getSessionExpireKey(session.getId()); redis.del(sessionExpireKey); } NotificationExpirationManagement(RedisFacade redis, RedisSessionRepository redisSession, String namespace,
      String owner, String keyPrefix, boolean sticky); @Override void sessionDeleted(SessionData session); @Override void sessionTouched(SessionData session); @Override void startExpiredSessionsTask(final SessionManager sessionManager); @Override void close(); void reset(); @Override void sessionIdChange(SessionData session);  }
@Test public void testSessionDeleted() { expiration.sessionDeleted(session); ArgumentCaptor<byte[]> captureExpireKey = ArgumentCaptor.forClass(byte[].class); ArgumentCaptor<byte[]> captureSessionKey = ArgumentCaptor.forClass(byte[].class); verify(redis).srem(captureExpireKey.capture(), captureSessionKey.capture()); assertEquals("prefixexpirations:60000", SafeEncoder.encode(captureExpireKey.getValue())); assertEquals("key:{1}", SafeEncoder.encode(captureSessionKey.getValue())); ArgumentCaptor<byte[]> captureSessionExpireKey = ArgumentCaptor.forClass(byte[].class); verify(redis).del(captureSessionExpireKey.capture()); assertEquals("com.amadeus.session:expire::test:{1}", SafeEncoder.encode(captureSessionExpireKey.getValue())); }
@Test public void testSessionDeletedIn2Minutes() { session = new SessionData("1", 100, 70); expiration.sessionDeleted(session); ArgumentCaptor<byte[]> captureExpireKey = ArgumentCaptor.forClass(byte[].class); ArgumentCaptor<byte[]> captureSessionKey = ArgumentCaptor.forClass(byte[].class); verify(redis).srem(captureExpireKey.capture(), captureSessionKey.capture()); assertEquals("prefixexpirations:120000", SafeEncoder.encode(captureExpireKey.getValue())); }