package guitests;

import static org.junit.Assert.assertTrue;

import java.text.ParseException;

import org.junit.Test;

import guitests.guihandles.TaskCardHandle;
import seedu.tasklist.commons.core.Messages;
import seedu.tasklist.commons.exceptions.IllegalValueException;
import seedu.tasklist.logic.commands.SortCommand;
import seedu.tasklist.testutil.DeadlineTaskBuilder;
import seedu.tasklist.testutil.EventTaskBuilder;
import seedu.tasklist.testutil.FloatingTaskBuilder;
import seedu.tasklist.testutil.TestTask;
//@@author A0141993X
public class SortCommandTest extends TaskListGuiTest {


    @Test
    public void sort_invalidParameter_errorMessageShown() {
        String command = "sort a";
        commandBox.runCommand(command);
        assertResultMessage(String.format(SortCommand.MESSAGE_FAILURE));
    }

    @Test
    public void sort_moreThanOneParameter_errorMessageShown() {
        String command = "sort n p";
        commandBox.runCommand(command);
        assertResultMessage(String.format(SortCommand.MESSAGE_FAILURE));
    }

    @Test
    public void sort_invalidCommand_errorMessageShown() {
        commandBox.runCommand("sorts newTask");
        assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);
    }

    @Test
    public void sort() {
        //sort by name
        TestTask[] expectedListName = {td.groceries, td.tutorial, td.homework, td.drink, td.project, td.java};
        String commandName = "sort n";
        commandBox.runCommand(commandName);
        assertSortSuccess(expectedListName);

        //sort by date
        TestTask[] expectedListDate = {td.tutorial, td.project, td.groceries, td.homework, td.drink, td.java };
        String commandDate = "sort d";
        commandBox.runCommand(commandDate);
        assertResultMessage(SortCommand.MESSAGE_SUCCESS);
        assertSortSuccess(expectedListDate);

        //sort by start priority
        TestTask[] expectedListPriority = {td.tutorial, td.project, td.drink, td.java, td.groceries, td.homework};
        String commandPriority = "sort p";
        commandBox.runCommand(commandPriority);
        assertResultMessage(SortCommand.MESSAGE_SUCCESS);
        assertSortSuccess(expectedListPriority);

        //sort by date after adding floating task
        try {
            TestTask floatingTaskToAdd = new FloatingTaskBuilder().withName("Shop clothes")
                    .withTags("shopping").withComment("save money")
                    .withPriority("low").withStatus(false).build();
            TestTask[] expectedListAddFloating = {td.tutorial, td.project, td.drink,
                                                  td.java, td.groceries, td.homework, floatingTaskToAdd};
            commandBox.runCommand(floatingTaskToAdd.getAddCommand());
            commandBox.runCommand("sort d");
            assertResultMessage(SortCommand.MESSAGE_SUCCESS);
            assertSortSuccess(expectedListAddFloating);
        } catch (IllegalValueException e) {
            e.printStackTrace();
        }
    }

    private void assertSortSuccess(TestTask... expectedList) {
        //confirm list contains all tasks in the correct sorted order
        assertTrue(taskListPanel.isListMatching(expectedList));
    }
}

@@ -67,101 +67,24 @@
 ort 
-java.text.ParseException;%0A%0Aimport org.junit.Test;%0A%0Aimport guitests.guihandles.TaskCardHandle;
+org.junit.Test;%0A
 %0Aimp
@@ -243,109 +243,8 @@
 nd;%0A
-import seedu.tasklist.testutil.DeadlineTaskBuilder;%0Aimport seedu.tasklist.testutil.EventTaskBuilder;%0A
 impo

Remove unused imports