use of org.asqatasun.webapp.command.CreateUserCommand in project Asqatasun by Asqatasun.
the class UserManagementControllerTest method testSubmitEditCurrentUserForm.
/**
* Test of submitEditUserForm method, of class UserManagementController.
*/
public void testSubmitEditCurrentUserForm() throws Exception {
System.out.println("testSubmitEditCurrentUserForm");
instance = new UserManagementController();
setUpMockRoleDataService();
setUpMockUserDataService(false, false, false, false, true);
setUpMockAuthenticationContext();
instance.setUserDataService(mockUserDataService);
CreateUserFormValidator createUserFormValidator = new CreateUserFormValidator();
createUserFormValidator.setUserDataService(mockUserDataService);
instance.setCreateUserFormValidator(createUserFormValidator);
// Finally the form is conform and the admin page is returned
CreateUserCommand createUserCommand = CreateUserCommandFactory.getInstance().getNewCreateUserCommand();
createUserCommand.setEmail("admin@test.com");
createUserCommand.setLastName("newName");
createUserCommand.setFirstName("newFirstName");
createUserCommand.setPhoneNumber("0102030405");
createUserCommand.setActivated(false);
createUserCommand.setAdmin(false);
MockHttpServletRequest request = new MockHttpServletRequest();
request.getSession().setAttribute(TgolKeyStore.USER_ID_KEY, Long.valueOf(4));
BindingResult bindingResult = new BeanPropertyBindingResult(createUserCommand, "createUserCommand");
Model model = new ExtendedModelMap();
String result = instance.submitEditUserForm(createUserCommand, bindingResult, request, model);
assertEquals(TgolKeyStore.ADMIN_VIEW_NAME, result);
assertFalse(bindingResult.hasErrors());
assertTrue(bindingResult.getFieldErrors().isEmpty());
assertEquals(2, model.asMap().size());
assertEquals("admin@test.com", model.asMap().get(TgolKeyStore.UPDATED_USER_NAME_KEY));
assertTrue(((List<User>) model.asMap().get(TgolKeyStore.USER_LIST_KEY)).isEmpty());
}
use of org.asqatasun.webapp.command.CreateUserCommand in project Asqatasun by Asqatasun.
the class UserManagementControllerTest method testSubmitAddAdminUserForm.
/**
* Test of submitAddUserForm method, of class UserManagementController.
*/
public void testSubmitAddAdminUserForm() throws Exception {
System.out.println("SubmitAddAdminUserForm");
instance = new UserManagementController();
setUpMockRoleDataService();
setUpMockUserDataService(false, true, true, false, false);
setUpMockAuthenticationContext();
instance.setUserDataService(mockUserDataService);
CreateUserFormValidator createUserFormValidator = new CreateUserFormValidator();
createUserFormValidator.setUserDataService(mockUserDataService);
instance.setCreateUserFormValidator(createUserFormValidator);
// Finally the form is conform and the admin page is returned
CreateUserCommand createUserCommand = CreateUserCommandFactory.getInstance().getNewCreateUserCommand();
createUserCommand.setSiteUrl("http://www.newSite.com/");
createUserCommand.setEmail("newUser@test.com");
createUserCommand.setPassword("P4sSw0rD");
createUserCommand.setConfirmPassword("P4sSw0rD");
createUserCommand.setAdmin(true);
createUserCommand.setActivated(true);
BindingResult bindingResult = new BeanPropertyBindingResult(createUserCommand, "createUserCommand");
Model model = new ExtendedModelMap();
String result = instance.submitAddUserForm(createUserCommand, bindingResult, model);
assertEquals(TgolKeyStore.ADMIN_VIEW_NAME, result);
assertFalse(bindingResult.hasErrors());
assertTrue(bindingResult.getFieldErrors().isEmpty());
assertEquals(2, model.asMap().size());
assertEquals("newUser@test.com", model.asMap().get(TgolKeyStore.ADDED_USER_NAME_KEY));
assertTrue(((List<User>) model.asMap().get(TgolKeyStore.USER_LIST_KEY)).isEmpty());
}
use of org.asqatasun.webapp.command.CreateUserCommand in project Asqatasun by Asqatasun.
the class UserManagementControllerTest method testSubmitAddUserForm.
/**
* Test of submitAddUserForm method, of class UserManagementController.
*/
public void testSubmitAddUserForm() throws Exception {
System.out.println("submitAddUserForm");
instance = new UserManagementController();
setUpMockRoleDataService();
setUpMockUserDataService(false, true, false, false, false);
setUpMockAuthenticationContext();
instance.setUserDataService(mockUserDataService);
CreateUserFormValidator createUserFormValidator = new CreateUserFormValidator();
createUserFormValidator.setUserDataService(mockUserDataService);
instance.setCreateUserFormValidator(createUserFormValidator);
// Finally the form is conform and the admin page is returned
CreateUserCommand createUserCommand = CreateUserCommandFactory.getInstance().getNewCreateUserCommand();
createUserCommand.setSiteUrl("http://www.newSite.com/");
createUserCommand.setEmail("newUser@test.com");
createUserCommand.setPassword("P4sSw0rD");
createUserCommand.setConfirmPassword("P4sSw0rD");
BindingResult bindingResult = new BeanPropertyBindingResult(createUserCommand, "createUserCommand");
Model model = new ExtendedModelMap();
String result = instance.submitAddUserForm(createUserCommand, bindingResult, model);
assertEquals(TgolKeyStore.ADMIN_VIEW_NAME, result);
assertFalse(bindingResult.hasErrors());
assertTrue(bindingResult.getFieldErrors().isEmpty());
assertEquals(2, model.asMap().size());
assertEquals("newUser@test.com", model.asMap().get(TgolKeyStore.ADDED_USER_NAME_KEY));
assertTrue(((List<User>) model.asMap().get(TgolKeyStore.USER_LIST_KEY)).isEmpty());
}
use of org.asqatasun.webapp.command.CreateUserCommand in project Asqatasun by Asqatasun.
the class SignUpControllerTest method testSetUpSignUpConfirmationPage.
/**
* Test of setUpSignUpConfirmationPage method, of class SignUpController.
*/
public void testSetUpSignUpConfirmationPage() {
System.out.println("setUpSignUpConfirmationPage");
Model model = new ExtendedModelMap();
String expResult = TgolKeyStore.SIGN_UP_CONFIRMATION_VIEW_NAME;
String result = instance.setUpSignUpConfirmationPage(model);
// the returned view is the sign-up confirmation view name
assertEquals(expResult, result);
// the model contains a UserSignUpCommand instance to maps the data of
// the form of the view
assertTrue(model.asMap().get(TgolKeyStore.CREATE_USER_COMMAND_KEY) instanceof CreateUserCommand);
}
use of org.asqatasun.webapp.command.CreateUserCommand in project Asqatasun by Asqatasun.
the class SignUpControllerTest method testSetUpSignUpPage.
/**
* Test of setUpSignUpPage method, of class SignUpController.
*/
public void testSetUpSignUpPage() {
System.out.println("setUpSignUpPage");
Model model = new ExtendedModelMap();
String expResult = TgolKeyStore.SIGN_UP_VIEW_NAME;
String result = instance.setUpSignUpPage(model);
// the returned view is the sign-up view name
assertEquals(expResult, result);
// the model contains a UserSignUpCommand instance to maps the data of
// the form of the view
assertTrue(model.asMap().get(TgolKeyStore.CREATE_USER_COMMAND_KEY) instanceof CreateUserCommand);
}
Aggregations