### Question:
WizardDaoImpl extends DaoBaseImpl<Wizard> implements WizardDao { @Override public Wizard findByName(String name) { Session session = getSessionFactory().openSession(); Transaction tx = null; Wizard result = null; try { tx = session.beginTransaction(); Criteria criteria = session.createCriteria(persistentClass); criteria.add(Restrictions.eq("name", name)); result = (Wizard) criteria.uniqueResult(); for (Spellbook s : result.getSpellbooks()) { s.getSpells().size(); } tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } finally { session.close(); } return result; }  @Override Wizard findByName(String name);  }### Answer:
@Test public void testFindByName() { final WizardDaoImpl dao = getDao(); final List<Wizard> allWizards = dao.findAll(); for (final Wizard spell : allWizards) { final Wizard byName = dao.findByName(spell.getName()); assertNotNull(byName); assertEquals(spell.getId(), byName.getId()); assertEquals(spell.getName(), byName.getName()); } }
@Test public void testFindByName() throws Exception { final WizardDaoImpl dao = getDao(); final List<Wizard> allWizards = dao.findAll(); for (final Wizard spell : allWizards) { final Wizard byName = dao.findByName(spell.getName()); assertNotNull(byName); assertEquals(spell.getId(), byName.getId()); assertEquals(spell.getName(), byName.getName()); } }