ScheduleDay implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeSerializable(day); dest.writeTypedList(slots); } ScheduleDay(LocalDate day, List<ScheduleSlot> slots); protected  ScheduleDay(Parcel in); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Parcelable.Creator<ScheduleDay> CREATOR; }
@Test public void should_restore_from_parcelable() { LocalDate day = LocalDate.of(1985, 5, 15); List<ScheduleSlot> slots = singletonList(new ScheduleSlot(null, null)); ScheduleDay scheduleDay = new ScheduleDay(day, slots); Parcel parcel = Parcel.obtain(); scheduleDay.writeToParcel(parcel, 0); parcel.setDataPosition(0); ScheduleDay fromParcel = ScheduleDay.CREATOR.createFromParcel(parcel); assertThat(fromParcel.getDay()).isEqualTo(day); assertThat(fromParcel.getSlots()).hasSize(1); }