@Test
public void testPutQuota() {

    ZMSClient client = createClient(systemAdminUser);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    client.setZMSRDLGeneratedClient(c);
    Quota quota = new Quota().setName("athenz").setAssertion(10).setEntity(11)
            .setPolicy(12).setPublicKey(13).setRole(14).setRoleMember(15)
            .setService(16).setServiceHost(17).setSubdomain(18);
    Mockito.when(c.putQuota("athenz", AUDIT_REF, quota))
            .thenReturn(null)
            .thenThrow(new ZMSClientException(401, "fail"))
            .thenThrow(new IllegalArgumentException("other-error"));
    // first time it completes successfully
    
    client.putQuota("athenz", AUDIT_REF, quota);
    // second time it fails
    try {
        client.putQuota("athenz", AUDIT_REF, quota);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(401, ex.getCode());
    }
    // last time with std exception
    try {
        client.putQuota("athenz", AUDIT_REF, quota);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(400, ex.getCode());
    }
}