TaskDetailPresenter implements TaskDetailContract.Presenter { @Override public void start() { openTask(); } TaskDetailPresenter(@NonNull UseCaseHandler useCaseHandler,
            @Nullable String taskId,
            @NonNull TaskDetailContract.View taskDetailView,
            @NonNull GetTask getTask,
            @NonNull CompleteTask completeTask,
            @NonNull ActivateTask activateTask,
            @NonNull DeleteTask deleteTask); @Override void start(); @Override void editTask(); @Override void deleteTask(); @Override void completeTask(); @Override void activateTask();  }
@Test public void getActiveTaskFromRepositoryAndLoadIntoView() { mTaskDetailPresenter = givenTaskDetailPresenter(ACTIVE_TASK.getId()); mTaskDetailPresenter.start(); verify(mTasksRepository).getTask(eq(ACTIVE_TASK.getId()), mGetTaskCallbackCaptor.capture()); verify(mTaskDetailView).setLoadingIndicator(true); mGetTaskCallbackCaptor.getValue().onTaskLoaded(ACTIVE_TASK); verify(mTaskDetailView).setLoadingIndicator(false); verify(mTaskDetailView).showTitle(TITLE_TEST); verify(mTaskDetailView).showDescription(DESCRIPTION_TEST); verify(mTaskDetailView).showCompletionStatus(false); }
@Test public void getCompletedTaskFromRepositoryAndLoadIntoView() { mTaskDetailPresenter = givenTaskDetailPresenter(COMPLETED_TASK.getId()); mTaskDetailPresenter.start(); verify(mTasksRepository).getTask( eq(COMPLETED_TASK.getId()), mGetTaskCallbackCaptor.capture()); verify(mTaskDetailView).setLoadingIndicator(true); mGetTaskCallbackCaptor.getValue().onTaskLoaded(COMPLETED_TASK); verify(mTaskDetailView).setLoadingIndicator(false); verify(mTaskDetailView).showTitle(TITLE_TEST); verify(mTaskDetailView).showDescription(DESCRIPTION_TEST); verify(mTaskDetailView).showCompletionStatus(true); }
@Test public void getUnknownTaskFromRepositoryAndLoadIntoView() { mTaskDetailPresenter = givenTaskDetailPresenter(INVALID_TASK_ID); mTaskDetailPresenter.start(); verify(mTaskDetailView).showMissingTask(); }
@Test public void getActiveTaskFromRepositoryAndLoadIntoView() { mTaskDetailPresenter = givenTaskDetailPresenter(ACTIVE_TASK.getId()); mTaskDetailPresenter.start(); verify(mTasksRepository).getTask(eq(ACTIVE_TASK.getId()), mGetTaskCallbackCaptor.capture()); InOrder inOrder = inOrder(mTaskDetailView); inOrder.verify(mTaskDetailView).setLoadingIndicator(true); mGetTaskCallbackCaptor.getValue().onTaskLoaded(ACTIVE_TASK); inOrder.verify(mTaskDetailView).setLoadingIndicator(false); verify(mTaskDetailView).showTitle(TITLE_TEST); verify(mTaskDetailView).showDescription(DESCRIPTION_TEST); verify(mTaskDetailView).showCompletionStatus(false); }
@Test public void getCompletedTaskFromRepositoryAndLoadIntoView() { mTaskDetailPresenter = givenTaskDetailPresenter(COMPLETED_TASK.getId()); mTaskDetailPresenter.start(); verify(mTasksRepository).getTask( eq(COMPLETED_TASK.getId()), mGetTaskCallbackCaptor.capture()); InOrder inOrder = inOrder(mTaskDetailView); inOrder.verify(mTaskDetailView).setLoadingIndicator(true); mGetTaskCallbackCaptor.getValue().onTaskLoaded(COMPLETED_TASK); inOrder.verify(mTaskDetailView).setLoadingIndicator(false); verify(mTaskDetailView).showTitle(TITLE_TEST); verify(mTaskDetailView).showDescription(DESCRIPTION_TEST); verify(mTaskDetailView).showCompletionStatus(true); }