@Test
public void testGetSessionExpiredValid() {

  SessionData sessionData = new SessionData("2", now(), 10);
  RepositoryBackedSession session = mock(RepositoryBackedSession.class);
  when(session.getId()).thenReturn("2");
  when(session.isExpired()).thenReturn(true);
  when(session.isValid()).thenReturn(true);
  when(repository.getSessionData("2")).thenReturn(sessionData);
  when(factory.build(sessionData)).thenReturn(session);
  RequestWithSession request = mock(RequestWithSession.class);
  when(request.getRequestedSessionId()).thenReturn("2");
  when(request.isIdRetrieved()).thenReturn(true);
  RepositoryBackedSession retrievedSession = sessionManager.getSession(request, false, null);
  verify(session).doInvalidate(true);
  assertNull(retrievedSession);
}