C32DocumentDaoImpl implements C32DocumentDao { @SuppressWarnings("unchecked") @Transactional public List<C32DocumentEntity> getAllDocuments(String patientId) { if (logger.isDebugEnabled()) { logger.debug("getAllDocuments with :" + patientId); } Query query = getEntityManager().createQuery("SELECT d FROM C32DocumentEntity d WHERE d.icn = :icn"); query.setParameter("icn", patientId); return (List<C32DocumentEntity>) query.getResultList(); }  EntityManager getEntityManager(); void setEntityManager(EntityManager manager); @Transactional void insert(C32DocumentEntity document); @Transactional void update(C32DocumentEntity document); @SuppressWarnings("unchecked") @Transactional List<C32DocumentEntity> getAllDocuments(String patientId);  }
@Test public void getAllDocuments_empty() { List<C32DocumentEntity> results = dao.getAllDocuments("fred"); Assert.assertNull(results); assertQueryTried(); }
@Test public void getAllDocuments_queryError() { managerError = true; try { dao.getAllDocuments("fred"); Assert.fail("error not thrown"); } catch (RuntimeException ex) {} assertQueryTried(); }