@Test
public void testPutServiceIdentityThrowException() {

    String domainName = "DomainName";
    String serviceName = "ServiceName";
    String wrongServiceName = "WrongServiceName";
    
    // Tests the putServiceIdentity() condition: if (!serviceResourceName(domainName, serviceName).equals(detail.getName()))...
    try {
        ServiceIdentity detail = createServiceObject(domainName,
                wrongServiceName, "http://localhost", "/usr/bin/java", "root",
                "users", "host1");
        
        // serviceName should not rendered to be the same as domainName:service.wrongServiceName
        zms.putServiceIdentity(mockDomRsrcCtx, domainName, serviceName, auditRef, detail);
        fail("requesterror not thrown.");
    } catch (ResourceException e) {
        assertEquals(e.getCode(), 400);
    }
    
    // Tests the putServiceIdentity() condition: if (domain == null)...
    try {
        ServiceIdentity detail = createServiceObject(domainName,
                serviceName, "http://localhost", "/usr/bin/java", "root",
                "users", "host1");
        
        // should fail b/c we never created a top level domain.
        zms.putServiceIdentity(mockDomRsrcCtx, domainName, serviceName, auditRef, detail);
        fail("notfounderror not thrown.");
    } catch (ResourceException e) {
        assertEquals(e.getCode(), 404);
    }
}