test_class.declarator: urlSessionTracking
test_class.modifier: private
test_class.original_string: private UrlSessionTracking urlSessionTracking;
test_class.type: UrlSessionTracking
test_class.var_name: urlSessionTracking
test_class.file: session-replacement/src/test/java/com/amadeus/session/servlet/TestUrlSessionTracking.java
test_class.identifier: TestUrlSessionTracking
test_case.body: @Test
    public void testRetrieveId() {
      SessionConfiguration sc = new SessionConfiguration();
      sc.setSessionIdName("somesession");
      sc.setAttribute("com.amadeus.session.id", "uuid");
      urlSessionTracking.configure(sc);
      RequestWithSession request = mock(RequestWithSession.class, withSettings().extraInterfaces(HttpServletRequest.class));
      HttpServletRequest hsr = (HttpServletRequest)request;
      UUID uuid = UUID.randomUUID();
      when(hsr.getRequestURI()).thenReturn("/url;somesession="+uuid);
      SessionTracking.IdAndSource id = urlSessionTracking.retrieveId(request);
      assertNotNull(id);
      assertEquals(uuid.toString(), id.id);
      
      // Also test case in-sensitivity
      when(hsr.getRequestURI()).thenReturn("/url;SomeSession="+uuid);
      id = urlSessionTracking.retrieveId(request);
      assertNotNull("URL parameter case sensitivity test", id);
      assertEquals("URL parameter case sensitivity test", uuid.toString(), id.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.getPathInfo()).thenReturn(";somesession="+sessionIdWithTimestamp);
      when(hsr.getRequestURI()).thenReturn("/url;somesession="+sessionIdWithTimestamp);
      assertNull(urlSessionTracking.retrieveId(request));
      when(hsr.getPathInfo()).thenReturn(";somesession="+sessionIdWithoutTimestamp);
      when(hsr.getRequestURI()).thenReturn("/url;somesession="+sessionIdWithoutTimestamp);
      assertEquals(sessionIdWithoutTimestamp, urlSessionTracking.retrieveId(request).id);
      when(hsr.getPathInfo()).thenReturn(";somesession="+invalidSessionIdWithTimestamp);
      when(hsr.getRequestURI()).thenReturn("/url;somesession="+invalidSessionIdWithTimestamp);
      assertNull(urlSessionTracking.retrieveId(request));
  
      sc.setTimestampSufix(true);
      urlSessionTracking.configure(sc);
      when(hsr.getPathInfo()).thenReturn(";somesession="+sessionIdWithTimestamp);
      when(hsr.getRequestURI()).thenReturn("/url;somesession="+sessionIdWithTimestamp);
      assertEquals(sessionIdWithTimestamp, urlSessionTracking.retrieveId(request).id);
      when(hsr.getPathInfo()).thenReturn(";somesession="+sessionIdWithoutTimestamp);
      when(hsr.getRequestURI()).thenReturn("/url;somesession="+sessionIdWithoutTimestamp);
      assertEquals(sessionIdWithoutTimestamp, urlSessionTracking.retrieveId(request).id);
      when(hsr.getPathInfo()).thenReturn(";somesession="+invalidSessionIdWithTimestamp);
      when(hsr.getRequestURI()).thenReturn("/url;somesession="+invalidSessionIdWithTimestamp);
      assertNull(urlSessionTracking.retrieveId(request));
    }
