### Question:
HibernateAttributeOptionDAO extends HibernatePersistentObjectDAO<AttributeOption> implements AttributeOptionDAO { @Override public List<AttributeOption> findBySetIdAndAttribute(long setId, String attribute) { List<AttributeOption> coll = new ArrayList<AttributeOption>(); try { if (StringUtils.isEmpty(attribute)) coll = (List<AttributeOption>) findByQuery( "from AttributeOption _opt where _opt.deleted=0 and _opt.setId = ?1 order by _opt.position asc", new Object[] { Long.valueOf(setId) }, null); else coll = (List<AttributeOption>) findByQuery( "from AttributeOption _opt where _opt.deleted=0 and _opt.setId = ?1 and _opt.attribute = ?2 order by _opt.position asc", new Object[] { Long.valueOf(setId), attribute }, null); } catch (Throwable e) { log.error(e.getMessage(), e); } return coll; } HibernateAttributeOptionDAO(); @Override boolean deleteBySetIdAndAttribute(long setId, String attribute); @Override List<AttributeOption> findBySetIdAndAttribute(long setId, String attribute); @Override boolean delete(long id, int code); @Override void deleteOrphaned(long setId, Collection<String> currentAttributes);  }### Answer:
@Test public void testFindByTemplateAndAttribute() { List<AttributeOption> options = dao.findBySetIdAndAttribute(1L, "att1"); Assert.assertEquals(2, options.size()); options = dao.findBySetIdAndAttribute(1L, null); Assert.assertEquals(3, options.size()); options = dao.findBySetIdAndAttribute(999L, null); Assert.assertEquals(0, options.size()); options = dao.findBySetIdAndAttribute(1L, "att2"); Assert.assertEquals(1, options.size()); options = dao.findBySetIdAndAttribute(2L, "att1"); Assert.assertEquals(1, options.size()); options = dao.findBySetIdAndAttribute(2L, null); Assert.assertEquals(1, options.size()); }