//@@author A0147996E

package guitests;

public class UndoCommandTest {

}

@@ -38,38 +38,2750 @@
 s;%0A%0A
-public class UndoCommandTest %7B%0A
+import static org.junit.Assert.assertTrue;%0Aimport static seedu.address.logic.commands.FinishCommand.MESSAGE_FINISH_TASK_SUCCESS;%0A%0Aimport org.junit.Test;%0A%0Aimport seedu.address.testutil.TestEvent;%0Aimport seedu.address.testutil.TestTask;%0Aimport seedu.address.testutil.TestUtil;%0A%0Apublic class UndoCommandTest extends TaskManagerGuiTest %7B%0A    @Test%0A    public void finishUndoTest() %7B%0A        //add some events in first%0A        TestTask%5B%5D currentList = td.getTypicalTasks();%0A        currentList = TestUtil.addEventsToList(currentList, te.assignment, te.gym);%0A        TestEvent eventToAdd = te.assignment;%0A        commandBox.runCommand(eventToAdd.getAddCommand());%0A        eventToAdd = te.gym;%0A        commandBox.runCommand(eventToAdd.getAddCommand());%0A%0A        //finish unfinished task in list all%0A        int targetIndex = 1;%0A        assertFinishSuccess(targetIndex, currentList);%0A%0A        //finish tasks or events under a specific list%0A        commandBox.runCommand(%22list personal%22);%0A        targetIndex = 1;%0A        assertFinishSuccess(targetIndex, new TestTask%5B%5D %7Btd.gym, te.gym, td.gym2, td.gym3, td.date%7D);%0A        targetIndex = 2;%0A        assertFinishSuccess(targetIndex, new TestTask%5B%5D %7Bte.gym, td.gym2, td.gym3, td.date%7D);%0A%0A        commandBox.runCommand(%22undo%22);%0A        commandBox.runCommand(%22list personal%22);%0A        TestTask%5B%5D expectedTasks = new TestTask%5B%5D %7Bte.gym, td.gym2, td.gym3, td.date%7D;%0A        assertTrue(taskListPanel.isListMatching(expectedTasks));%0A%0A        commandBox.runCommand(%22finish 2%22);%0A        commandBox.runCommand(%22undo%22);%0A        commandBox.runCommand(%22list personal%22);%0A        expectedTasks = new TestTask%5B%5D %7Bte.gym, td.gym2, td.gym3, td.date%7D;%0A        assertTrue(taskListPanel.isListMatching(expectedTasks));%0A    %7D%0A%0A    /**%0A     * Runs the finish command to finish the task at specified index and confirms the result is correct.%0A     * @param targetIndexOneIndexed e.g. index 1 to finish the first task in the list,%0A     * @param currentList A copy of the current unfinished list of tasks (before finish command).%0A     */%0A    private void assertFinishSuccess(int targetIndexOneIndexed, final TestTask%5B%5D currentList) %7B%0A        TestTask taskToFinish = currentList%5BtargetIndexOneIndexed - 1%5D; // -1 as array uses zero indexing%0A        TestTask%5B%5D expectedRemainder = TestUtil.removeTaskFromList(currentList, targetIndexOneIndexed);%0A        commandBox.runCommand(%22finish %22 + targetIndexOneIndexed);%0A%0A        //confirm the list now contains all previous tasks except the finished task%0A        assertTrue(taskListPanel.isListMatching(expectedRemainder));%0A%0A        //confirm the result message is correct%0A        assertResultMessage(String.format(MESSAGE_FINISH_TASK_SUCCESS, taskToFinish.toString() + %22 finished%22));%0A    %7D
 %0A%7D%0A

Add testcases to UndoCommandTest - undoFinish