HibernatePatientListDAO implements PatientListDAO { @Override public List<PatientList> getPatientListByEncounterType(EncounterType encounterType) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(PatientList.class); criteria.add(Restrictions.like("searchQuery", "%" + encounterType.getUuid() + "%")); List<PatientList> patients = new ArrayList<PatientList>(); patients.addAll(criteria.list()); return patients; }  void setSessionFactory(SessionFactory sessionFactory); @Override PatientList savePatientList(PatientList patientList); @Override void deletePatientList(PatientList patientList); @Override PatientList getPatientList(Integer patientListId); @Override List<PatientList> getPatientListByEncounterType(EncounterType encounterType); @Override PatientList getPatientListByUuid(String uuid); @Override List<PatientList> getPatientListByName(String name); @Override List<PatientList> getAllPatientList(boolean includeRetired); @Override PatientList updatePatientList(PatientList patientList);  }
@Test public void testGetPatientListByEncounterType() { EncounterType encounterType = new EncounterType(); encounterType.setName("Registration"); encounterType.setUuid("61ae96f4-6afe-4351-b6f8-cd4fc383cce1"); encounterType.setDescription("Patient has been registered"); encounterType.setRetired(Boolean.FALSE); String name = dao.getPatientListByEncounterType(encounterType).get(0).getName(); assertEquals("TestList1", name); }