use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAO method findUserFromName.
public User findUserFromName(String name) {
Query query = entityManager.createQuery("SELECT u FROM " + getEntityClass().getName() + " u" + " left join fetch u.contractSet c" + " WHERE u.name = :name");
query.setParameter("name", name);
try {
return (User) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAO method read.
public User read(Long key) {
if (key == null) {
return null;
}
Query query = entityManager.createQuery("SELECT u FROM " + getEntityClass().getName() + " u" + " left join fetch u.contractSet c" + " WHERE u.id = :id");
query.setParameter("id", key);
try {
return (User) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAO method findUserFromEmail.
public User findUserFromEmail(String email) {
Query query = entityManager.createQuery("SELECT u FROM " + getEntityClass().getName() + " u" + " left join fetch u.contractSet c" + // + " left join fetch c.actSet a"
" WHERE u.email = :email");
query.setParameter("email", email);
try {
return (User) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class PageListControllerTest method setUpMockUserDataService.
/**
* Create a user with Id=1, email=test1@test.com and empty name and first name
*/
private void setUpMockUserDataService() {
mockUser = new User();
mockUser.setId(1L);
mockUser.setEmail1("test1@test.com");
mockUser.setName("");
mockUser.setFirstName("");
}
use of org.asqatasun.entity.user.User in project Asqatasun by Asqatasun.
the class UserManagementControllerTest method testSubmitEditUserForm.
/**
* Test of submitEditUserForm method, of class UserManagementController.
*/
@Test
public void testSubmitEditUserForm() throws Exception {
setUpMockRoleDataService();
setUpMockUserDataService(false, true, false);
setUpMockAuthenticationContext();
// Finally the form is conform and the admin page is returned
CreateUserCommand createUserCommand = createUserCommandFactory.getNewCreateUserCommand();
createUserCommand.setEmail("user@test.com");
createUserCommand.setLastName("newName");
createUserCommand.setFirstName("newFirstName");
createUserCommand.setPhoneNumber("0102030405");
createUserCommand.setActivated(false);
createUserCommand.setAdmin(true);
MockHttpServletRequest request = new MockHttpServletRequest();
request.getSession().setAttribute(TgolKeyStore.USER_ID_KEY, 5L);
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("user@test.com", model.asMap().get(TgolKeyStore.UPDATED_USER_NAME_KEY));
assertTrue(((List<User>) model.asMap().get(TgolKeyStore.USER_LIST_KEY)).isEmpty());
}
Aggregations