AddEditTaskPresenter implements AddEditTaskContract.Presenter,
        TasksDataSource.GetTaskCallback { @Override public void createTask(String title, String description) { Task newTask = new Task(title, description); if (newTask.isEmpty()) { mAddTaskView.showEmptyTaskError(); } else { mTasksRepository.saveTask(newTask); mAddTaskView.showTasksList(); } } AddEditTaskPresenter(@Nullable String taskId, @NonNull TasksDataSource tasksRepository,
            @NonNull AddEditTaskContract.View addTaskView); @Override void start(); @Override void createTask(String title, String description); @Override void updateTask(String title, String description); @Override void populateTask(); @Override void onTaskLoaded(Task task); @Override void onDataNotAvailable();  }
@Test public void saveNewTaskToRepository_showsSuccessMessageUi() { mAddEditTaskPresenter = new AddEditTaskPresenter("1", mTasksRepository, mAddEditTaskView); mAddEditTaskPresenter.createTask("New Task Title", "Some Task Description"); verify(mTasksRepository).saveTask(any(Task.class)); verify(mAddEditTaskView).showTasksList(); }
@Test public void saveTask_emptyTaskShowsErrorUi() { mAddEditTaskPresenter = new AddEditTaskPresenter(null, mTasksRepository, mAddEditTaskView); mAddEditTaskPresenter.createTask("", ""); verify(mAddEditTaskView).showEmptyTaskError(); }