### Question:
GroupHibernateDao extends GenericDao<Group> implements GroupDao { @Override public List<Group> getByName(String name) { Validate.notNull(name, "User Group name can't be null"); Query query = session().getNamedQuery(FIND_EXACTLY_BY_NAME); query.setString("name", name); return query.list(); } GroupHibernateDao(SessionFactory sessionFactory); @Override @SuppressWarnings("unchecked") List<Group> getAll(); @SuppressWarnings("unchecked") @Override List<Group> getByNameContains(String name); @Override List<Group> getByName(String name); @Override void delete(Group group); @SuppressWarnings("unchecked") @Override List<PoulpeBranch> getModeratingBranches(Group group);  }### Answer:
@Test public void testGetByName() { Group group = TestFixtures.group(); saveAndEvict(group); List<Group> actual = dao.getByName(group.getName()); assertEquals(actual.size(), 1); assertReflectionEquals(actual.get(0), group); }
@Test public void testGetByNameFailWithEmptyString() { Group group = TestFixtures.group(); saveAndEvict(group); List<Group> actual = dao.getByName(NO_FILTER); assertEquals(actual.size(), 0); }
@Test public void testGetByNameLowerCase() { Group group = TestFixtures.group(); saveAndEvict(group); List<Group> actual = dao.getByName(group.getName().toLowerCase()); assertEquals(actual.size(), 1); assertReflectionEquals(actual.get(0), group); }
@Test public void testGetByNameUpperCase() { Group group = TestFixtures.group(); saveAndEvict(group); List<Group> actual = dao.getByName(group.getName().toUpperCase()); assertEquals(actual.size(), 1); assertReflectionEquals(actual.get(0), group); }
@Test public void testGetByNameWithSpecialChars() { Group group = TestFixtures.group(); group.setName("!@#$%^&*()\"\'\\/"); saveAndEvict(group); List<Group> actual = dao.getByName(group.getName()); assertEquals(actual.size(), 1); assertReflectionEquals(actual.get(0), group); }