SettingsPresenter extends BasePresenter<SettingsContract.View> implements SettingsContract.Presenter { @Override public void setNewBookNotificationSubscriptionStatus(final boolean onOff) { checkViewAttached(); analytics.trackUserToggleNewBookNotifications(onOff); settings.setNewBookNotificationStatus(onOff).subscribe(new Observer<Boolean>() { @Override public void onCompleted() { } @Override public void onError(final Throwable e) { } @Override public void onNext(final Boolean aBoolean) { } }); } SettingsPresenter(TutorialsRepository repository, Analytics analytics, SettingsRepository settings); @Override void openTutorialScreen(); @Override void setNewBookNotificationSubscriptionStatus(final boolean onOff);  }
@Test public void setNewBookNotificationStatus_Subscribed_TurnsOff() { when(mockSettings.isSubscribedToNewBookNotification()).thenReturn(Single.just(true)); when(mockSettings.setNewBookNotificationStatus(anyBoolean())).thenReturn(Single.just(true)); presenter.setNewBookNotificationSubscriptionStatus(false); verify(mockSettings).setNewBookNotificationStatus(false); verify(mockAnalytics).trackUserToggleNewBookNotifications(false); }
@Test public void setNewBookNotificationStatus_Unsubscribed_TurnsOn() { when(mockSettings.isSubscribedToNewBookNotification()).thenReturn(Single.just(false)); when(mockSettings.setNewBookNotificationStatus(anyBoolean())).thenReturn(Single.just(true)); presenter.setNewBookNotificationSubscriptionStatus(true); verify(mockSettings).setNewBookNotificationStatus(true); verify(mockAnalytics).trackUserToggleNewBookNotifications(true); }