RedisSessionRepository implements SessionRepository { @Override public void storeSessionData(SessionData sessionData) { Map<byte[], byte[]> attributes = new HashMap<>(); addInt(attributes, MAX_INACTIVE_INTERVAL, sessionData.getMaxInactiveInterval()); addLong(attributes, LAST_ACCESSED, sessionData.getLastAccessedTime()); addLong(attributes, CREATION_TIME, sessionData.getCreationTime()); if (sessionManager.getConfiguration().isSticky()) { attributes.put(OWNER_NODE, ownerByteArray); } redis.hmset(sessionKey(sessionData.getId()), attributes); expirationManager.sessionTouched(sessionData); } RedisSessionRepository(RedisFacade redis, String namespace, String owner, ExpirationStrategy strategy,
      boolean sticky); @Override void setSessionManager(final SessionManager sessionManager); @Override SessionData getSessionData(String id); @Override CommitTransaction startCommit(SessionData session); @Override void remove(SessionData session); byte[] sessionKey(String sessionId); @Override Object getSessionAttribute(SessionData session, String attribute); @Override boolean prepareRemove(SessionData session); @Override Set<String> getAllKeys(SessionData session); @Override void storeSessionData(SessionData sessionData); @Override void requestFinished(); @Override void setSessionAttribute(SessionData session, String name, Object value); @Override void removeSessionAttribute(SessionData session, String name); @Override boolean cleanSessionsOnShutdown(); @Override Collection<String> getOwnedSessionIds(); @Override void close(); @Override void reset(); @Override void sessionIdChange(SessionData sessionData); @Override boolean isConnected();  }
@SuppressWarnings("unchecked") @Test public void testStoreSessionData() { RedisFacade facade = mock(RedisFacade.class); SessionManager sm = mock(SessionManager.class); JdkSerializerDeserializer serializer = new JdkSerializerDeserializer(); when(sm.getSerializerDeserializer()).thenReturn(serializer); SessionConfiguration conf = new SessionConfiguration(); when(sm.getConfiguration()).thenReturn(conf); try (RedisSessionRepository rsr = new RedisSessionRepository(facade, "myapp", "localhost", ExpirationStrategy.ZRANGE, false)) { rsr.setSessionManager(sm); SessionData sessionData = mock(SessionData.class); when(sessionData.getId()).thenReturn("id"); rsr.storeSessionData(sessionData); @SuppressWarnings("rawtypes") ArgumentCaptor<Map> map = ArgumentCaptor.forClass(Map.class); verify(facade).hmset(eq(rsr.sessionKey("id")), map.capture()); } }