TemplateManager { public AlertTemplates getTemplate(EntityManager em, String tenantId, short templateId) throws Exception { try { AlertTemplates result = em.createNamedQuery(Queries.TEMPLATE_FIND_BY_ID, AlertTemplates.class) .setParameter("templateId", templateId).setParameter("tenantId", tenantId).getSingleResult(); return result; } catch (Exception e) { throw new NoResultException("Template:" + templateId + " not found"); } } private  TemplateManager(); static TemplateManager getInstance(); String getTemplateContents(EntityManager em, String tenantId, boolean pretty); AlertTemplates getTemplate(EntityManager em, String tenantId, short templateId); List<AlertTemplates> getTemplates(EntityManager em, String tenantId); AlertTemplate createNewTemplate(EntityManager em, AlertTemplates templates, Tenant tenant); AlertTemplate saveTemplate(EntityManager em, AlertTemplates templates, Tenant tenant, AlertTemplate currTemplate,
			ApplicationManager am); AlertTemplate getTemplateObj(EntityManager em, String tenantId, short templateId); void deleteTemplate(EntityManager em, String tenantId, short templateId, ApplicationManager am); void deleteTemplates(EntityManager em, Tenant tenant, ApplicationManager am); void sendTemplateToKafka(boolean delete, String tenantId, AlertTemplate template, ApplicationManager am); void sendTemplateToKafka(boolean delete, String tenantId, String templateJson, ApplicationManager am); Tenant getTenant(EntityManager em, String tenantId);  }
@Test public void testGetTemplate() throws Exception { AlertTemplates templates = new AlertTemplates(); tenant = TemplateManager.getInstance().getTenant(em, TENANT_ID_1); id = TemplateManager.getInstance().createNewTemplate(em, templates, tenant).getTemplateId(); AlertTemplates template = TemplateManager.getInstance().getTemplate(em, tenant.getTenant_id(), id); assertEquals(id, template.getTemplateId()); }