HomeContainerPresenter implements Presenter { @VisibleForTesting public void checkForPromotionApps() { view.getLifecycleEvent() .filter(event -> event.equals(View.LifecycleEvent.CREATE)) .flatMapSingle(__ -> home.hasPromotionApps()) .filter(HomePromotionsWrapper::hasPromotions) .observeOn(viewScheduler) .doOnNext(apps -> { view.showPromotionsHomeIcon(apps); homeAnalytics.sendPromotionsImpressionEvent(); }) .filter(HomePromotionsWrapper::shouldShowDialog) .doOnNext(apps -> { homeAnalytics.sendPromotionsDialogImpressionEvent(); home.setPromotionsDialogShown(); view.showPromotionsHomeDialog(apps); }) .doOnError(Throwable::printStackTrace) .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY)) .subscribe(__ -> { }, err -> view.hidePromotionsIcon()); } HomeContainerPresenter(HomeContainerView view, Scheduler viewScheduler,
      AptoideAccountManager accountManager, HomeContainerNavigator homeContainerNavigator,
      HomeNavigator homeNavigator, HomeAnalytics homeAnalytics, Home home,
      ChipManager chipManager); @Override void present(); @VisibleForTesting void loadMainHomeContent(); @VisibleForTesting void loadUserImage(); @VisibleForTesting void handleUserImageClick(); @VisibleForTesting void handlePromotionsClick(); @VisibleForTesting void checkForPromotionApps(); @VisibleForTesting void handleClickOnPromotionsDialogContinue(); @VisibleForTesting void handleClickOnPromotionsDialogCancel(); @VisibleForTesting void handleLoggedInAcceptTermsAndConditions(); @VisibleForTesting void handleTermsAndConditionsContinueClicked(); @VisibleForTesting void handleTermsAndConditionsLogOutClicked(); @VisibleForTesting void handleClickOnTermsAndConditions(); @VisibleForTesting void handleClickOnPrivacyPolicy(); @VisibleForTesting void handleClickOnGamesChip(); @VisibleForTesting void handleClickOnAppsChip();  }
@Test public void hasPromotionAppsAndDialog_checkForPromotionAppsTest() { HomePromotionsWrapper homePromotionsWrapper = new HomePromotionsWrapper("", "", true, 2, 20f, true, ""); when(home.hasPromotionApps()).thenReturn(Single.just(homePromotionsWrapper)); presenter.checkForPromotionApps(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); verify(view).showPromotionsHomeIcon(homePromotionsWrapper); verify(homeAnalytics).sendPromotionsImpressionEvent(); verify(homeAnalytics).sendPromotionsDialogImpressionEvent(); verify(home).setPromotionsDialogShown(); verify(view).showPromotionsHomeDialog(homePromotionsWrapper); }
@Test public void hasPromotionAppsNoDialog_CheckForPromotionAppsTest() { HomePromotionsWrapper homePromotionsWrapper = new HomePromotionsWrapper("", "", true, 2, 20f, false, ""); when(home.hasPromotionApps()).thenReturn(Single.just(homePromotionsWrapper)); presenter.checkForPromotionApps(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); verify(view).showPromotionsHomeIcon(homePromotionsWrapper); verify(homeAnalytics).sendPromotionsImpressionEvent(); }