use of com.hack23.cia.service.api.action.admin.ManageUserAccountRequest in project cia by Hack23.
the class ManageUserAccountServiceITest method manageUserAccountSuccessUnLockTest.
@Test
public void manageUserAccountSuccessUnLockTest() 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.UNLOCK);
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(1, allByAfterDelete.size());
assertEquals(allByAfterDelete.get(0).getUserLockStatus(), UserLockStatus.UNLOCKED);
}
use of com.hack23.cia.service.api.action.admin.ManageUserAccountRequest in project cia by Hack23.
the class ManageUserAccountServiceITest method manageUserAccountFailureTest.
@Test
public void manageUserAccountFailureTest() throws Exception {
final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
final ManageUserAccountRequest serviceRequest = new ManageUserAccountRequest();
serviceRequest.setSessionId(createSessionRequest.getSessionId());
final ManageUserAccountResponse response = (ManageUserAccountResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, response);
assertEquals(ServiceResult.FAILURE, response.getResult());
assertEquals("accountOperation must not be null, userAcountId must not be null", response.getErrorMessage());
}
use of com.hack23.cia.service.api.action.admin.ManageUserAccountRequest in project cia by Hack23.
the class ManageUserAccountService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final ManageUserAccountRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.ADMIN);
eventRequest.setApplicationOperation(ApplicationOperationType.UPDATE);
eventRequest.setActionName(ManageUserAccountRequest.class.getSimpleName());
eventRequest.setSessionId(serviceRequest.getSessionId());
return eventRequest;
}
use of com.hack23.cia.service.api.action.admin.ManageUserAccountRequest in project cia by Hack23.
the class ManageUserAccountClickListener method buttonClick.
@Override
public void buttonClick(final ClickEvent event) {
final ServiceResponse response = ApplicationMangerAccess.getApplicationManager().service(manageUserAccountRequest);
if (ServiceResult.SUCCESS == response.getResult()) {
LOGGER.info(LOG_MSG, manageUserAccountRequest.getUserAcountId());
Notification.show(OPERATION_COMPLETED);
} else {
Notification.show(OPERATION_FAILED, response.getErrorMessage(), Notification.Type.WARNING_MESSAGE);
LOGGER.info(OPERATION_FAILURE, manageUserAccountRequest.getUserAcountId());
}
}
use of com.hack23.cia.service.api.action.admin.ManageUserAccountRequest in project cia by Hack23.
the class AdminUserAccountPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout content = createPanelContent();
final String pageId = getPageId(parameters);
final int pageNr = getPageNr(parameters);
getMenuItemFactory().createMainPageMenuBar(menuBar);
LabelFactory.createHeader2Label(content, ADMIN_USERACCOUNT);
final DataContainer<UserAccount, Long> dataContainer = getApplicationManager().getDataContainer(UserAccount.class);
final List<UserAccount> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, UserAccount_.createdDate);
createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
getGridFactory().createBasicBeanItemGrid(content, UserAccount.class, pageOrderBy, USER_ACCOUNT, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
if (pageId != null && !pageId.isEmpty()) {
final UserAccount userAccount = dataContainer.load(Long.valueOf(pageId));
if (userAccount != null) {
getFormFactory().addFormPanelTextFields(content, userAccount, UserAccount.class, AS_LIST);
final VerticalLayout overviewLayout = new VerticalLayout();
overviewLayout.setSizeFull();
content.addComponent(overviewLayout);
content.setExpandRatio(overviewLayout, ContentRatio.LARGE);
final ResponsiveRow grid = createGridLayout(overviewLayout);
for (final AccountOperation accountOperation : ManageUserAccountRequest.AccountOperation.values()) {
final ManageUserAccountRequest request = new ManageUserAccountRequest();
request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
request.setAccountOperation(accountOperation);
request.setUserAcountId(userAccount.getUserId());
final Button accountOperationButton = new Button(MessageFormat.format(BUTTON_PATTERN, accountOperation), VaadinIcons.BULLSEYE);
accountOperationButton.addClickListener(new ManageUserAccountClickListener(request));
accountOperationButton.setId(MessageFormat.format(BUTTON_ID_PATTERN, ViewAction.START_AGENT_BUTTON, accountOperation));
createRowItem(grid, accountOperationButton, "Will perform useraccount action");
}
}
}
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_USERACCOUNT_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
return content;
}
Aggregations