@Test
public void testRoleToken() throws CryptoException {

    // Add some roles
    List<String> roles = new ArrayList<>();
    roles.add("storage.tenant.weather.updater");
    roles.add("fantasy.tenant.sports.admin");
    roles.add("fantasy.tenant.sports.reader");
    roles.add("fantasy.tenant.sports.writer");
    roles.add("fantasy.tenant.sports.scanner");
    // Create a token for validation using the signed data
    String testKeyVersionK1 = "1";
    RoleToken rollTokenToValidate = createRoleTokenToValidate(roles, testKeyVersionK1);
    assertNotNull(rollTokenToValidate.getSignedToken());
    // Validate all input data
    assertEquals(rollTokenToValidate.getVersion(), rolVersion);
    assertEquals(rollTokenToValidate.getDomain(), svcDomain);
    List<String> rolesToValidate = rollTokenToValidate.getRoles();
    assertEquals(rolesToValidate.size(), roles.size());
    assertEquals(rolesToValidate, roles);
    assertEquals(rollTokenToValidate.getKeyId(), testKeyVersionK1);
    // Validate the signature and that expiration time had not elapsed
    assertTrue(rollTokenToValidate.validate(ztsPublicKeyStringK1, 300, false));
    
    // Create ServiceToken with null keyVersion which should default to 0
    rollTokenToValidate = createRoleTokenToValidate(roles);
    assertEquals(rollTokenToValidate.getKeyId(), "0");
    
    // Validate the signature using key(k0) and that expiration time had not elapsed
    assertTrue(rollTokenToValidate.validate(ztsPublicKeyStringK0, 300, false));
}