Speaker implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(id); dest.writeString(name); dest.writeString(title); dest.writeString(bio); dest.writeString(website); dest.writeString(twitter); dest.writeString(github); dest.writeString(photo); } Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo); protected  Speaker(Parcel in); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Parcelable.Creator<Speaker> CREATOR; }
@Test public void should_restore_from_parcelable() { Speaker speaker = new Speaker(24, "Name", "Title", "Bio", "website", "Twitter", "Github", "photoUrl"); Parcel parcel = Parcel.obtain(); speaker.writeToParcel(parcel, 0); parcel.setDataPosition(0); Speaker fromParcel = Speaker.CREATOR.createFromParcel(parcel); assertThat(fromParcel.getId()).isEqualTo(24); assertThat(fromParcel.getName()).isEqualTo("Name"); assertThat(fromParcel.getTitle()).isEqualTo("Title"); assertThat(fromParcel.getBio()).isEqualTo("Bio"); assertThat(fromParcel.getWebsite()).isEqualTo("website"); assertThat(fromParcel.getTwitter()).isEqualTo("Twitter"); assertThat(fromParcel.getGithub()).isEqualTo("Github"); assertThat(fromParcel.getPhoto()).isEqualTo("photoUrl"); }