@Test
public void testPutGroupMembership() {

    final String domainName = "put-group-mbr";
    final String groupName = "group1";
    ZMSClient client = createClient(systemAdminUser);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    client.setZMSRDLGeneratedClient(c);
    GroupMembership member = new GroupMembership().setGroupName(groupName).setMemberName("user.joe")
            .setIsMember(true);
    Mockito.when(c.putGroupMembership(domainName, groupName, "user.joe", AUDIT_REF, member))
            .thenThrow(new ResourceException(403))
            .thenThrow(new NullPointerException());
    try {
        client.putGroupMembership(domainName, groupName, "user.joe", AUDIT_REF);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(ex.getCode(), 403);
    }
    try {
        client.putGroupMembership(domainName, groupName, "user.joe", AUDIT_REF);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(ex.getCode(), 400);
    }
}