@Test
public void testGetAccessTokenCacheKey() {

    Principal principal = SimplePrincipal.create("user_domain", "user",
            "auth_creds", PRINCIPAL_AUTHORITY);
    ZTSClient client = new ZTSClient("http://localhost:4080/", principal);
    assertNull(client.getAccessTokenCacheKey(null, "service", "coretech", null, null, null));
    assertEquals("p=sports;d=coretech",
            client.getAccessTokenCacheKey("sports", null, "coretech", null, null, null));
    assertEquals("p=sports.api;d=coretech",
            client.getAccessTokenCacheKey("sports", "api", "coretech", null, null, null));
    assertEquals("p=sports.api;d=coretech;r=readers",
            client.getAccessTokenCacheKey("sports", "api", "coretech",
                    Collections.singletonList("readers"), null, null));
    List<String> roles = new ArrayList<>();
    roles.add("writers");
    roles.add("readers");
    assertEquals("p=sports.api;d=coretech;r=readers,writers",
            client.getAccessTokenCacheKey("sports", "api", "coretech", roles, null, null));
    assertEquals("p=sports.api;d=coretech;r=readers,writers",
            client.getAccessTokenCacheKey("sports", "api", "coretech", roles, "", null));
    assertEquals("p=sports.api;d=coretech;r=readers,writers;o=backend",
            client.getAccessTokenCacheKey("sports", "api", "coretech", roles, "backend", null));
    // using tenant domain details from principal object
    assertEquals("p=user_domain.user;d=coretech;r=readers,writers;o=backend",
            client.getAccessTokenCacheKey("coretech", roles, "backend", null));
    client.close();
}