test_case.class_method_signature: TestUrlSessionTracking.testRetrieveId()
test_case.full_signature: @Test public void testRetrieveId()
test_case.identifier: testRetrieveId
test_case.invocations: setSessionIdName setAttribute configure mock extraInterfaces withSettings randomUUID thenReturn when getRequestURI retrieveId assertNotNull assertEquals toString thenReturn when getRequestURI retrieveId assertNotNull assertEquals toString toString currentTimeMillis toString currentTimeMillis toString thenReturn when getPathInfo thenReturn when getRequestURI assertNull retrieveId thenReturn when getPathInfo thenReturn when getRequestURI assertEquals retrieveId thenReturn when getPathInfo thenReturn when getRequestURI assertNull retrieveId setTimestampSufix configure thenReturn when getPathInfo thenReturn when getRequestURI assertEquals retrieveId thenReturn when getPathInfo thenReturn when getRequestURI assertEquals retrieveId thenReturn when getPathInfo thenReturn when getRequestURI assertNull retrieveId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRetrieveId()
focal_class.declarator: sessionIdPathItem
focal_class.modifier: private
focal_class.original_string: private String sessionIdPathItem;
focal_class.type: String
focal_class.var_name: sessionIdPathItem
focal_class.file: session-replacement/src/main/java/com/amadeus/session/servlet/UrlSessionTracking.java
focal_class.identifier: UrlSessionTracking
focal_class.interfaces: implements SessionTracking
focal_class.class_method_signature: UrlSessionTracking.configure(SessionConfiguration configuration)
focal_class.full_signature: @Override public void configure(SessionConfiguration configuration)
focal_class.identifier: configure
focal_class.modifiers: @Override public
focal_class.parameters: (SessionConfiguration configuration)
focal_class.return: void
focal_class.signature: void configure(SessionConfiguration configuration)
focal_class.class_method_signature: UrlSessionTracking.retrieveId(RequestWithSession request)
focal_class.full_signature: @Override public IdAndSource retrieveId(RequestWithSession request)
focal_class.identifier: retrieveId
focal_class.modifiers: @Override public
focal_class.parameters: (RequestWithSession request)
focal_class.return: IdAndSource
focal_class.signature: IdAndSource retrieveId(RequestWithSession request)
focal_class.class_method_signature: UrlSessionTracking.propagateSession(RequestWithSession request, Object response)
focal_class.full_signature: @Override public void propagateSession(RequestWithSession request, Object response)
focal_class.identifier: propagateSession
focal_class.modifiers: @Override public
focal_class.parameters: (RequestWithSession request, Object response)
focal_class.return: void
focal_class.signature: void propagateSession(RequestWithSession request, Object response)
focal_class.class_method_signature: UrlSessionTracking.encodeUrl(RequestWithSession request, String url)
focal_class.full_signature: @Override public String encodeUrl(RequestWithSession request, String url)
focal_class.identifier: encodeUrl
focal_class.modifiers: @Override public
focal_class.parameters: (RequestWithSession request, String url)
focal_class.return: String
focal_class.signature: String encodeUrl(RequestWithSession request, String url)
focal_class.class_method_signature: UrlSessionTracking.isCookieTracking()
focal_class.full_signature: @Override public boolean isCookieTracking()
focal_class.identifier: isCookieTracking
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isCookieTracking()
focal_class.superclass: extends BaseSessionTracking
focal_method.body: @Override
    public IdAndSource retrieveId(RequestWithSession request) {
      String requestUri = ((HttpServletRequest)request).getRequestURI();
      int sessionIdStart = requestUri.toLowerCase().lastIndexOf(sessionIdPathItem);
      if (sessionIdStart > -1) {
        sessionIdStart += sessionIdPathItem.length();
        String sessionId = clean(requestUri.substring(sessionIdStart));
        if (sessionId != null) {
          return new IdAndSource(sessionId, isCookieTracking());
        } else {
          return null;
        }
      }
      if (this.nextSessionTracking != null) {
        return this.nextSessionTracking.retrieveId(request);
      }
      return null;
    }
focal_method.class_method_signature: UrlSessionTracking.retrieveId(RequestWithSession request)
focal_method.full_signature: @Override public IdAndSource retrieveId(RequestWithSession request)
focal_method.identifier: retrieveId
focal_method.invocations: getRequestURI lastIndexOf toLowerCase length clean substring isCookieTracking retrieveId
focal_method.modifiers: @Override public
focal_method.parameters: (RequestWithSession request)
focal_method.return: IdAndSource
focal_method.signature: IdAndSource retrieveId(RequestWithSession request)