@Test
public void testDeleteServiceIdentity() {

    TopLevelDomain dom1 = createTopLevelDomainObject("ServiceDelDom1",
            "Test Domain1", "testOrg", adminUser);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    ServiceIdentity service1 = createServiceObject("ServiceDelDom1",
            "Service1", "http://localhost", "/usr/bin/java", "root",
            "users", "host1");
    zms.putServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service1", auditRef, service1);
    ServiceIdentity service2 = createServiceObject("ServiceDelDom1",
            "Service2", "http://localhost", "/usr/bin/java", "root",
            "users", "host1");
    zms.putServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service2", auditRef, service2);
    ServiceIdentity serviceRes1 = zms.getServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1",
            "Service1");
    assertNotNull(serviceRes1);
    ServiceIdentity serviceRes2 = zms.getServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1",
            "Service2");
    assertNotNull(serviceRes2);
    zms.deleteServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service1", auditRef);
    // this should throw a not found exception
    try {
        zms.getServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service1");
        fail();
    } catch (ResourceException ex) {
        assertEquals(404, ex.getCode());
    }
    serviceRes2 = zms.getServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service2");
    assertNotNull(serviceRes2);
    zms.deleteServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service2", auditRef);
    // this should throw a not found exception
    try {
        zms.getServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service1");
        fail();
    } catch (ResourceException ex) {
        assertEquals(404, ex.getCode());
    }
    // this should throw a not found exception
    try {
        zms.getServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service2");
        fail();
    } catch (ResourceException ex) {
        assertEquals(404, ex.getCode());
    }
    // this should throw an invalid exception
    try {
        zms.getServiceIdentity(mockDomRsrcCtx, "ServiceDelDom1", "Service2.Service3");
        fail();
    } catch (ResourceException ex) {
        assertEquals(400, ex.getCode());
    }
    
    zms.deleteTopLevelDomain(mockDomRsrcCtx, "ServiceDelDom1", auditRef);
}