@Test
public void testExecutePutDomainMeta() {

    TopLevelDomain dom1 = createTopLevelDomainObject("MetaDom1",
            "Test Domain1", "testOrg", adminUser);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    Domain resDom1 = zms.getDomain(mockDomRsrcCtx, "MetaDom1");
    assertNotNull(resDom1);
    assertEquals("Test Domain1", resDom1.getDescription());
    assertEquals("testorg", resDom1.getOrg());
    assertTrue(resDom1.getEnabled());
    assertFalse(resDom1.getAuditEnabled());
    assertNull(resDom1.getTokenExpiryMins());
    assertNull(resDom1.getMemberExpiryDays());
    assertNull(resDom1.getServiceExpiryDays());
    assertNull(resDom1.getRoleCertExpiryMins());
    assertNull(resDom1.getServiceCertExpiryMins());
    
    // update meta with values for account and product ids
    
    DomainMeta meta = new DomainMeta().setDescription("Test2 Domain").setOrg("NewOrg")
            .setEnabled(true).setAuditEnabled(false).setAccount("12345").setYpmId(1001)
            .setCertDnsDomain("athenz1.cloud").setMemberExpiryDays(10).setTokenExpiryMins(20)
            .setServiceExpiryDays(45).setGroupExpiryDays(50);
    zms.dbService.executePutDomainMeta(mockDomRsrcCtx, "metadom1", meta, null, false, auditRef, "putDomainMeta");
    zms.dbService.executePutDomainMeta(mockDomRsrcCtx, "metadom1", meta, "productid", true, auditRef, "putDomainMeta");
    zms.dbService.executePutDomainMeta(mockDomRsrcCtx, "metadom1", meta, "account", true, auditRef, "putDomainMeta");
    zms.dbService.executePutDomainMeta(mockDomRsrcCtx, "metadom1", meta, "certdnsdomain", true, auditRef, "putDomainMeta");
    zms.dbService.executePutDomainMeta(mockDomRsrcCtx, "metadom1", meta, "org", true, auditRef, "putDomainMeta");
    Domain resDom2 = zms.getDomain(mockDomRsrcCtx, "MetaDom1");
    assertNotNull(resDom2);
    assertEquals("Test2 Domain", resDom2.getDescription());
    assertEquals("NewOrg", resDom2.getOrg());
    assertTrue(resDom2.getEnabled());
    assertFalse(resDom2.getAuditEnabled());
    assertEquals(Integer.valueOf(1001), resDom2.getYpmId());
    assertEquals("12345", resDom2.getAccount());
    assertEquals(resDom2.getCertDnsDomain(), "athenz1.cloud");
    assertEquals(Integer.valueOf(20), resDom2.getTokenExpiryMins());
    assertEquals(Integer.valueOf(10), resDom2.getMemberExpiryDays());
    assertEquals(Integer.valueOf(45), resDom2.getServiceExpiryDays());
    assertEquals(Integer.valueOf(50), resDom2.getGroupExpiryDays());
    assertNull(resDom2.getRoleCertExpiryMins());
    assertNull(resDom2.getServiceCertExpiryMins());
    // now update without account and product ids
    
    meta = new DomainMeta().setDescription("Test2 Domain-New").setOrg("NewOrg-New")
            .setEnabled(true).setAuditEnabled(false).setRoleCertExpiryMins(30)
            .setServiceCertExpiryMins(40).setSignAlgorithm("rsa")
            .setServiceExpiryDays(45).setGroupExpiryDays(50);
    zms.dbService.executePutDomainMeta(mockDomRsrcCtx, "metadom1", meta, null, false, auditRef, "putDomainMeta");
    zms.dbService.executePutDomainMeta(mockDomRsrcCtx, "metadom1", meta, "org", true, auditRef, "putDomainMeta");
    Domain resDom3 = zms.getDomain(mockDomRsrcCtx, "MetaDom1");
    assertNotNull(resDom3);
    assertEquals("Test2 Domain-New", resDom3.getDescription());
    assertEquals("NewOrg-New", resDom3.getOrg());
    assertTrue(resDom3.getEnabled());
    assertFalse(resDom3.getAuditEnabled());
    assertEquals(Integer.valueOf(1001), resDom3.getYpmId());
    assertEquals("12345", resDom3.getAccount());
    assertEquals(resDom3.getCertDnsDomain(), "athenz1.cloud");
    assertEquals(Integer.valueOf(20), resDom3.getTokenExpiryMins());
    assertEquals(Integer.valueOf(10), resDom3.getMemberExpiryDays());
    assertEquals(Integer.valueOf(45), resDom3.getServiceExpiryDays());
    assertEquals(Integer.valueOf(50), resDom3.getGroupExpiryDays());
    assertEquals(Integer.valueOf(30), resDom3.getRoleCertExpiryMins());
    assertEquals(Integer.valueOf(40), resDom3.getServiceCertExpiryMins());
    assertEquals(resDom3.getSignAlgorithm(), "rsa");
    meta = new DomainMeta().setDescription("Test2 Domain-New").setOrg("NewOrg-New")
            .setEnabled(true).setAuditEnabled(false).setRoleCertExpiryMins(300)
            .setServiceCertExpiryMins(400).setTokenExpiryMins(500)
            .setSignAlgorithm("ec").setServiceExpiryDays(20).setGroupExpiryDays(25);
    zms.dbService.executePutDomainMeta(mockDomRsrcCtx, "metadom1", meta, null, false, auditRef, "putDomainMeta");
    Domain resDom4 = zms.getDomain(mockDomRsrcCtx, "MetaDom1");
    assertNotNull(resDom4);
    assertEquals("Test2 Domain-New", resDom4.getDescription());
    assertEquals("NewOrg-New", resDom4.getOrg());
    assertTrue(resDom4.getEnabled());
    assertFalse(resDom4.getAuditEnabled());
    assertEquals(Integer.valueOf(1001), resDom4.getYpmId());
    assertEquals("12345", resDom4.getAccount());
    assertEquals(resDom4.getCertDnsDomain(), "athenz1.cloud");
    assertEquals(Integer.valueOf(500), resDom4.getTokenExpiryMins());
    assertEquals(Integer.valueOf(10), resDom4.getMemberExpiryDays());
    assertEquals(Integer.valueOf(20), resDom4.getServiceExpiryDays());
    assertEquals(Integer.valueOf(25), resDom4.getGroupExpiryDays());
    assertEquals(Integer.valueOf(300), resDom4.getRoleCertExpiryMins());
    assertEquals(Integer.valueOf(400), resDom4.getServiceCertExpiryMins());
    assertEquals(resDom4.getSignAlgorithm(), "ec");
    zms.deleteTopLevelDomain(mockDomRsrcCtx, "MetaDom1", auditRef);
}