@Test
public void testPutTenant() {

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