@Test
public void testRetrieveId() {

  SessionConfiguration sc = new SessionConfiguration();
  sc.setSessionIdName("somesession");
  sc.setAttribute("com.amadeus.session.id", "uuid");
  cookieSessionTracking.configure(sc);
  RequestWithSession request = mock(RequestWithSession.class,
      withSettings().extraInterfaces(HttpServletRequest.class));
  HttpServletRequest hsr = (HttpServletRequest)request;
  UUID uuid = UUID.randomUUID();
  UUID uuidUrl = UUID.randomUUID();
  when(hsr.getRequestURI()).thenReturn("/url;somesession=" + uuidUrl);
  when(hsr.getCookies()).thenReturn(new Cookie[] { new Cookie("somesession", uuid.toString()) });
  assertEquals(uuid.toString(), cookieSessionTracking.retrieveId(request).id);
  when(hsr.getCookies()).thenReturn(new Cookie[] { new Cookie("notused", uuid.toString()) });
  assertNull(cookieSessionTracking.retrieveId(request));
  when(hsr.getCookies()).thenReturn(new Cookie[] {
      new Cookie("othercookie", "ABC"),
      new Cookie("somesession", uuid.toString())
      });
  assertEquals(uuid.toString(), cookieSessionTracking.retrieveId(request).id);
  String sessionIdWithTimestamp = uuid.toString() + BaseSessionTracking.SESSION_ID_TIMESTAMP_SEPARATOR + System.currentTimeMillis();
  String invalidSessionIdWithTimestamp = uuid.toString() + "-abcdefgh" + BaseSessionTracking.SESSION_ID_TIMESTAMP_SEPARATOR + System.currentTimeMillis();
  String sessionIdWithoutTimestamp = uuid.toString();
  when(hsr.getCookies()).thenReturn(new Cookie[] { new Cookie("somesession", sessionIdWithTimestamp)});
  assertNull(cookieSessionTracking.retrieveId(request));
  when(hsr.getCookies()).thenReturn(new Cookie[] { new Cookie("somesession", sessionIdWithoutTimestamp)});
  assertEquals(sessionIdWithoutTimestamp, cookieSessionTracking.retrieveId(request).id);
  sc.setTimestampSufix(true);
  cookieSessionTracking.configure(sc);
  when(hsr.getCookies()).thenReturn(new Cookie[] { new Cookie("somesession", sessionIdWithTimestamp)});
  assertEquals(sessionIdWithTimestamp, cookieSessionTracking.retrieveId(request).id);
  when(hsr.getCookies()).thenReturn(new Cookie[] { new Cookie("somesession", sessionIdWithoutTimestamp)});
  assertEquals(sessionIdWithoutTimestamp, cookieSessionTracking.retrieveId(request).id);
  when(hsr.getCookies()).thenReturn(new Cookie[] { new Cookie("somesession", invalidSessionIdWithTimestamp)});
  assertNull(cookieSessionTracking.retrieveId(request));
}