Search in sources :

Example 1 with CreateApplicationEventResponse

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());
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) CreateApplicationEventResponse(com.hack23.cia.service.api.action.application.CreateApplicationEventResponse) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) Required(org.databene.contiperf.Required) PerfTest(org.databene.contiperf.PerfTest) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest) PerfTest(org.databene.contiperf.PerfTest)

Example 2 with CreateApplicationEventResponse

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);
    }
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) ApplicationActionEvent(com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent) CreateApplicationEventResponse(com.hack23.cia.service.api.action.application.CreateApplicationEventResponse) Date(java.util.Date)

Aggregations

ApplicationSession (com.hack23.cia.model.internal.application.system.impl.ApplicationSession)2 CreateApplicationEventResponse (com.hack23.cia.service.api.action.application.CreateApplicationEventResponse)2 ApplicationActionEvent (com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent)1 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)1 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)1 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)1 Date (java.util.Date)1 PerfTest (org.databene.contiperf.PerfTest)1 Required (org.databene.contiperf.Required)1 Test (org.junit.Test)1