@Test
public void testDefaultOAuthJwtAccessTokenParser() {

    BiFunction<Field, DefaultOAuthJwtAccessTokenParser, Object> getFieldValue = (f, object) -> {
        try {
            f.setAccessible(true);
            return f.get(object);
        } catch (IllegalArgumentException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    };
    DefaultOAuthJwtAccessTokenParser parser = null;
    // new error
    assertThrows(IllegalArgumentException.class, () -> new DefaultOAuthJwtAccessTokenParser(null, null));
    // new with null/empty URL
    parser = new DefaultOAuthJwtAccessTokenParser(baseKeyStore, null);
    assertNotNull(parser);
    for (Field f : parser.getClass().getDeclaredFields()) {
        switch (f.getName()) {
            case "parser":
                assertNotNull(getFieldValue.apply(f, parser));
                break;
        }
    }
    parser = new DefaultOAuthJwtAccessTokenParser(baseKeyStore, "");
    assertNotNull(parser);
    for (Field f : parser.getClass().getDeclaredFields()) {
        switch (f.getName()) {
            case "parser":
                assertNotNull(getFieldValue.apply(f, parser));
                break;
        }
    }
    // new with file JWKS
    parser = new DefaultOAuthJwtAccessTokenParser(baseKeyStore, this.classLoader.getResource("jwt_jwks.json").toString());
    assertNotNull(parser);
    for (Field f : parser.getClass().getDeclaredFields()) {
        switch (f.getName()) {
            case "parser":
                assertNotNull(getFieldValue.apply(f, parser));
                break;
        }
    }
    // new with HTTPS JWKS
    parser = new DefaultOAuthJwtAccessTokenParser(baseKeyStore, "https://athenz-oauth-example.auth0.com/.well-known/jwks.json");
    assertNotNull(parser);
    for (Field f : parser.getClass().getDeclaredFields()) {
        switch (f.getName()) {
            case "parser":
                assertNotNull(getFieldValue.apply(f, parser));
                break;
        }
    }
}