@Test
public void testDeleteTenancy() {

    ZMSClient client = createClient(systemAdminUser);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    client.setZMSRDLGeneratedClient(c);
    Tenancy tenancyMock = Mockito.mock(Tenancy.class);
    Mockito.when(c.deleteTenancy("tenantDom1", "providerService1", AUDIT_REF)).thenReturn(tenancyMock).thenThrow(new ZMSClientException(400,"Audit reference required"));
    client.deleteTenancy("tenantDom1", "providerService1", AUDIT_REF);
    try {
        client.deleteTenancy("tenantDom1", "providerService1", AUDIT_REF);
        fail();
    } catch (ZMSClientException ex) {
        assertTrue(true);
    }
    try {
        Mockito.when(c.deleteTenancy("tenantDom2", "providerService1", AUDIT_REF))
                .thenThrow(new NullPointerException());
        client.deleteTenancy("tenantDom2", "providerService1", AUDIT_REF);
        fail();
    } catch (ResourceException ex) {
        assertTrue(true);
    }
}