@Test
public void testSetSessionAttribute() {

  RedisFacade facade = mock(RedisFacade.class);
  SessionManager sm = mock(SessionManager.class);
  SessionConfiguration conf = new SessionConfiguration();
  when(sm.getConfiguration()).thenReturn(conf);
  when(sm.getMetrics()).thenReturn(new MetricRegistry());
  JdkSerializerDeserializer serializer = new JdkSerializerDeserializer();
  when(sm.getSerializerDeserializer()).thenReturn(serializer);
  serializer.setSessionManager(sm);
  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.setSessionAttribute(sessionData, "attr", "value");
    verify(facade).hset(rsr.sessionKey("id"), encode("attr"), serializer.serialize("value"));
  }
}