use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOImplTest method testFindUserFromEmail.
public void testFindUserFromEmail() {
User user = userDAO.findUserFromEmail("test1@test.com");
assertEquals(Long.valueOf(1), user.getId());
assertEquals(2, user.getContractSet().size());
user = userDAO.findUserFromEmail("test@test.com");
assertNull(user);
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class ContractDAOImplTest method testFindAllContractsByUser.
/**
* Test of findAllContractsByUser method, of class ContractDAOImpl.
*/
public void testFindAllContractsByUser() {
System.out.println("findAllContractsByUser");
User user = userDAO.read(Long.valueOf(1));
assertEquals(2, contractDAO.findAllContractsByUser(user).size());
user = userDAO.read(Long.valueOf(2));
assertEquals(0, contractDAO.findAllContractsByUser(user).size());
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class OptionElementDAOImplTest method testFindOptionElementFromUserAndFamilyCode.
/**
* Test of findOptionElementFromUserAndFamilyCode method, of class OptionElementDAOImpl.
*/
public void testFindOptionElementFromUserAndFamilyCode() {
User user1 = userDAO.findUserFromEmail("test1@test.com");
User user2 = userDAO.findUserFromEmail("test2@test.com");
User user3 = userDAO.findUserFromEmail("test3@test.com");
Collection<OptionElement> oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user1, "USER_OPTION");
assertEquals(2, oec.size());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user1, "ANOTHER_OPTION");
assertTrue(oec.isEmpty());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user2, "USER_OPTION");
assertEquals(1, oec.size());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user2, "ANOTHER_OPTION");
assertTrue(oec.isEmpty());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user3, "USER_OPTION");
assertTrue(oec.isEmpty());
oec = optionElementDAO.findOptionElementFromUserAndFamilyCode(user3, "ANOTHER_OPTION");
assertTrue(oec.isEmpty());
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOImpl method isAccountActivated.
@Override
public boolean isAccountActivated(String email) {
Query query = entityManager.createQuery("SELECT u FROM " + getEntityClass().getName() + " u" + " WHERE u.email = :email");
query.setParameter("email", email);
try {
return ((User) query.getSingleResult()).isAccountActivated();
} catch (NoResultException e) {
return false;
}
}
use of org.asqatasun.webapp.entity.user.User in project Asqatasun by Asqatasun.
the class UserDAOImpl method read.
@Override
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;
}
}
Aggregations