<commit_before>//@@author A0147984L
package seedu.address.model;

import static org.junit.Assert.assertEquals;

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.model.task.Task;
import seedu.address.model.task.UniqueTaskList.DuplicateTaskException;
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());
    }

    @Test
    public void resetDataNullThrowsAssertionError() {
        thrown.expect(AssertionError.class);
        modelManager.resetData(null);
    }

    @Test
    public void resetData() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getTaskManager(), testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getFilteredTaskList().size(), 7);
        assertEquals(modelManager.getFilteredTagList().size(), 3);
    }

    @Test
    public void testFilterName() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        Set<String> keywords = new HashSet<String>();
        keywords.add("Gym");

        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 3);
        assertEquals(modelManager.getFilteredTaskList().get(0).getName().fullName, "gym");

        modelManager.updateFilteredListToShowAllUnfinishedTasks();
        assertEquals(modelManager.getFilteredTaskList().size(), 7);

        keywords.add("cs2103");
        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 4);

        modelManager = new ModelManager();
        modelManager.resetData(testUtil.getTypicalTaskManager());
        keywords.add("cs2103");

        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 4);
    }

    private void initModelManager() {
        modelManager = new ModelManager();
        modelManager.resetData(testUtil.getTypicalTaskManager());
    }

    @Test
    public void testFilterDate() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getFilteredTaskList().size(), 7);

        modelManager.updateFilteredTaskListGivenDaysToDueBy("0");
        assertEquals(modelManager.getFilteredTaskList().size(), 0);

        initModelManager();

        modelManager.updateFilteredTaskListGivenDaysToDueBy("300");
        assertEquals(modelManager.getFilteredTaskList().size(), 4);
        assertEquals(modelManager.getFilteredTaskList().get(0).getName().fullName, "assignment");

        initModelManager();

        modelManager.updateFilteredTaskListGivenDaysToDueBy("365");
        assertEquals(modelManager.getFilteredTaskList().size(), 7);

        initModelManager();

        modelManager.updateFilteredTaskListGivenDaysToDueBy("700");
        assertEquals(modelManager.getFilteredTaskList().size(), 7);
    }

    @Test
    public void testFilterTag() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getFilteredTaskList().size(), 7);

        Set<String> keywords = new HashSet<String>();
        keywords.add("personal");

        modelManager.updateFilteredTaskListGivenListName(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 4);
        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(), 2);
        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);
    }

    @Test
    public void addTask() throws DuplicateTaskException {
        modelManager = new ModelManager();
        Task task1 = new Task(testUtil.gym);
        Task task2 = new Task(testUtil.cs2103);
        Task task3 = new Task(testUtil.study);

        modelManager.addTask(task1);
        assertEquals(modelManager.getFilteredTaskList().size(), 1);
        assertEquals(modelManager.getFilteredTagList().size(), 1);<commit_msg>[V0.5RC][Test] Add testcase for ModelManager<commit_after>//@@author A0147984L
package seedu.address.model;

import static org.junit.Assert.assertEquals;

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.model.task.Task;
import seedu.address.model.task.UniqueTaskList.DuplicateTaskException;
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());
    }

    @Test
    public void resetDataNullThrowsAssertionError() {
        thrown.expect(AssertionError.class);
        modelManager.resetData(null);
    }

    @Test
    public void resetData() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getTaskManager(), testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getFilteredTaskList().size(), 7);
        assertEquals(modelManager.getFilteredTagList().size(), 3);
    }

    @Test
    public void testFilterName() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        Set<String> keywords = new HashSet<String>();
        keywords.add("Gym");

        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 3);
        assertEquals(modelManager.getFilteredTaskList().get(0).getName().fullName, "gym");

        modelManager.updateFilteredListToShowAllUnfinishedTasks();
        assertEquals(modelManager.getFilteredTaskList().size(), 7);

        keywords.add("cs2103");
        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 4);

        modelManager = new ModelManager();
        modelManager.resetData(testUtil.getTypicalTaskManager());
        keywords.add("cs2103");

        modelManager.updateFilteredTaskList(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 4);
    }

    private void initModelManager() {
        modelManager = new ModelManager();
        modelManager.resetData(testUtil.getTypicalTaskManager());
    }

    @Test
    public void testFilterDate() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getFilteredTaskList().size(), 7);

        modelManager.updateFilteredTaskListGivenDaysToDueBy("0");
        assertEquals(modelManager.getFilteredTaskList().size(), 0);

        modelManager.updateFilteredTaskListGivenDaysToDueOn("0");
        assertEquals(modelManager.getFilteredTaskList().size(), 0);

        initModelManager();

        modelManager.updateFilteredTaskListGivenDaysToDueBy("300");
        assertEquals(modelManager.getFilteredTaskList().size(), 4);
        assertEquals(modelManager.getFilteredTaskList().get(0).getName().fullName, "assignment");

        initModelManager();

        modelManager.updateFilteredTaskListGivenDaysToDueBy("365");
        assertEquals(modelManager.getFilteredTaskList().size(), 7);

        initModelManager();

        modelManager.updateFilteredTaskListGivenDaysToDueBy("700");
        assertEquals(modelManager.getFilteredTaskList().size(), 7);
    }

    @Test
    public void testFilterTag() {
        modelManager.resetData(testUtil.getTypicalTaskManager());
        assertEquals(modelManager.getFilteredTaskList().size(), 7);

        Set<String> keywords = new HashSet<String>();
        keywords.add("personal");

        modelManager.updateFilteredTaskListGivenListName(keywords);
        assertEquals(modelManager.getFilteredTaskList().size(), 4);
        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(), 2);
        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);
    }

    @Test
    public void addTask() throws DuplicateTaskException {
        modelManager = new ModelManager();
        Task task1 = new Task(testUtil.gym);
        Task task2 = new Task(testUtil.cs2103);
        Task task3 = new Task(testUtil.study);

        modelManager.addTask(task1);
        assertEquals(modelManager.getFilteredTaskList().size(), 1);
        assertEquals(modelManager.getFilteredTagList().size(), 1);
{'fraction_non_alphanumeric': 0.11686127053235701, 'fraction_numerical': 0.011874134177716208, 'mean_word_length': 3.9134662129314535, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5321837', 'n_tokens_mistral': 2821, 'n_tokens_neox': 2640, 'n_words': 388}