### Question:
OktaIdToken { public static OktaIdToken parseIdToken(@NonNull String token) throws IllegalArgumentException { String[] sections = token.split("\\."); if (sections.length < NUMBER_OF_SECTIONS) { throw new IllegalArgumentException("IdToken missing header, claims or" + " signature section"); } Gson gson = new GsonBuilder().registerTypeAdapterFactory(ArrayTypeAdapter.CREATE).create(); String headerSection = new String(Base64.decode(sections[0], Base64.URL_SAFE)); Header header = gson.fromJson(headerSection, Header.class); String claimsSection = new String(Base64.decode(sections[1], Base64.URL_SAFE)); Claims claims = gson.fromJson(claimsSection, Claims.class); String signature = new String(Base64.decode(sections[2], Base64.URL_SAFE)); return new OktaIdToken(header, claims, signature); } private  OktaIdToken(Header header, Claims claims, String signature); Header getHeader(); Claims getClaims(); String getSignature(); @RestrictTo(RestrictTo.Scope.LIBRARY) void validate(TokenRequest request, Clock clock); static OktaIdToken parseIdToken(@NonNull String token);  }### Answer:
@Test public void parseValidIdToken() { OktaIdToken token = OktaIdToken.parseIdToken(JsonStrings.VALID_ID_TOKEN); assertNotNull(token.mClaims); assertNotNull(token.mSignature); assertNotNull(token.mHeader); assertEquals("RS256", token.mHeader.alg); }
@Test public void parseInvalidIdToken() { mExpectedEx.expect(IllegalArgumentException.class); OktaIdToken.parseIdToken(JsonStrings.INVALID_ID_TOKEN); }