@Test
public void testGetDomainRoleMembers() {

    ZMSClient client = createClient(systemAdminUser);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    client.setZMSRDLGeneratedClient(c);
    MemberRole memberRole = new MemberRole();
    memberRole.setRoleName("readers");
    List<MemberRole> memberRoles = new ArrayList<>();
    memberRoles.add(memberRole);
    DomainRoleMember member = new DomainRoleMember();
    member.setMemberName("athenz.api");
    member.setMemberRoles(memberRoles);
    List<DomainRoleMember> members = new ArrayList<>();
    members.add(member);
    DomainRoleMembers domainRoleMembers = new DomainRoleMembers();
    domainRoleMembers.setMembers(members);
    Mockito.when(c.getDomainRoleMembers("athenz"))
            .thenReturn(domainRoleMembers)
            .thenThrow(new ZMSClientException(401, "fail"))
            .thenThrow(new IllegalArgumentException("other-error"));
    DomainRoleMembers retMembers = client.getDomainRoleMembers("athenz");
    assertNotNull(retMembers);
    assertEquals(retMembers.getMembers().get(0).getMemberName(), "athenz.api");
    // second time it fails with zms client exception
    try {
        client.getDomainRoleMembers("athenz");
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(401, ex.getCode());
    }
    // last time with std exception - resulting in 400
    try {
        client.getDomainRoleMembers("athenz");
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(400, ex.getCode());
    }
}