MoreBundlePresenter implements Presenter { @VisibleForTesting public void handleAppClick() { view.getLifecycleEvent() .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE)) .flatMap(created -> view.appClicked() .doOnNext(click -> { ChipManager.Chip chip = chipManager.getCurrentChip(); homeAnalytics.sendTapOnAppInteractEvent(click.getApp() .getRating(), click.getApp() .getPackageName(), click.getAppPosition(), click.getBundlePosition(), click.getBundle() .getTag(), click.getBundle() .getContent() .size(), chip != null ? chip.getName() : null); if (chip != null) { homeAnalytics.sendChipTapOnApp(click.getBundle() .getTag(), click.getApp() .getPackageName(), chip.getName()); } }) .observeOn(viewScheduler) .doOnNext(click -> { Application app = click.getApp(); homeNavigator.navigateToAppView(app.getAppId(), app.getPackageName(), app.getTag()); }) .retry()) .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY)) .subscribe(homeClick -> { }, throwable -> { throw new OnErrorNotImplementedException(throwable); }); } MoreBundlePresenter(MoreBundleView view, MoreBundleManager moreBundleManager,
      Scheduler viewScheduler, CrashReport crashReporter, HomeNavigator homeNavigator,
      AdMapper adMapper, BundleEvent bundleEvent, HomeAnalytics homeAnalytics,
      ChipManager chipManager); @Override void present(); @VisibleForTesting void onCreateSetupToolbar(); @VisibleForTesting void onCreateLoadBundles(); @VisibleForTesting void handleAppClick(); @VisibleForTesting void handleAdClick(); @VisibleForTesting void handleMoreClick(); @VisibleForTesting void handleBundleScrolledRight(); @VisibleForTesting void handleBottomReached(); @VisibleForTesting void handlePullToRefresh(); @VisibleForTesting void handleRetryClick();  }
@Test public void appClicked_NavigateToAppView() { presenter.handleAppClick(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); appClickEvent.onNext(new AppHomeEvent(aptoide, 1, localTopAppsBundle, 3, HomeEvent.Type.APP)); verify(homeNavigator).navigateToAppView(aptoide.getAppId(), aptoide.getPackageName(), aptoide.getTag()); verify(homeAnalytics).sendTapOnAppInteractEvent(aptoide.getRating(), aptoide.getPackageName(), 1, 3, localTopAppsBundle.getTag(), localTopAppsBundle.getContent() .size(), null); }
@Test public void appClicked_GamesChipAnalytics() { when(chipManager.getCurrentChip()).thenReturn(ChipManager.Chip.GAMES); presenter.handleAppClick(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); appClickEvent.onNext(new AppHomeEvent(aptoide, 1, localTopAppsBundle, 3, HomeEvent.Type.APP)); verify(homeAnalytics).sendChipTapOnApp(localTopAppsBundle.getTag(), aptoide.getPackageName(), ChipManager.Chip.GAMES.getName()); verify(homeAnalytics).sendTapOnAppInteractEvent(aptoide.getRating(), aptoide.getPackageName(), 1, 3, localTopAppsBundle.getTag(), localTopAppsBundle.getContent() .size(), ChipManager.Chip.GAMES.getName()); }
@Test public void appClicked_AppsChipAnalytics() { when(chipManager.getCurrentChip()).thenReturn(ChipManager.Chip.APPS); presenter.handleAppClick(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); appClickEvent.onNext(new AppHomeEvent(aptoide, 1, localTopAppsBundle, 3, HomeEvent.Type.APP)); verify(homeAnalytics).sendChipTapOnApp(localTopAppsBundle.getTag(), aptoide.getPackageName(), ChipManager.Chip.APPS.getName()); verify(homeAnalytics).sendTapOnAppInteractEvent(aptoide.getRating(), aptoide.getPackageName(), 1, 3, localTopAppsBundle.getTag(), localTopAppsBundle.getContent() .size(), ChipManager.Chip.APPS.getName()); }