use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserManagementControllerTest method testSubmitAddAdminUserForm.
/**
* Test of submitAddUserForm method, of class UserManagementController.
*/
@Test
public void testSubmitAddAdminUserForm() throws Exception {
setUpMockRoleDataService();
setUpMockUserDataService(true, false, false);
setUpMockAuthenticationContext();
// Finally the form is conform and the admin page is returned
CreateUserCommand createUserCommand = createUserCommandFactory.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(ADMIN_VIEW_NAME, result);
assertFalse(bindingResult.hasErrors());
assertTrue(bindingResult.getFieldErrors().isEmpty());
assertEquals(2, model.asMap().size());
assertEquals("newUser@test.com", model.asMap().get(ADDED_USER_NAME_KEY));
assertTrue(((List<User>) model.asMap().get(TgolKeyStore.USER_LIST_KEY)).isEmpty());
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class CreateContractFormValidator method checkUsers.
/**
* @param createContractCommand
* @param errors
* @return
*/
private boolean checkUsers(CreateContractCommand createContractCommand, Errors errors) {
Collection<User> userList = createContractCommand.getUserList();
if (userList == null || userList.isEmpty()) {
return false;
}
boolean hasAtLeastOneRealUser = false;
for (User user : userList) {
if (user != null) {
hasAtLeastOneRealUser = true;
}
}
return hasAtLeastOneRealUser;
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class AuditSetUpCommandFactory method getGroupOfPagesUrl.
/**
* This methods prepares the String table passed to the jsp that handles the
* URL filled-in by the user. Depending the status of the user
* (authenticated or guest), the table is pre-populated.
*/
private List<String> getGroupOfPagesUrl(Contract contract, boolean isSiteAudit) {
User user = contract.getUser();
/*
* WARNING hard-coded exception for guest user
* @TODO : do it better
*/
int nbOfPages = AuditSetUpCommand.DEFAULT_LIST_SIZE;
List<String> groupOfPagesUrl = new LinkedList();
if (user == null) {
return null;
} else if (user.getEmail1().equalsIgnoreCase("guest") || isSiteAudit) {
nbOfPages = 1;
}
for (int i = 0; i < nbOfPages; i++) {
groupOfPagesUrl.add("");
}
// When the form is displayed for an authenticated user, it is
// pre-populated with the Url recorded with the contract.
String url = contractDataService.getUrlFromContractOption(contract);
if (!StringUtils.isEmpty(url)) {
groupOfPagesUrl.set(0, url);
}
return groupOfPagesUrl;
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserFactory method create.
public User create(String email1, String password, String name, String firstName, String address, String phoneNumber, String webUrl1, String webUrl2, String identicaId, String twitterId, Role role, String email2) {
User user = create();
user.setEmail1(email1);
user.setPassword(password);
user.setName(name);
user.setAddress(address);
user.setFirstName(firstName);
user.setTwitterId(twitterId);
user.setIdenticaId(identicaId);
user.setWebUrl1(webUrl1);
user.setWebUrl2(webUrl2);
user.setRole(role);
user.setPhoneNumber(phoneNumber);
user.setEmail1(email2);
return user;
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class ContractDAOTest method testFindAllContractsByUser.
/**
* Test of findAllContractsByUser method, of class ContractDAOImpl.
*/
@Test
public void testFindAllContractsByUser() {
User user = userDAO.read(1L);
assertEquals(2, contractDAO.findAllContractsByUser(user).size());
user = userDAO.read(2L);
assertEquals(0, contractDAO.findAllContractsByUser(user).size());
}
Aggregations