package ca.six.todo.tasks;

import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import ca.six.todo.data.Task;
import ca.six.todo.data.source.TasksDataSource;
import ca.six.todo.data.source.TasksRepository;
import static org.junit.Assert.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;

public class TasksPresenterTest {
    @Mock TasksContract.View view;
    @Mock TasksRepository repo;
    @Captor ArgumentCaptor<TasksDataSource.LoadTasksCallback> captor;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        when(view.isActive()).thenReturn(true);
    }

    @Test
    public void testFirstEnters_listShouldBeEmpty(){
        TasksPresenter presenter = new TasksPresenter(repo, view);
        presenter.start();

        verify(view).setLoadingIndicator(true);
        verify(repo).refreshTasks();

        verify(repo).getTasks(captor.capture());
        captor.getValue().onTasksLoaded(new ArrayList<Task>());

        // default filter is : All_Tasks
        verify(view).showNoTasks();
    }

}

@@ -466,16 +466,64 @@
 rayList;
+%0Aimport java.util.Arrays;%0Aimport java.util.List;
 %0A%0Apublic
@@ -1267,10 +1267,905 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testFirstEnters_getDataFailed()%7B%0A        TasksPresenter presenter = new TasksPresenter(repo, view);%0A        presenter.start();%0A%0A        verify(repo).getTasks(captor.capture());%0A        captor.getValue().onDataNotAvailable();%0A%0A        verify(view).showLoadingTasksError();%0A    %7D%0A    @Test%0A    public void showMultipleTasks()%7B%0A        TasksPresenter presenter = new TasksPresenter(repo, view);%0A        presenter.start();%0A%0A        Task%5B%5D tmp = new Task%5B%5D%7B%0A                new Task(%2201%22,%22u%22, false),%0A                new Task(%2202%22,%22%22, false),%0A                new Task(%2203%22,%22%22, true),%0A                new Task(%2204%22,%22x%22, false)%0A        %7D;%0A        List%3CTask%3E tasks = Arrays.asList(tmp);%0A%0A        verify(repo).getTasks(captor.capture());%0A        captor.getValue().onTasksLoaded(tasks);%0A%0A        verify(view).showTasks(tasks);%0A        verify(view).showAllFilterLabel();%0A%0A    %7D%0A%0A%0A
 %7D%0A

write unit test code