EditorialListPresenter 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 -> crashReporter.log(throwable)); } EditorialListPresenter(EditorialListView editorialListView,
      EditorialListManager editorialListManager, AptoideAccountManager accountManager,
      EditorialListNavigator editorialListNavigator, EditorialListAnalytics editorialListAnalytics,
      CrashReport crashReporter, Scheduler viewScheduler,
      UserFeedbackAnalytics userFeedbackAnalytics); @Override void present(); @VisibleForTesting void onCreateLoadViewModel(); @VisibleForTesting void loadUserImage(); @VisibleForTesting void handleEditorialCardClick(); @VisibleForTesting void handlePullToRefresh(); @VisibleForTesting void handleRetryClick(); @VisibleForTesting void handleImpressions(); @VisibleForTesting void handleBottomReached(); @VisibleForTesting void handleUserImageClick(); @VisibleForTesting void handleReactionButtonClick(); @VisibleForTesting void handleUserReaction(); @VisibleForTesting void handleSnackLogInClick();  }
@Test public void loadLoggedInUserImageUserTest() { when(account.getAvatar()).thenReturn("A string"); when(account.isLoggedIn()).thenReturn(true); presenter.loadUserImage(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); accountStatusEvent.onNext(account); verify(view).setUserImage("A string"); verify(view).showAvatar(); }
@Test public void loadNotLoggedInUserImageUserTest() { when(account.isLoggedIn()).thenReturn(false); presenter.loadUserImage(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); accountStatusEvent.onNext(account); verify(view).showAvatar(); }