package guitests;
// @@author A0160076L
import static org.junit.Assert.assertEquals;

import org.junit.Test;

import seedu.doit.model.item.ReadOnlyTask;

public class SelectCommandTest extends TaskManagerGuiTest {


    @Test
    public void selectTask_nonEmptyList() {
        assertSelectionInvalid(30); // invalid index
        assertNoTaskSelected();
        //assertSelectionSuccess(1); // first task in the list
        int taskCount = this.td.getTypicalTasks().length;
        //assertSelectionSuccess(taskCount); // last task in the list
        int middleIndex = taskCount / 2;
        //assertSelectionSuccess(middleIndex); // a task in the middle of the list
        //assertSelectionInvalid(taskCount + 1); // invalid index
        //assertTaskSelected(middleIndex); // assert previous selection remains

        /* Testing other invalid indexes such as -1 should be done when testing the SelectCommand */
    }
    private void getExpectedSelect(){
        ReadOnlyTask task =  this.model.getFilteredTaskList().get(this.index - 1);
        String taskDetails = "Name: \t\t\t".concat(task.getName().toString()).concat("\n").
                concat("Description: \t\t").concat(task.getDescription().toString()).concat("\n").
                concat("Priority: \t\t\t").concat(task.getPriority().toString()).concat("\n");
        if (task.hasStartTime()) {
            taskDetails = taskDetails.concat("Start Time: \t\t").concat(task.getStartTime().toString()).concat("\n");
        }
        if (task.hasEndTime()) {
            taskDetails = taskDetails.concat("End Time: \t\t").concat(task.getDeadline().toString()).concat("\n");
        }
        //tag not yet implemented
        return firstLine.concat("\n\n").concat(taskDetails);
    }

    @Test
    public void selectTask_emptyList() {
        this.commandBox.runCommand("clear");
        assertListSize(0);
        assertSelectionInvalid(1); //invalid index
    }

    private void assertSelectionInvalid(int index) {
        this.commandBox.runCommand("select " + index);
        assertResultMessage("The task index provided is invalid");
    }

    private void assertSelectionSuccess(int index) {
        this.commandBox.runCommand("select " + index);
        assertResultMessage("Selected Task: " + index);
        assertTaskSelected(index);
    }

    private void assertTaskSelected(int index) {
        assertEquals(this.taskListPanel.getSelectedTasks().size(), 1);
        ReadOnlyTask selectedTask = this.taskListPanel.getSelectedTasks().get(0);
        assertEquals(this.taskListPanel.getTask(index - 1), selectedTask);
    }


        //TODO: confirm the correct page is loaded in the Browser Panel



    private void assertNoTaskSelected() {
        assertEquals(this.taskListPanel.getSelectedTasks().size(), 0);
    }
    //@@author

}

@@ -920,837 +920,8 @@
    %7D
-%0A    private void getExpectedSelect()%7B%0A        ReadOnlyTask task =  this.model.getFilteredTaskList().get(this.index - 1);%0A        String taskDetails = %22Name: %5Ct%5Ct%5Ct%22.concat(task.getName().toString()).concat(%22%5Cn%22).%0A                concat(%22Description: %5Ct%5Ct%22).concat(task.getDescription().toString()).concat(%22%5Cn%22).%0A                concat(%22Priority: %5Ct%5Ct%5Ct%22).concat(task.getPriority().toString()).concat(%22%5Cn%22);%0A        if (task.hasStartTime()) %7B%0A            taskDetails = taskDetails.concat(%22Start Time: %5Ct%5Ct%22).concat(task.getStartTime().toString()).concat(%22%5Cn%22);%0A        %7D%0A        if (task.hasEndTime()) %7B%0A            taskDetails = taskDetails.concat(%22End Time: %5Ct%5Ct%22).concat(task.getDeadline().toString()).concat(%22%5Cn%22);%0A        %7D%0A        //tag not yet implemented%0A        return firstLine.concat(%22%5Cn%5Cn%22).concat(taskDetails);%0A    %7D
 %0A%0A  

Fix travis error