package guitests;

import seedu.taskman.model.event.Activity;
import seedu.taskman.model.event.Task;
import seedu.taskman.testutil.TestTask;

import static org.junit.Assert.assertTrue;

public class ClearCommandTest extends TaskManGuiTest {

    //@Test
    public void clear() {

        //verify a non-empty list can be cleared
        TestTask[] currentList = testTasks.getTypicalTasks();
        Activity[] expectedList = new Activity[currentList.length];
        for (int i = 0; i < expectedList.length; i++) {
            expectedList[i] = new Activity(new Task(currentList[i]));
        }
        assertTrue(deadlineListPanel.isListMatching(expectedList));
        assertClearCommandSuccess();

        //verify other commands can work after a clear command
        commandBox.runCommand(testTasks.taskCS2102.getAddCommand());
        assertTrue(deadlineListPanel.isListMatching(new Activity(new Task(testTasks.taskCS2102))));
        commandBox.runCommand("delete 1");
        assertDeadlineListSize(0);

        //verify clear command works when the list is empty
        assertClearCommandSuccess();
    }

    private void assertClearCommandSuccess() {
        commandBox.runCommand("clear");
        assertDeadlineListSize(0);
        assertResultMessage("Task man has been cleared!");
    }
}

@@ -12,16 +12,39 @@
 tests;%0A%0A
+import org.junit.Test;%0A
 import s
@@ -78,16 +78,16 @@
 tivity;%0A
-
 import s
@@ -156,16 +156,80 @@
 estTask;
+%0Aimport seedu.taskman.testutil.TestUtil;%0A%0Aimport java.util.List;
 %0A%0Aimport
@@ -326,18 +326,16 @@
  %7B%0A%0A    
-//
 @Test%0A  
@@ -416,24 +416,29 @@
         
+List%3C
 TestTask
 %5B%5D curre
@@ -429,18 +429,17 @@
 TestTask
-%5B%5D
+%3E
  current
@@ -445,16 +445,32 @@
 tList = 
+TestUtil.asList(
 testTask
@@ -488,16 +488,17 @@
 lTasks()
+)
 ;%0A      
@@ -529,21 +529,36 @@
 t = 
-new Activity%5B
+TestUtil.getActivitiesArray(
 curr
@@ -568,16 +568,9 @@
 List
-.length%5D
+)
 ;%0A  
@@ -579,135 +579,56 @@
     
-for (int i = 0; i %3C expectedList.length; i++) %7B%0A            expectedList%5Bi%5D = new Activity(new Task(currentList%5Bi%5D));%0A        %7D
+TestUtil.sortActivitiesByDeadline(expectedList);
 %0A   
@@ -958,24 +958,24 @@
 CS2102))));%0A
-
         comm
@@ -1000,16 +1000,17 @@
 %22delete 
+d
 1%22);%0A   

Fix ClearCommandTest