@Test
public void testGetPrincipalGroups() {

    ZMSClient client = createClient(systemAdminUser);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    client.setZMSRDLGeneratedClient(c);
    DomainGroupMember domainGroupMember = Mockito.mock(DomainGroupMember.class);
    Mockito.when(c.getPrincipalGroups(null, null))
            .thenReturn(domainGroupMember)
            .thenThrow(new ZMSClientException(401, "fail"))
            .thenThrow(new IllegalArgumentException("other-error"));
    DomainGroupMember retMember = client.getPrincipalGroups(null, null);
    assertNotNull(retMember);
    try {
        client.getPrincipalGroups(null, null);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(ex.getCode(), 401);
    }
    try {
        client.getPrincipalGroups(null, null);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(ex.getCode(), 400);
    }
}