HomeContainerPresenter implements Presenter { @VisibleForTesting public void loadUserImage() { view.getLifecycleEvent() .filter(lifecycleEvent -> lifecycleEvent.equals(View.LifecycleEvent.CREATE)) .flatMap(created -> accountManager.accountStatus()) .flatMap(account -> getUserAvatar(account)) .observeOn(viewScheduler) .doOnNext(userAvatarUrl -> { if (userAvatarUrl != null) { view.setUserImage(userAvatarUrl); } else { view.setDefaultUserImage(); } view.showAvatar(); }) .compose(view.bindUntilEvent(View.LifecycleEvent.DESTROY)) .subscribe(__ -> { }, throwable -> { throw new OnErrorNotImplementedException(throwable); }); } 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 loadLoggedInUserImageUserTest() { when(account.getAvatar()).thenReturn("A string"); when(account.isLoggedIn()).thenReturn(true); presenter.loadUserImage(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); verify(view).setUserImage("A string"); verify(view).showAvatar(); }
@Test public void loadNotLoggedInUserImageUserTest() { when(account.isLoggedIn()).thenReturn(false); presenter.loadUserImage(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); verify(view).showAvatar(); }