@Test
public void testDeleteMembership() {

    ZMSClient client = createClient(systemAdminUser);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    client.setZMSRDLGeneratedClient(c);
    Mockito.when(c.deleteMembership("domain", "role1", "joe", AUDIT_REF)).thenThrow(new ResourceException(403));
    Mockito.when(c.deleteMembership("domain", "role2", "joe", AUDIT_REF)).thenThrow(new NullPointerException());
    try {
        client.deleteMembership("domain", "role1", "joe", AUDIT_REF);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(ex.getCode(), 403);
    }
    try {
        client.deleteMembership("domain", "role2", "joe", AUDIT_REF);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(ex.getCode(), 400);
    }
}