package seedu.address.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import seedu.address.testutil.TypicalTestTasks;

public class ModelManagerTest {
    
    @Rule
    public ExpectedException thrown = ExpectedException.none();
    
    private ModelManager modelManager = new ModelManager();
    private final TypicalTestTasks testUtil = new TypicalTestTasks();
    
    @Test
    public void constructor() {
        assertEquals(Collections.emptyList(), modelManager.getFilteredTaskList());
        assertEquals(Collections.emptyList(), modelManager.getFilteredListList());
    }
    
    @Test
    public void resetData_null_throwsAssertionError() {
        thrown.expect(AssertionError.class);
        modelManager.resetData(null);
    }
    
    @Test
    public void resetData() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getTaskManager(), testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getFilteredTaskList().size(), 2);
        assertEquals(modelManager.getFilteredListList().size(), 2);
    }

    @Test
    public void testFilterName() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        Set<String> keywords = new HashSet<String>();
        keywords.add("Gym");
        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 1);
        assertEquals(modelManager.getFilteredTaskList().get(0).getName().fullName, "gym");
        
        modelManager = new ModelManager();
        modelManager.resetData(testUtil.getTypicalTaskManager());
        keywords.add("cs2103");
        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 2);
    }
    
    @Test
    public void testFilterTag() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getFilteredTaskList().size(), 2);
        Set<String> keywords = new HashSet<String>();
        keywords.add("personal");
        modelManager.updateFilteredTaskListGivenListName(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 1);
        assertEquals(modelManager.getFilteredTaskList().get(0).getName().fullName, "gym");
        
        modelManager = new ModelManager();
        modelManager.resetData(testUtil.getTypicalTaskManager());
        keywords.clear();
        keywords.add("School");
        modelManager.updateFilteredTaskListGivenListName(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 1);
        assertEquals(modelManager.getFilteredTaskList().get(0).getName().fullName, "cs2103");
        
        modelManager = new ModelManager();
        modelManager.resetData(testUtil.getTypicalTaskManager());
        keywords.clear();
        keywords.add("inbox");
        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 0);
    }
}

@@ -305,24 +305,25 @@
 dException;%0A
+%0A
 import seedu
@@ -357,16 +357,349 @@
 stTasks;
+%0Aimport seedu.address.commons.exceptions.IllegalValueException;%0Aimport seedu.address.model.task.Task;%0Aimport seedu.address.model.task.UniqueTaskList.DuplicateTaskException;%0Aimport seedu.address.model.tasklist.TaskList;%0Aimport seedu.address.model.tasklist.UniqueListList.DuplicateListException;%0Aimport seedu.address.testutil.TestTask;
 %0A%0Apublic
@@ -1571,33 +1571,33 @@
 kList().size(), 
-2
+3
 );%0A        asser
@@ -2520,25 +2520,25 @@
 t().size(), 
-2
+3
 );%0A        S
@@ -2740,33 +2740,33 @@
 kList().size(), 
-1
+2
 );%0A        asser
@@ -3471,32 +3471,32 @@
 List(keywords);%0A
-
         assertEq
@@ -3553,10 +3553,1079 @@
 ;%0A    %7D%0A
+    %0A    @Test%0A    public void addTask() throws DuplicateTaskException %7B%0A        modelManager = new ModelManager();%0A        Task task1 = new Task(testUtil.gym);%0A        Task task2 = new Task(testUtil.cs2103);%0A        Task task3 = new Task(testUtil.study);%0A        %0A        modelManager.addTask(task1);%0A        assertEquals(modelManager.getFilteredTaskList().size(), 1);%0A        assertEquals(modelManager.getFilteredListList().size(), 1);%0A        %0A        modelManager.addTask(task3);%0A        assertEquals(modelManager.getFilteredTaskList().size(), 2);%0A        assertEquals(modelManager.getFilteredListList().size(), 1);%0A    %7D%0A    %0A    @Test%0A    public void addList() throws DuplicateListException, IllegalValueException %7B%0A        modelManager = new ModelManager();%0A        Task task1 = new Task(testUtil.gym);%0A        Task task2 = new Task(testUtil.cs2103);%0A        %0A        modelManager.addTask(task1);%0A        modelManager.addTask(task2);%0A%0A        modelManager.addList(new TaskList(%22inbox%22));%0A        assertEquals(modelManager.getFilteredListList().size(), 3);%0A    %7D%0A
 %7D%0A

Test ModelManager