DefaultOAuthJwtAccessToken implements OAuthJwtAccessToken { public DefaultOAuthJwtAccessToken(Jws<Claims> jws) { this.body = jws.getBody(); this.signature = jws.getSignature(); } DefaultOAuthJwtAccessToken(Jws<Claims> jws); @Override String getSubject(); @Override String getIssuer(); @Override String getAudience(); @Override @SuppressWarnings("unchecked") List<String> getAudiences(); @Override String getClientId(); @Override String getCertificateThumbprint(); @Override String getScope(); @Override long getIssuedAt(); @Override long getExpiration(); @Override String getSignature(); @Override String toString();  }
@Test public void testDefaultOAuthJwtAccessToken() { BiFunction<Field, DefaultOAuthJwtAccessToken, Object> getFieldValue = (f, object) -> { JwtBuilder b = Jwts.builder().setSubject("Bob"); try { f.setAccessible(true); return f.get(object); } catch (IllegalArgumentException | IllegalAccessException e) { throw new RuntimeException(e); } }; Jws<Claims> jws = this.parser.parseClaimsJws(jwtString); DefaultOAuthJwtAccessToken at = new DefaultOAuthJwtAccessToken(jws); assertNotNull(at); for (Field f : at.getClass().getDeclaredFields()) { switch (f.getName()) { case "body": assertSame(getFieldValue.apply(f, at), jws.getBody()); break; case "signature": assertSame(getFieldValue.apply(f, at), jws.getSignature()); break; } } }