OAuth2Token extends AuthToken implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { out.writeString(tokenType); out.writeString(accessToken); } OAuth2Token(String tokenType, String accessToken);  OAuth2Token(String tokenType, String accessToken, long createdAt); private  OAuth2Token(Parcel in); String getTokenType(); String getAccessToken(); @Override boolean isExpired(); @Override int describeContents(); @Override void writeToParcel(Parcel out, int flags); @Override boolean equals(Object o); @Override int hashCode(); static final String TOKEN_TYPE_BEARER; static final Parcelable.Creator<OAuth2Token> CREATOR; }
@Test public void testParcelable() { final OAuth2Token authToken = new OAuth2Token(TOKEN_TYPE, ACCESS_TOKEN); final Parcel parcel = Parcel.obtain(); authToken.writeToParcel(parcel, 0); parcel.setDataPosition(0); final OAuth2Token parceledAuthToken = OAuth2Token.CREATOR.createFromParcel(parcel); assertEquals(authToken, parceledAuthToken); }