<commit_before>package seedu.task.testutil;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

import org.loadui.testfx.GuiTest;
import org.testfx.api.FxToolkit;

import com.google.common.io.Files;

import guitests.guihandles.PersonCardHandle;
import javafx.geometry.Bounds;
import javafx.geometry.Point2D;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import junit.framework.AssertionFailedError;
import seedu.task.TestApp;
import seedu.task.commons.exceptions.IllegalValueException;
import seedu.task.commons.util.FileUtil;
import seedu.task.commons.util.NattyDateUtil;
import seedu.task.commons.util.XmlUtil;
import seedu.task.model.TaskManager;
import seedu.task.model.tag.Tag;
import seedu.task.model.tag.UniqueTagList;
import seedu.task.model.task.CompletionStatus;
import seedu.task.model.task.EndTime;
import seedu.task.model.task.Name;
import seedu.task.model.task.ReadOnlyTask;
import seedu.task.model.task.StartTime;
import seedu.task.model.task.Task;
import seedu.task.storage.XmlSerializableTaskManager;

/**
 * A utility class for test cases.
 */
public class TestUtil {

    public static final String LS = System.lineSeparator();

    /**
     * Folder used for temp files created during testing. Ignored by Git.
     */
    public static final String SANDBOX_FOLDER = FileUtil.getPath("./src/test/data/sandbox/");

    public static final Task[] SAMPLE_PERSON_DATA = getSampleTaskData();

    public static final Tag[] SAMPLE_TAG_DATA = getSampleTagData();

    public static void assertThrows(Class<? extends Throwable> expected, Runnable executable) {
        try {
            executable.run();
        } catch (Throwable actualException) {
            if (actualException.getClass().isAssignableFrom(expected)) {
                return;
            }
            String message = String.format("Expected thrown: %s, actual: %s", expected.getName(),
                    actualException.getClass().getName());
            throw new AssertionFailedError(message);
        }
        throw new AssertionFailedError(
                String.format("Expected %s to be thrown, but nothing was thrown.", expected.getName()));
    }

    private static Task[] getSampleTaskData() {
        try {
            StartTime SAMPLE_START_TIME = new StartTime(NattyDateUtil.parseSingleDate("06/13/13 0909"));
            EndTime SAMPLE_END_TIME = new EndTime(NattyDateUtil.parseSingleDate("06/13/13 0909"));
            //CHECKSTYLE.OFF: LineLength
            return new Task[]{
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), SAMPLE_START_TIME, SAMPLE_END_TIME, new CompletionStatus(false), new UniqueTagList())
            };
            //CHECKSTYLE.ON: LineLength
        } catch (IllegalValueException e) {
            assert false;
            // not possible
            return null;
        }
    }


    private static Tag[] getSampleTagData() {
        try {
            return new Tag[]{
                new Tag("relatives"),
                new Tag("friends")
            };
        } catch (IllegalValueException e) {
            assert false;
            return null;
            //not possible
        }
    }

    public static List<Task> generateSampleTaskData() {
        return Arrays.asList(SAMPLE_PERSON_DATA);
    }

    /**
     * Appends the file name to the sandbox folder path.<commit_msg>Fix checkstyle warning for TestUtil class<commit_after>package seedu.task.testutil;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

import org.loadui.testfx.GuiTest;
import org.testfx.api.FxToolkit;

import com.google.common.io.Files;

import guitests.guihandles.PersonCardHandle;
import javafx.geometry.Bounds;
import javafx.geometry.Point2D;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import junit.framework.AssertionFailedError;
import seedu.task.TestApp;
import seedu.task.commons.exceptions.IllegalValueException;
import seedu.task.commons.util.FileUtil;
import seedu.task.commons.util.NattyDateUtil;
import seedu.task.commons.util.XmlUtil;
import seedu.task.model.TaskManager;
import seedu.task.model.tag.Tag;
import seedu.task.model.tag.UniqueTagList;
import seedu.task.model.task.CompletionStatus;
import seedu.task.model.task.EndTime;
import seedu.task.model.task.Name;
import seedu.task.model.task.ReadOnlyTask;
import seedu.task.model.task.StartTime;
import seedu.task.model.task.Task;
import seedu.task.storage.XmlSerializableTaskManager;

/**
 * A utility class for test cases.
 */
public class TestUtil {

    public static final String LS = System.lineSeparator();

    /**
     * Folder used for temp files created during testing. Ignored by Git.
     */
    public static final String SANDBOX_FOLDER = FileUtil.getPath("./src/test/data/sandbox/");

    public static final Task[] SAMPLE_PERSON_DATA = getSampleTaskData();

    public static final Tag[] SAMPLE_TAG_DATA = getSampleTagData();

    public static void assertThrows(Class<? extends Throwable> expected, Runnable executable) {
        try {
            executable.run();
        } catch (Throwable actualException) {
            if (actualException.getClass().isAssignableFrom(expected)) {
                return;
            }
            String message = String.format("Expected thrown: %s, actual: %s", expected.getName(),
                    actualException.getClass().getName());
            throw new AssertionFailedError(message);
        }
        throw new AssertionFailedError(
                String.format("Expected %s to be thrown, but nothing was thrown.", expected.getName()));
    }

    //@@author A0146789H
    private static Task[] getSampleTaskData() {
        try {
            StartTime sampleStartTime = new StartTime(NattyDateUtil.parseSingleDate("06/13/13 0909"));
            EndTime sampleEndTime = new EndTime(NattyDateUtil.parseSingleDate("06/13/13 0909"));
            //CHECKSTYLE.OFF: LineLength
            return new Task[]{
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList()),
                new Task(new Name("<NAME>"), sampleStartTime, sampleEndTime, new CompletionStatus(false), new UniqueTagList())
            };
            //CHECKSTYLE.ON: LineLength
        } catch (IllegalValueException e) {
            assert false;
            // not possible
            return null;
        }
    }

    //@@author
    private static Tag[] getSampleTagData() {
        try {
            return new Tag[]{
                new Tag("relatives"),
                new Tag("friends")
            };
        } catch (IllegalValueException e) {
            assert false;
            return null;
            //not possible
        }
    }

    public static List<Task> generateSampleTaskData() {
        return Arrays.asList(SAMPLE_PERSON_DATA);
    }

    /**
     * Appends the file name to the sandbox folder path.
{'fraction_non_alphanumeric': 0.10958617077003667, 'fraction_numerical': 0.005133577789418544, 'mean_word_length': 3.150434782608696, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '3426765', 'n_tokens_mistral': 2785, 'n_tokens_neox': 2654, 'n_words': 627}