Search in sources :

Example 1 with CreateApplicationSessionResponse

use of com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse in project cia by Hack23.

the class AbstractServiceFunctionalIntegrationTest method createTestApplicationSession.

/**
 * Creates the test application session.
 *
 * @return the creates the application session request
 */
protected final CreateApplicationSessionRequest createTestApplicationSession() {
    final Random r = new Random();
    final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest();
    serviceRequest.setIpInformation(r.nextInt(256) + "." + r.nextInt(256) + "." + r.nextInt(256) + "." + r.nextInt(256));
    serviceRequest.setLocale("en_US.UTF-8");
    serviceRequest.setOperatingSystem("LINUX");
    serviceRequest.setSessionId(UUID.randomUUID().toString());
    serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS);
    serviceRequest.setUserAgentInformation("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0");
    final CreateApplicationSessionResponse response = (CreateApplicationSessionResponse) applicationManager.service(serviceRequest);
    assertNotNull(EXPECT_A_RESULT, response);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
    return serviceRequest;
}
Also used : Random(java.util.Random) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) CreateApplicationSessionResponse(com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse)

Example 2 with CreateApplicationSessionResponse

use of com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse in project cia by Hack23.

the class CreateApplicationSessionService method processService.

@Secured({ "ROLE_ANONYMOUS" })
@Override
public CreateApplicationSessionResponse processService(final CreateApplicationSessionRequest serviceRequest) {
    final ApplicationSession applicationSession = new ApplicationSession();
    applicationSession.setCreatedDate(new Date());
    applicationSession.setSessionId(serviceRequest.getSessionId());
    applicationSession.setIpInformation(serviceRequest.getIpInformation());
    applicationSession.setLocale(serviceRequest.getLocale());
    applicationSession.setTimeZone(serviceRequest.getTimeZone());
    applicationSession.setScreenSize(serviceRequest.getScreenSize());
    applicationSession.setOperatingSystem(serviceRequest.getOperatingSystem());
    applicationSession.setUserAgentInformation(serviceRequest.getUserAgentInformation());
    applicationSession.setSessionType(serviceRequest.getSessionType());
    applicationSession.setEvents(new ArrayList<>());
    applicationSession.setSessionType(ApplicationSessionType.ANONYMOUS);
    applicationSessionDAO.persist(applicationSession);
    LOGGER.info("Create application session:{}", applicationSession);
    return new CreateApplicationSessionResponse(ServiceResult.SUCCESS);
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) CreateApplicationSessionResponse(com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse) Date(java.util.Date) Secured(org.springframework.security.access.annotation.Secured)

Example 3 with CreateApplicationSessionResponse

use of com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse in project cia by Hack23.

the class CreateApplicationSessionServiceITest method serviceCreateApplicationSessionRequestSuccessTest.

/**
 * Service create application session request success test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void serviceCreateApplicationSessionRequestSuccessTest() throws Exception {
    setAuthenticatedAnonymousUser();
    final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest();
    serviceRequest.setIpInformation("8.8.8.8");
    serviceRequest.setLocale("en_US.UTF-8");
    serviceRequest.setOperatingSystem("LINUX");
    serviceRequest.setSessionId(UUID.randomUUID().toString());
    serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS);
    serviceRequest.setUserAgentInformation("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0");
    final CreateApplicationSessionResponse response = (CreateApplicationSessionResponse) applicationManager.service(serviceRequest);
    assertNotNull(EXPECT_A_RESULT, response);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
    final List<ApplicationSession> findListByProperty = applicationSessionDAO.findListByProperty(ApplicationSession_.sessionId, serviceRequest.getSessionId());
    assertEquals(1, findListByProperty.size());
    final ApplicationSession applicationSession = findListByProperty.get(0);
    assertNotNull(applicationSession);
    assertNotNull(applicationSession.getCreatedDate());
    assertEquals(serviceRequest.getIpInformation(), applicationSession.getIpInformation());
    assertEquals(serviceRequest.getOperatingSystem(), applicationSession.getOperatingSystem());
    assertEquals(serviceRequest.getLocale(), applicationSession.getLocale());
    assertEquals(serviceRequest.getUserAgentInformation(), applicationSession.getUserAgentInformation());
    assertEquals(serviceRequest.getSessionType(), applicationSession.getSessionType());
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) CreateApplicationSessionResponse(com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Aggregations

CreateApplicationSessionResponse (com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse)3 ApplicationSession (com.hack23.cia.model.internal.application.system.impl.ApplicationSession)2 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)2 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)1 Date (java.util.Date)1 Random (java.util.Random)1 Test (org.junit.Test)1 Secured (org.springframework.security.access.annotation.Secured)1