### Question:
HibernateDiagnosisDAO implements DiagnosisDAO { @Override public List<Diagnosis> getPrimaryDiagnoses(Encounter encounter) { Query query = sessionFactory.getCurrentSession().createQuery( "from Diagnosis d where d.encounter.encounterId = :encounterId and d.rank = :rankId order by dateCreated desc"); query.setInteger("encounterId", encounter.getId()); query.setInteger("rankId", PRIMARY_RANK); return query.list(); }  void setSessionFactory(SessionFactory sessionFactory); @Override Diagnosis saveDiagnosis(Diagnosis diagnosis); @SuppressWarnings("unchecked") @Override List<Diagnosis> getActiveDiagnoses(Patient patient, Date fromDate); @Override List<Diagnosis> getDiagnoses(Encounter encounter); @Override List<Diagnosis> getPrimaryDiagnoses(Encounter encounter); @Override Diagnosis getDiagnosisById(Integer diagnosisId); @Override Diagnosis getDiagnosisByUuid(String uuid); @Override void deleteDiagnosis(Diagnosis diagnosis);  }### Answer:
@Test public void shouldGetPrimaryDiagnoses() { assertEquals(2, diagnosisDAO.getPrimaryDiagnoses(new Encounter(3)).size()); assertEquals(0, diagnosisDAO.getPrimaryDiagnoses(new Encounter(4)).size()); }