use of com.hack23.cia.service.api.action.application.CreateApplicationEventResponse in project cia by Hack23.
the class CreateApplicationEventServiceITest method serviceCreateApplicationEventRequestSuccessTest.
/**
* Service create application event request success test.
*
* @throws Exception
* the exception
*/
@Test
@PerfTest(threads = 4, duration = 3000, warmUp = 1500)
@Required(max = 1000, average = 400, percentile95 = 450, throughput = 10)
public void serviceCreateApplicationEventRequestSuccessTest() throws Exception {
setAuthenticatedAnonymousUser();
final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
final CreateApplicationEventRequest serviceRequest = new CreateApplicationEventRequest();
serviceRequest.setSessionId(createSessionRequest.getSessionId());
serviceRequest.setApplicationMessage("applicationMessage");
serviceRequest.setEventGroup(ApplicationEventGroup.USER);
serviceRequest.setApplicationOperation(ApplicationOperationType.CREATE);
serviceRequest.setPage("Test");
serviceRequest.setPageMode("PageMode");
serviceRequest.setElementId("ElementId");
serviceRequest.setActionName("Content");
serviceRequest.setApplicationMessage("applicationMessage");
serviceRequest.setErrorMessage("errorMessage");
final CreateApplicationEventResponse response = (CreateApplicationEventResponse) 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);
assertEquals(1, applicationSession.getEvents().size());
}
use of com.hack23.cia.service.api.action.application.CreateApplicationEventResponse in project cia by Hack23.
the class CreateApplicationEventService method processService.
@Override
public CreateApplicationEventResponse processService(final CreateApplicationEventRequest serviceRequest) {
final CreateApplicationEventResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final ApplicationSession applicationSession = applicationSessionDAO.findFirstByProperty(ApplicationSession_.sessionId, serviceRequest.getSessionId());
if (applicationSession != null) {
final ApplicationActionEvent applicationActionEvent = new ApplicationActionEvent();
applicationActionEvent.setEventGroup(serviceRequest.getEventGroup());
applicationActionEvent.setCreatedDate(new Date());
applicationActionEvent.setSessionId(serviceRequest.getSessionId());
applicationActionEvent.setPage(serviceRequest.getPage());
applicationActionEvent.setPageMode(serviceRequest.getPageMode());
applicationActionEvent.setElementId(serviceRequest.getElementId());
applicationActionEvent.setApplicationOperation(serviceRequest.getApplicationOperation());
applicationActionEvent.setActionName(serviceRequest.getActionName());
applicationActionEvent.setUserId(serviceRequest.getUserId());
if (serviceRequest.getUserId() != null && ApplicationSessionType.ANONYMOUS == applicationSession.getSessionType()) {
applicationSession.setSessionType(ApplicationSessionType.REGISTERED_USER);
applicationSession.setUserId(serviceRequest.getUserId());
}
applicationActionEvent.setApplicationMessage(serviceRequest.getApplicationMessage());
applicationActionEvent.setErrorMessage(serviceRequest.getErrorMessage());
applicationSession.getEvents().add(applicationActionEvent);
applicationSessionDAO.persist(applicationSession);
return new CreateApplicationEventResponse(ServiceResult.SUCCESS);
} else {
return new CreateApplicationEventResponse(ServiceResult.FAILURE);
}
}
Aggregations