@Test
public void testGetDomainTemplateList() {

    
    String domainName = "domaintemplatelist-valid";
    TopLevelDomain dom1 = createTopLevelDomainObject(domainName,
            "Test Domain1", "testOrg", adminUser);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    
    // initially no templates
    
    DomainTemplateList domaintemplateList = zms.getDomainTemplateList(mockDomRsrcCtx, domainName);
    List<String> templates = domaintemplateList.getTemplateNames();
    assertEquals(0, templates.size());
    
    // add a single template
    
    DomainTemplate domTemplate = new DomainTemplate();
    templates = new ArrayList<>();
    templates.add("vipng");
    domTemplate.setTemplateNames(templates);
    
    zms.putDomainTemplate(mockDomRsrcCtx, domainName, auditRef, domTemplate);
    
    domaintemplateList = zms.getDomainTemplateList(mockDomRsrcCtx, domainName);
    templates = domaintemplateList.getTemplateNames();
    assertEquals(1, templates.size());
    assertTrue(templates.contains("vipng"));
    
    // add 2 templates
    
    domTemplate = new DomainTemplate();
    templates = new ArrayList<>();
    templates.add("vipng");
    templates.add("platforms");
    domTemplate.setTemplateNames(templates);
    
    zms.putDomainTemplate(mockDomRsrcCtx, domainName, auditRef, domTemplate);
    
    domaintemplateList = zms.getDomainTemplateList(mockDomRsrcCtx, domainName);
    templates = domaintemplateList.getTemplateNames();
    assertEquals(2, templates.size());
    assertTrue(templates.contains("vipng"));
    assertTrue(templates.contains("platforms"));
    // add the same set of templates again and no change in results
    domTemplate = new DomainTemplate();
    domTemplate.setTemplateNames(templates);
    zms.putDomainTemplate(mockDomRsrcCtx, domainName, auditRef, domTemplate);
    
    domaintemplateList = zms.getDomainTemplateList(mockDomRsrcCtx, domainName);
    templates = domaintemplateList.getTemplateNames();
    assertEquals(2, templates.size());
    assertTrue(templates.contains("vipng"));
    assertTrue(templates.contains("platforms"));
    // delete an applied service template
    //
    String templateName = "vipng";
    zms.deleteDomainTemplate(mockDomRsrcCtx, domainName, templateName, auditRef);
    domaintemplateList = zms.getDomainTemplateList(mockDomRsrcCtx, domainName);
    templates = domaintemplateList.getTemplateNames();
    assertEquals(1, templates.size());
    assertTrue(templates.contains("platforms"));
    
    // delete last applied service template
    //
    templateName = "platforms";
    zms.deleteDomainTemplate(mockDomRsrcCtx, domainName, templateName, auditRef);
    domaintemplateList = zms.getDomainTemplateList(mockDomRsrcCtx, domainName);
    templates = domaintemplateList.getTemplateNames();
    assertTrue(templates.isEmpty());
    
    zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName, auditRef);
}