NotificationExpirationManagement implements RedisExpirationStrategy { Set<byte[]> getKeysToExpire(byte[] key) { if (!redis.supportsMultiSpop()) { return redis.transaction(key, smembersAndDel(key)).get(); } else { Set<byte[]> res = redis.spop(key, SPOP_BULK_SIZE); if (res == null || res.isEmpty() || res.size() < SPOP_BULK_SIZE) { redis.del(key); } return res; } } 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);  }
@SuppressWarnings("unchecked") @Test public void testGetKeysToExpire() { Set<byte[]> expected = Collections.singleton(new byte[] { 1 }); RedisFacade.ResponseFacade<Object> value = mock(RedisFacade.ResponseFacade.class); when(value.get()).thenReturn(expected); when(redis.transaction(eq(encode("Test")), any(TransactionRunner.class))).thenReturn(value); Set<byte[]> result = expiration.getKeysToExpire(encode("Test")); assertSame(expected, result); verify(redis).transaction(eq(encode("Test")), any(TransactionRunner.class)); }