SchedulePagerPresenter extends BaseFragmentPresenter<SchedulePagerMvp.View> implements SchedulePagerMvp.Presenter { @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (schedule == null) { loadData(); } else { this.view.displaySchedule(schedule); } } SchedulePagerPresenter(SchedulePagerMvp.View view, DataProvider dataProvider); @Override void onViewCreated(View view, @Nullable Bundle savedInstanceState); @Override void reloadData(); @Override void onStop();  }
@Test public void should_load_schedule_when_view_is_created() { Schedule schedule = new Schedule(); when(dataProvider.getSchedule()).thenReturn(Observable.just(schedule)); presenter.onViewCreated(null, null); schedulerProxy.advanceBy(1, TimeUnit.MINUTES); assertThat(presenter.schedule).isSameAs(schedule); verify(view).displaySchedule(schedule); }
@Test public void should_restore_schedule_when_state_changes() { Schedule schedule = new Schedule(); presenter.schedule = schedule; presenter.onViewCreated(null, new Bundle()); verify(view).displaySchedule(schedule); }