@Test
public void testGetAccessExt() {

    ZMSClient client = createClient(systemAdminUser);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    client.setZMSRDLGeneratedClient(c);
    Access access = new Access().setGranted(true);
    Mockito.when(c.getAccessExt("update", "service1", "athenz", "user.johndoe"))
            .thenReturn(access)
            .thenThrow(new ZMSClientException(401, "fail"))
            .thenThrow(new IllegalArgumentException("other-error"));
    Access accessCheck = client.getAccessExt("update", "service1", "athenz", "user.johndoe");
    assertNotNull(accessCheck);
    assertTrue(accessCheck.getGranted());
    // second time it fails
    try {
        client.getAccessExt("update", "service1", "athenz", "user.johndoe");
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(401, ex.getCode());
    }
    // last time with std exception
    try {
        client.getAccessExt("update", "service1", "athenz", "user.johndoe");
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(400, ex.getCode());
    }
}