@Test
public void testGetAccessToken() {

    Principal principal = SimplePrincipal.create("user_domain", "user",
            "auth_creds", PRINCIPAL_AUTHORITY);
    ZTSRDLClientMock ztsClientMock = new ZTSRDLClientMock();
    ZTSClient client = new ZTSClient("http://localhost:4080", principal);
    client.setZTSRDLGeneratedClient(ztsClientMock);
    AccessTokenResponse accessTokenResponse = client.getAccessToken("coretech", null, 3600);
    assertNotNull(accessTokenResponse);
    assertEquals("accesstoken", accessTokenResponse.getAccess_token());
    assertTrue(3600 == accessTokenResponse.getExpires_in());
    assertNull(accessTokenResponse.getId_token());
    accessTokenResponse = client.getAccessToken("coretech", Collections.singletonList("role1"), 3600);
    assertNotNull(accessTokenResponse);
    assertEquals("accesstoken", accessTokenResponse.getAccess_token());
    assertTrue(3600 == accessTokenResponse.getExpires_in());
    assertNull(accessTokenResponse.getId_token());
    // the second request should be addressed from the cache
    accessTokenResponse = client.getAccessToken("coretech", Collections.singletonList("role1"), 3600);
    assertNotNull(accessTokenResponse);
    assertEquals("accesstoken", accessTokenResponse.getAccess_token());
    assertTrue(3600 == accessTokenResponse.getExpires_in());
    assertNull(accessTokenResponse.getId_token());
    // now with id token
    accessTokenResponse = client.getAccessToken("coretech", null, "backend", 3600, false);
    assertNotNull(accessTokenResponse);
    assertEquals("accesstoken", accessTokenResponse.getAccess_token());
    assertEquals("idtoken", accessTokenResponse.getId_token());
    assertTrue(3600 == accessTokenResponse.getExpires_in());
    // now with id token and cache disabled
    accessTokenResponse = client.getAccessToken("coretech", null, "backend", 3600, true);
    assertNotNull(accessTokenResponse);
    assertEquals("accesstoken", accessTokenResponse.getAccess_token());
    assertEquals("idtoken", accessTokenResponse.getId_token());
    assertTrue(3600 == accessTokenResponse.getExpires_in());
    ZTSClient.setCacheDisable(true);
    accessTokenResponse = client.getAccessToken("coretech", null, "backend", 3600, true);
    assertNotNull(accessTokenResponse);
    assertEquals("accesstoken", accessTokenResponse.getAccess_token());
    assertEquals("idtoken", accessTokenResponse.getId_token());
    assertTrue(3600 == accessTokenResponse.getExpires_in());
    ZTSClient.setCacheDisable(false);
    client.close();
}