Schedule extends ArrayList<ScheduleDay> implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeTypedList(this); } Schedule(); protected  Schedule(Parcel in); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Parcelable.Creator<Schedule> CREATOR; }
@Test public void should_restore_from_parcelable() { Schedule schedule = new Schedule(); ScheduleDay day1 = new ScheduleDay(null, null); ScheduleDay day2 = new ScheduleDay(null, null); schedule.add(day1); schedule.add(day2); Parcel parcel = Parcel.obtain(); schedule.writeToParcel(parcel, 0); parcel.setDataPosition(0); Schedule fromParcel = Schedule.CREATOR.createFromParcel(parcel); assertThat(schedule).isEqualTo(fromParcel); assertThat(fromParcel).hasSize(2); }