package guitests;

import org.junit.Test;
import seedu.address.commons.core.Messages;
import seedu.address.testutil.TestTask;

import static org.junit.Assert.assertTrue;

public class FilterCommandTest extends TaskManagerGuiTest {

    @Test
    public void filter_nonEmptyList() {
        assertFilterResult("filter d/12.10.2016"); //no results
        commandBox.runCommand("list");
        assertFilterResult("filter d/11.10.2016", td.friendEvent, td.work); //multiple results

        //find after deleting one result
        commandBox.runCommand("delete 1");
        assertFilterResult("filter d/11.10.2016",td.work);
        
        // Filter for event start date
        commandBox.runCommand("list");
        assertFilterResult("filter s/11.10.2016",td.travel);
    }

    @Test
    public void filter_emptyList(){
        commandBox.runCommand("clear");
        assertFilterResult("filter d/11.10.2016"); //no results
    }

    @Test
    public void filter_invalidCommand_fail() {
        commandBox.runCommand("filterd/11.10.2016");
        assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);
    }

    private void assertFilterResult(String command, TestTask... expectedHits ) {
        commandBox.runCommand(command);
        assertListSize(expectedHits.length);
        assertResultMessage(expectedHits.length + " tasks listed!");
        assertTrue(taskListPanel.isListMatching(expectedHits));
    }

}

@@ -79,16 +79,67 @@
 ssages;%0A
+import seedu.address.logic.commands.FilterCommand;%0A
 import s
@@ -213,16 +213,98 @@
 ertTrue;
+%0Aimport static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
 %0A%0Apublic
@@ -476,47 +476,8 @@
 lts%0A
-        commandBox.runCommand(%22list%22);%0A
     
@@ -567,25 +567,24 @@
 results%0A
-%0A
         
 //find a
@@ -579,81 +579,59 @@
     
-//find after deleting one result%0A        commandBox.runCommand(%22delete 1%22
+assertFilterResult(%22filter s/11.10.2016%22, td.travel
 );%0A 
@@ -656,33 +656,33 @@
 rResult(%22filter 
-d
+e
 /11.10.2016%22,td.
@@ -680,17 +680,24 @@
 2016
+-12
 %22,
+ 
 td.
-work
+meeting
 );%0A 
@@ -703,16 +703,93 @@
         
+assertFilterResult(%22filter t/friends%22, td.friend, td.friendEvent, td.lunch);%0A
 %0A       
@@ -795,36 +795,76 @@
   //
- F
+f
 ilter 
-for event start date
+after add one result%0A        TestTask taskToAdd = td.lecture;
 %0A   
@@ -894,14 +894,33 @@
 and(
-%22list%22
+taskToAdd.getAddCommand()
 );%0A 
@@ -957,33 +957,39 @@
 ter 
-s/11.10.2016%22,td.travel);
+r/weekly%22, taskToAdd);%0A        
 %0A   
@@ -1322,16 +1322,162 @@
 MMAND);%0A
+        commandBox.runCommand(%22filter%22);%0A        assertResultMessage(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE));%0A
     %7D%0A%0A 

Add test for filterr command