### Question:
HibernateDiagnosisDAO implements DiagnosisDAO { @SuppressWarnings("unchecked") @Override public List<Diagnosis> getActiveDiagnoses(Patient patient, Date fromDate) { String fromDateCriteria = ""; if(fromDate != null){ fromDateCriteria = " and d.dateCreated >= :fromDate "; } Query query = sessionFactory.getCurrentSession().createQuery( "from Diagnosis d where d.patient.patientId = :patientId and d.voided = false " + fromDateCriteria + " order by d.dateCreated desc"); query.setInteger("patientId", patient.getId()); if(fromDate != null){ query.setDate("fromDate", fromDate); } 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 shouldGetActiveDiagnosesWithFromDate() { Calendar calendar = new GregorianCalendar(2014,1,1,13,24,56); assertEquals(1, diagnosisDAO.getActiveDiagnoses(new Patient(2), calendar.getTime()).size()); }
@Test public void shouldGetActiveDiagnosesWithDifferentFromDate() { Calendar calendar = new GregorianCalendar(2012,1,3,13,32,36); assertEquals(2, diagnosisDAO.getActiveDiagnoses(new Patient(2), calendar.getTime()).size()); }
@Test public void shouldGetActiveDiagnosesWithoutFromDate() { assertEquals(2, diagnosisDAO.getActiveDiagnoses(new Patient(2), null).size()); }