@Test
public void testGetDelegatedRoleMembers() {

    String domainName1 = "role-expand1";
    String domainName2 = "role-expand2";
    String roleName = "role1";
    
    TopLevelDomain dom1 = createTopLevelDomainObject(domainName1,
            "Test Domain1", "testOrg", adminUser);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    TopLevelDomain dom2 = createTopLevelDomainObject(domainName2,
            "Test Domain2", "testOrg", adminUser);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom2);
    
    Role role1 = createRoleObject(domainName1, roleName, domainName2,
            null, null);
    zms.putRole(mockDomRsrcCtx, domainName1, roleName, auditRef, role1);
    
    Role role2a = createRoleObject(domainName2, "role2a", null,
            "user.joe", "user.jane");
    zms.putRole(mockDomRsrcCtx, domainName2, "role2a", auditRef, role2a);
    
    Role role2b = createRoleObject(domainName2, "role2b", null,
            "user.joe", "user.doe");
    zms.putRole(mockDomRsrcCtx, domainName2, "role2b", auditRef, role2b);
    
    Role role2c = createRoleObject(domainName2, "role2c", "sys.auth",
            null, null);
    zms.putRole(mockDomRsrcCtx, domainName2, "role2c", auditRef, role2c);
    
    Role role2d = createRoleObject(domainName2, "role2d", null,
            "user.user1", "user.user2");
    zms.putRole(mockDomRsrcCtx, domainName2, "role2d", auditRef, role2d);
    
    Role role2e = createRoleObject(domainName2, "role2e", null,
            null, null);
    zms.putRole(mockDomRsrcCtx, domainName2, "role2e", auditRef, role2e);
    
    Policy policy = createPolicyObject(domainName2, "policy",
            domainName2 + ":role.role2a", false, "assume_role", domainName1 + ":role." + roleName,
            AssertionEffect.ALLOW);
    
    Assertion assertion = new Assertion();
    assertion.setAction("assume_role");
    assertion.setEffect(AssertionEffect.ALLOW);
    assertion.setResource("*:role." + roleName);
    assertion.setRole(domainName2 + ":role.role2b");
    policy.getAssertions().add(assertion);
    zms.putPolicy(mockDomRsrcCtx, domainName2, "policy", auditRef, policy);
    
    policy = new Policy().setName(domainName2 + ":policy.policy2");
    zms.dbService.executePutPolicy(mockDomRsrcCtx, domainName2, "policy2", policy, auditRef, "putPolicy");
    ObjectStoreConnection conn = zms.dbService.store.getConnection(true, false);
    List<RoleMember> members = zms.dbService.getDelegatedRoleMembers(conn, domainName1, domainName2, roleName);
    assertEquals(3, members.size());
    
    List<String> checkList = new ArrayList<>();
    checkList.add("user.joe");
    checkList.add("user.jane");
    checkList.add("user.doe");
    checkRoleMember(checkList, members);
    
    zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName1, auditRef);
    zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName2, auditRef);
}