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