### Question:
HibernateTemplateDAO extends HibernatePersistentObjectDAO<Template> implements TemplateDAO { @Override public boolean delete(long id, int code) throws PersistenceException { if (!checkStoringAspect()) return false; boolean result = true; Template template = (Template) findById(id); if (countDocs(id) > 0) throw new PersistenceException(String.format("Some documents are referencing the template %s (%d)", template.getName(), template.getId())); if (countFolders(id) > 0) throw new PersistenceException(String.format("Some folders are referencing the template %s (%d)", template.getName(), template.getId())); if (template != null) { template.setDeleted(code); template.setName(template.getName() + "." + template.getId()); saveOrUpdate(template); } return result; } 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 testDelete() throws PersistenceException { try { Assert.assertFalse(dao.delete(1)); } catch (PersistenceException e) { Assert.assertTrue(true); } Assert.assertTrue(dao.delete(-1L)); Template template = dao.findById(-1L); Assert.assertNull(template); }