HibernateDrugGroupDAO implements DrugGroupDAO { @Override public List<DrugGroup> getDrugGroupByName(String name) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(DrugGroup.class); criteria.add(Restrictions.like("name", name)); criteria.add(Restrictions.like("retired", false)); List<DrugGroup> patients = new ArrayList<DrugGroup>(); patients.addAll(criteria.list()); return patients; }  void setSessionFactory(SessionFactory sessionFactory); @Override DrugGroup saveDrugGroup(DrugGroup drugGroup); @Override void deleteDrugGroup(DrugGroup drugGroup); @Override DrugGroup getDrugGroup(Integer drugGroupId); @Override DrugGroup getDrugGroupByUuid(String uuid); @Override List<DrugGroup> getDrugGroupByName(String name); @Override List<DrugGroup> getAllDrugGroup(boolean includeRetired); @Override DrugGroup updateDrugGroup(DrugGroup drugGroup);  }
@Test public void testGetDrugGroupByName() { String name = "TestDrugGroup1"; String result = dao.getDrugGroupByName(name).get(0).getName(); assertEquals(name, result); }