TripDatesPresenter extends BasePresenter<TripDateView> { @Override public void subscribe() { if (editableTrip == null) { compositeDisposable.add(view.getStartDateChanges() .map(date -> new Date(date.getTime() + TimeUnit.DAYS.toMillis(userPreferenceManager.get(UserPreference.General.DefaultReportDuration)))) .subscribe(view.displayEndDate())); } } TripDatesPresenter(@NonNull TripDateView view, @NonNull UserPreferenceManager userPreferenceManager, @Nullable Trip editableTrip); @Override void subscribe();  }
@Test public void subscribeWithNullTripToEditUpdatesEndDateBasedOnSettings() throws Exception { final TripDatesPresenter presenter = new TripDatesPresenter(tripDateView, userPreferenceManager, null); presenter.subscribe(); verify(dateConsumer).accept(DATE_IN_5_DAYS); }
@Test public void subscribeWithNonNullTripToEditDoesNothing() throws Exception { final TripDatesPresenter presenter = new TripDatesPresenter(tripDateView, userPreferenceManager, trip); presenter.subscribe(); verifyZeroInteractions(dateConsumer); }