Search in sources :

Example 16 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class ApplicationSessionDAOITest method createApplicationSession.

private ApplicationSession createApplicationSession() {
    final ApplicationSession applicationSession = new ApplicationSession();
    applicationSession.withCreatedDate(new Date()).withIpInformation(UUID.randomUUID().toString()).withLocale("Locale").withSessionId(UUID.randomUUID().toString());
    applicationSessionDAO.persist(applicationSession);
    return applicationSession;
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) Date(java.util.Date)

Example 17 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class ApplicationSessionDAOITest method findListByPropertyInListTest.

/**
 * Find list by property in list test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void findListByPropertyInListTest() throws Exception {
    final ApplicationSession applicationSession = createApplicationSession();
    List<ApplicationSession> list = applicationSessionDAO.findListByPropertyInList(ApplicationSession_.sessionId, new Object[] { applicationSession.getSessionId() });
    assertNotNull(list);
    assertEquals(applicationSession, list.iterator().next());
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) Test(org.junit.Test)

Example 18 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class ApplicationSessionDAOITest method persistTest.

/**
 * Persist test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void persistTest() throws Exception {
    final ApplicationSession applicationSession = createApplicationSession();
    ApplicationSession loaddedApplicationSession = applicationSessionDAO.load(applicationSession.getHjid());
    assertNotNull(loaddedApplicationSession);
    assertEquals(applicationSession, loaddedApplicationSession);
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) Test(org.junit.Test)

Example 19 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class ManageUserAccountServiceITest method manageUserAccountSuccessDeleteTest.

@Test
public void manageUserAccountSuccessDeleteTest() throws Exception {
    setAuthenticatedAnonymousUser();
    final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
    final RegisterUserRequest createAccountRequest = new RegisterUserRequest();
    createAccountRequest.setCountry("Sweden");
    createAccountRequest.setUsername(UUID.randomUUID().toString());
    createAccountRequest.setEmail(createAccountRequest.getUsername() + "@email.com");
    createAccountRequest.setUserpassword("Userpassword1!");
    createAccountRequest.setUserType(UserType.PRIVATE);
    createAccountRequest.setSessionId(createSessionRequest.getSessionId());
    final RegisterUserResponse response = (RegisterUserResponse) applicationManager.service(createAccountRequest);
    assertNotNull("Expect a result", response);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
    setAuthenticatedAdminuser();
    final DataContainer<UserAccount, Long> userContainer = applicationManager.getDataContainer(UserAccount.class);
    final List<UserAccount> firstCreatedUsed = userContainer.getAllBy(UserAccount_.username, createAccountRequest.getUsername());
    assertEquals(1, firstCreatedUsed.size());
    final ManageUserAccountRequest deleteAccountRequest = new ManageUserAccountRequest();
    deleteAccountRequest.setSessionId(createSessionRequest.getSessionId());
    deleteAccountRequest.setAccountOperation(AccountOperation.DELETE);
    deleteAccountRequest.setUserAcountId(firstCreatedUsed.get(0).getUserId());
    final ManageUserAccountResponse deleteAccountResponse = (ManageUserAccountResponse) applicationManager.service(deleteAccountRequest);
    assertNotNull(EXPECT_A_RESULT, deleteAccountResponse);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, deleteAccountResponse.getResult());
    final List<UserAccount> allByAfterDelete = userContainer.getAllBy(UserAccount_.username, createAccountRequest.getUsername());
    assertEquals(0, allByAfterDelete.size());
    final DataContainer<ApplicationActionEvent, Long> eventContainer = applicationManager.getDataContainer(ApplicationActionEvent.class);
    final List<ApplicationActionEvent> events = eventContainer.getAllBy(ApplicationActionEvent_.userId, firstCreatedUsed.get(0).getUserId());
    assertEquals(0, events.size());
    final DataContainer<ApplicationSession, Serializable> sessionContainer = applicationManager.getDataContainer(ApplicationSession.class);
    final List<ApplicationSession> sessions = sessionContainer.getAllBy(ApplicationSession_.userId, firstCreatedUsed.get(0).getUserId());
    assertEquals(0, sessions.size());
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) Serializable(java.io.Serializable) RegisterUserRequest(com.hack23.cia.service.api.action.application.RegisterUserRequest) ApplicationActionEvent(com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) ManageUserAccountRequest(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest) RegisterUserResponse(com.hack23.cia.service.api.action.application.RegisterUserResponse) ManageUserAccountResponse(com.hack23.cia.service.api.action.admin.ManageUserAccountResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Example 20 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession 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

ApplicationSession (com.hack23.cia.model.internal.application.system.impl.ApplicationSession)21 Test (org.junit.Test)14 Date (java.util.Date)5 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)4 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)4 Secured (org.springframework.security.access.annotation.Secured)4 ApplicationActionEvent (com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent)3 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)2 CreateApplicationEventResponse (com.hack23.cia.service.api.action.application.CreateApplicationEventResponse)2 CreateApplicationSessionResponse (com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 PerfTest (org.databene.contiperf.PerfTest)2 Required (org.databene.contiperf.Required)2 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)1 ManageUserAccountRequest (com.hack23.cia.service.api.action.admin.ManageUserAccountRequest)1 ManageUserAccountResponse (com.hack23.cia.service.api.action.admin.ManageUserAccountResponse)1 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)1 DestroyApplicationSessionRequest (com.hack23.cia.service.api.action.application.DestroyApplicationSessionRequest)1 DestroyApplicationSessionResponse (com.hack23.cia.service.api.action.application.DestroyApplicationSessionResponse)1 RegisterUserRequest (com.hack23.cia.service.api.action.application.RegisterUserRequest)1