### Question:
HibernateTemplateDAO extends HibernatePersistentObjectDAO<Template> implements TemplateDAO { @Override public void initialize(Template template) { try { refresh(template); if (template.getAttributes() != null) template.getAttributes().keySet().size(); } catch (Throwable t) { } } 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 testFindById() { Template template = dao.findById(1); Assert.assertNotNull(template); dao.initialize(template); Assert.assertEquals(1, template.getId()); Assert.assertEquals("test1", template.getName()); Assert.assertTrue(template.getAttributes().containsKey("attr1")); template = dao.findById(99); Assert.assertNull(template); template = dao.findById(-1); Assert.assertNotNull(template); dao.initialize(template); Assert.assertEquals(-1, template.getId()); Assert.assertEquals("default", template.getName()); Assert.assertTrue(template.getAttributes().containsKey("object")); }
@Test public void testStore() throws PersistenceException { Template template = new Template(); template.setName("test3"); template.setValue("a1", "v1"); template.setValue("a2", "v2"); template.setValue("object", "value"); Assert.assertTrue(dao.store(template)); template = dao.findById(template.getId()); dao.initialize(template); Assert.assertEquals("test3", template.getName()); Assert.assertTrue(template.getAttributes().containsKey("a1")); Assert.assertTrue(template.getAttributes().containsKey("a2")); Assert.assertTrue(template.getAttributes().containsKey("object")); }