### Question:
HibernateTemplateDAO extends HibernatePersistentObjectDAO<Template> implements TemplateDAO { @Override public Template findByName(String name, long tenantId) { Template template = null; try { List<Template> coll = findByWhere( "_entity.name = '" + SqlUtil.doubleQuotes(name) + "' and _entity.tenantId=" + tenantId, null, null); if (coll.size() > 0) template = coll.iterator().next(); if (template != null && template.getDeleted() == 1) template = null; } catch (PersistenceException e) { log.error(e.getMessage(), e); } return template; } HibernateTemplateDAO(); @Override List<Template> findAll(); @Override List<Template> findAll(long tenantId); @Override Template findByName(String name, long tenantId); @Override boolean delete(long id, int code); int countFolders(long id); @Override int countDocs(long id); @Override List<Template> findByType(int type, long tenantId); @Override void initialize(Template template);  }### Answer:
@Test public void testFindByName() { Template template = dao.findByName("test1", Tenant.DEFAULT_ID); Assert.assertNotNull(template); dao.initialize(template); Assert.assertEquals(1, template.getId()); Assert.assertEquals("test1", template.getName()); template = dao.findByName("xxx", Tenant.DEFAULT_ID); Assert.assertNull(template); template = dao.findByName("test1", 99L); Assert.assertNull(template); }