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;
}
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);
}
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());
}
Aggregations