UserDAO extends AbstractJPADAO<User, Long> { 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; } } UserDAO(); User read(Long key); User findUserFromEmail(String email); User findUserFromName(String name); boolean isAccountActivated(String email);  }
@Test public void testIsAccountActivated(){ assertFalse(userDAO.isAccountActivated("test1@test.com")); assertTrue(userDAO.isAccountActivated("test2@test.com")); assertTrue(userDAO.isAccountActivated("test3@test.com")); assertFalse(userDAO.isAccountActivated("test4@test.com")); }