@Test public void handleAlert() throws Exception { doAnswer(invocation -> null).when(fragment).unMuteSense(); doAnswer(invocation -> null).when(fragment).startDevicesActivity(); fragment.handleAlert(Category.SENSE_MUTED); verify(fragment, times(1)).unMuteSense(); fragment.handleAlert(Category.SENSE_NOT_PAIRED); fragment.handleAlert(Category.SENSE_NOT_PAIRED); fragment.handleAlert(Category.SLEEP_PILL_NOT_PAIRED); fragment.handleAlert(Category.SLEEP_PILL_NOT_SEEN); verify(fragment, times(4)).startDevicesActivity(); }
@Override public void handleAlert(@NonNull final Category alertCategory) { switch (alertCategory) { case SENSE_MUTED: this.unMuteSense(); break; case REVIEW_ACCOUNTS_PAIRED_TO_SENSE: break; case SENSE_NOT_PAIRED: case SENSE_NOT_SEEN: case SLEEP_PILL_NOT_PAIRED: case SLEEP_PILL_NOT_SEEN: this.startDevicesActivity(); break; case EXPANSION_UNREACHABLE: case UNKNOWN: break; default: throw new IllegalStateException("unhandled alert category " + alertCategory); } }
HomePresenterFragment extends PresenterFragment<HomeView> implements
        OnBackPressedInterceptor,
        HomeTabLayout.Listener,
        TimelineFragment.ParentProvider,
        InsightInfoFragment.ParentProvider,
        Alert.ActionHandler { @Override public void handleAlert(@NonNull final Category alertCategory) { switch (alertCategory) { case SENSE_MUTED: this.unMuteSense(); break; case REVIEW_ACCOUNTS_PAIRED_TO_SENSE: break; case SENSE_NOT_PAIRED: case SENSE_NOT_SEEN: case SLEEP_PILL_NOT_PAIRED: case SLEEP_PILL_NOT_SEEN: this.startDevicesActivity(); break; case EXPANSION_UNREACHABLE: case UNKNOWN: break; default: throw new IllegalStateException("unhandled alert category " + alertCategory); } } }
HomePresenterFragment extends PresenterFragment<HomeView> implements
        OnBackPressedInterceptor,
        HomeTabLayout.Listener,
        TimelineFragment.ParentProvider,
        InsightInfoFragment.ParentProvider,
        Alert.ActionHandler { @Override public void handleAlert(@NonNull final Category alertCategory) { switch (alertCategory) { case SENSE_MUTED: this.unMuteSense(); break; case REVIEW_ACCOUNTS_PAIRED_TO_SENSE: break; case SENSE_NOT_PAIRED: case SENSE_NOT_SEEN: case SLEEP_PILL_NOT_PAIRED: case SLEEP_PILL_NOT_SEEN: this.startDevicesActivity(); break; case EXPANSION_UNREACHABLE: case UNKNOWN: break; default: throw new IllegalStateException("unhandled alert category " + alertCategory); } }  }
HomePresenterFragment extends PresenterFragment<HomeView> implements
        OnBackPressedInterceptor,
        HomeTabLayout.Listener,
        TimelineFragment.ParentProvider,
        InsightInfoFragment.ParentProvider,
        Alert.ActionHandler { @Override public void handleAlert(@NonNull final Category alertCategory) { switch (alertCategory) { case SENSE_MUTED: this.unMuteSense(); break; case REVIEW_ACCOUNTS_PAIRED_TO_SENSE: break; case SENSE_NOT_PAIRED: case SENSE_NOT_SEEN: case SLEEP_PILL_NOT_PAIRED: case SLEEP_PILL_NOT_SEEN: this.startDevicesActivity(); break; case EXPANSION_UNREACHABLE: case UNKNOWN: break; default: throw new IllegalStateException("unhandled alert category " + alertCategory); } }  static HomePresenterFragment newInstance(@Nullable final Bundle args); @Override void initializePresenterView(); @Override void onViewCreated(final View view,
                              final Bundle savedInstanceState); @Override void onPause(); @Override void onResume(); @Override boolean onInterceptBackPressed(@NonNull final Runnable defaultBehavior); @Override void scrollUp(final int fragmentPosition); @Override void tabChanged(final int fragmentPosition); @Nullable @Override Timeline getCurrentTimeline(); @Nullable @Override TimelineFragment.Parent getTimelineParent(); @Nullable @Override InsightInfoFragment.Parent provideInsightInfoParent(); @Override void handleAlert(@NonNull final Category alertCategory); void forwardNotification(@NonNull final Notification notification); void showProgressOverlay(final boolean show); void jumpToLastNight(); void checkInForUpdates(); int getCurrentTabPosition(); void selectTimelineTab(); void selectTrendsTab(); void selectFeedTab(); void selectSoundTab(); void selectConditionsTab(); }
HomePresenterFragment extends PresenterFragment<HomeView> implements
        OnBackPressedInterceptor,
        HomeTabLayout.Listener,
        TimelineFragment.ParentProvider,
        InsightInfoFragment.ParentProvider,
        Alert.ActionHandler { @Override public void handleAlert(@NonNull final Category alertCategory) { switch (alertCategory) { case SENSE_MUTED: this.unMuteSense(); break; case REVIEW_ACCOUNTS_PAIRED_TO_SENSE: break; case SENSE_NOT_PAIRED: case SENSE_NOT_SEEN: case SLEEP_PILL_NOT_PAIRED: case SLEEP_PILL_NOT_SEEN: this.startDevicesActivity(); break; case EXPANSION_UNREACHABLE: case UNKNOWN: break; default: throw new IllegalStateException("unhandled alert category " + alertCategory); } }  static HomePresenterFragment newInstance(@Nullable final Bundle args); @Override void initializePresenterView(); @Override void onViewCreated(final View view,
                              final Bundle savedInstanceState); @Override void onPause(); @Override void onResume(); @Override boolean onInterceptBackPressed(@NonNull final Runnable defaultBehavior); @Override void scrollUp(final int fragmentPosition); @Override void tabChanged(final int fragmentPosition); @Nullable @Override Timeline getCurrentTimeline(); @Nullable @Override TimelineFragment.Parent getTimelineParent(); @Nullable @Override InsightInfoFragment.Parent provideInsightInfoParent(); @Override void handleAlert(@NonNull final Category alertCategory); void forwardNotification(@NonNull final Notification notification); void showProgressOverlay(final boolean show); void jumpToLastNight(); void checkInForUpdates(); int getCurrentTabPosition(); void selectTimelineTab(); void selectTrendsTab(); void selectFeedTab(); void selectSoundTab(); void selectConditionsTab(); static final String TAG; }