@@ -0,0 +1,2974 @@
+package linenux.command;%0A%0Aimport static junit.framework.TestCase.assertFalse;%0Aimport static junit.framework.TestCase.assertTrue;%0Aimport static linenux.helpers.Assert.assertChangeBy;%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.util.ArrayList;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport linenux.command.result.CommandResult;%0Aimport linenux.model.Schedule;%0Aimport linenux.model.Task;%0A%0A/**%0A * JUnit test for view command.%0A */%0Apublic class ClearCommandTest %7B%0A    private Schedule schedule;%0A    private ClearCommand clearCommand;%0A    private Task task1;%0A    private Task task2;%0A    private Task task3;%0A    private ArrayList%3CString%3E tags;%0A%0A    @Before%0A    public void setupListCommand() %7B%0A        this.schedule = new Schedule();%0A        this.clearCommand = new ClearCommand(this.schedule);%0A%0A        this.tags = new ArrayList%3C%3E();%0A        tags.add(%22hello%22);%0A%0A        this.task1 = new Task(%22Task 1%22);%0A        this.task2 = new Task(%22Task 2%22);%0A        this.task3 = new Task(%22Task 3%22, tags);%0A%0A        this.task2 = this.task2.markAsDone();%0A%0A        this.schedule.addTask(task1);%0A        this.schedule.addTask(task2);%0A        this.schedule.addTask(task3);%0A    %7D%0A%0A    /**%0A     * Test that command responds to the correct format.%0A     */%0A    @Test%0A    public void testRespondToViewWithKeywords() %7B%0A        assertTrue(this.clearCommand.respondTo(%22clear #/hashtag%22));%0A    %7D%0A%0A    /**%0A     * Test that command is case insensitive.%0A     */%0A    @Test%0A    public void testCaseInsensitiveRespondToView() %7B%0A        assertTrue(this.clearCommand.respondTo(%22ClEaR #/hashtag%22));%0A    %7D%0A%0A    /**%0A     * Test that command does not respond to other commands.%0A     */%0A    @Test%0A    public void testDoesNotRespondToOtherCommands() %7B%0A        assertFalse(this.clearCommand.respondTo(%22notclear%22));%0A    %7D%0A%0A    /**%0A     * Test the result when there are no tasks to clear.%0A     */%0A    @Test%0A    public void testCommandResultWhenNoTaskToClear() %7B%0A        this.schedule.clear();%0A        CommandResult result = this.clearCommand.execute(%22clear%22);%0A        assertEquals(%22There are no done tasks to clear!%22, result.getFeedback());%0A    %7D%0A%0A    /**%0A     * Test the result when there are tasks to clear.%0A     */%0A    @Test%0A    public void testCommandResultWhenWithTaskToClear() %7B%0A        assertChangeBy(() -%3E this.schedule.getTaskList().size(),%0A            -1,%0A            () -%3E this.clearCommand.execute(%22clear%22));%0A%0A        //Ensure that the correct task is cleared%0A        ArrayList%3CTask%3E tasks = this.schedule.getTaskList();%0A        assertTrue(!tasks.contains(this.task2));%0A    %7D%0A%0A    /**%0A     * Test that command clears the result with hashtag.%0A     */%0A    @Test%0A    public void testClearWithHashtag() %7B%0A        assertChangeBy(() -%3E this.schedule.getTaskList().size(), -1, () -%3E this.clearCommand.execute(%22clear #/hello%22));%0A%0A        // Ensure that the correct task is cleared%0A        ArrayList%3CTask%3E tasks = this.schedule.getTaskList();%0A        assertTrue(!tasks.contains(this.task3));%0A    %7D%0A%7D%0A

Add tests