@Test
public void testGetServiceIdentity() {

    TopLevelDomain dom1 = createTopLevelDomainObject("ServiceGetDom1",
            "Test Domain1", "testOrg", adminUser);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    ServiceIdentity service = createServiceObject("ServiceGetDom1",
            "Service1", "http://localhost", "/usr/bin/java", "root",
            "users", "host1");
    zms.putServiceIdentity(mockDomRsrcCtx, "ServiceGetDom1", "Service1", auditRef, service);
    ServiceIdentity serviceRes = zms.getServiceIdentity(mockDomRsrcCtx, "ServiceGetDom1",
            "Service1");
    assertNotNull(serviceRes);
    assertEquals(serviceRes.getName(), "ServiceGetDom1.Service1".toLowerCase());
    assertEquals(serviceRes.getExecutable(), "/usr/bin/java");
    assertEquals(serviceRes.getGroup(), "users");
    assertEquals(serviceRes.getUser(), "root");
    // provider endpoint is a system meta attribute so we shouldn't saved it
    assertNull(serviceRes.getProviderEndpoint());
    List<String> hosts = serviceRes.getHosts();
    assertNotNull(hosts);
    assertEquals(hosts.size(), 1);
    assertEquals(hosts.get(0), "host1");
    // this should throw a not found exception
    try {
        zms.getServiceIdentity(mockDomRsrcCtx, "ServiceGetDom1", "Service2");
        fail();
    } catch (ResourceException ex) {
        assertEquals(404, ex.getCode());
    }
    // this should throw a request error exception
    try {
        zms.getServiceIdentity(mockDomRsrcCtx, "ServiceGetDom1", "Service2.Service3");
        fail();
    } catch (ResourceException ex) {
        assertEquals(400, ex.getCode());
    }
    
    zms.deleteTopLevelDomain(mockDomRsrcCtx, "ServiceGetDom1", auditRef);
}