<commit_before>//@@author A0143049J

package seedu.address.logic.parser;

import static org.junit.Assert.assertEquals;

import java.lang.reflect.Field;
import java.util.Optional;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.EditCommand.EditTaskDescriptor;
import seedu.address.model.tag.Tag;
import seedu.address.model.task.Date;
import seedu.address.model.task.Description;
import seedu.address.model.task.Name;
import seedu.address.model.task.Priority;
import seedu.address.model.task.Time;
import seedu.address.model.task.Venue;

public class EditCommandParserTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    public EditTaskDescriptor editTaskDescriptor;

    @Before
    public void setUp() {
    	editTaskDescriptor = new EditTaskDescriptor();
    }

    @Test
    public void nameOnlyEditTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        field.setAccessible(true);

        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        EditCommand editCommand =  (EditCommand) EditCommandParser.parse("1 n/CS2103 Lecture \n");
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameAndDateTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) EditCommandParser.parse("1 n/CS2103 Lecture due/10/3 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date editTaskDescriptorDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(editTaskDescriptorDate);
        editTaskDescriptor.setDate(optionalDate);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) EditCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeDescriptionTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) EditCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 d/Interesting \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        Description sampleDescription = new Description("Interesting");
        Optional<Description> optionalDescription = Optional.of(sampleDescription);
        editTaskDescriptor.setDescription(optionalDescription);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeDescriptionTagTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) EditCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 d/Interesting #CS2103 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        Description sampleDescription = new Description("Interesting");
        Optional<Description> optionalDescription = Optional.of(sampleDescription);
        editTaskDescriptor.setDescription(optionalDescription);
        Tag sampleTag = new Tag("CS2103");
        Optional<Tag> optionalTag = Optional.of(sampleTag);
        editTaskDescriptor.setTag(optionalTag);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeDescriptionTagVenueTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) EditCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 d/Interesting #CS2103 @I3 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        Description sampleDescription = new Description("Interesting");
        Optional<Description> optionalDescription = Optional.of(sampleDescription);
        editTaskDescriptor.setDescription(optionalDescription);
        Tag sampleTag = new Tag("CS2103");
        Optional<Tag> optionalTag = Optional.of(sampleTag);
        editTaskDescriptor.setTag(optionalTag);
        Venue sampleVenue = new Venue("I3");
        Optional<Venue> optionalVenue = Optional.of(sampleVenue);
        editTaskDescriptor.setVenue(optionalVenue);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeDescriptionTagVenuePriorityTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) EditCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 d/Interesting #CS2103 @I3 p/3 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        Description sampleDescription = new Description("Interesting");
        Optional<Description> optionalDescription = Optional.of(sampleDescription);
        editTaskDescriptor.setDescription(optionalDescription);
        Tag sampleTag = new Tag("CS2103");
        Optional<Tag> optionalTag = Optional.of(sampleTag);
        editTaskDescriptor.setTag(optionalTag);
        Venue sampleVenue = new Venue("I3");
        Optional<Venue> optionalVenue = Optional.of(sampleVenue);
        editTaskDescriptor.setVenue(optionalVenue);
        Priority samplePriority = new Priority("3");
        Optional<Priority> optionalPriority = Optional.of(samplePriority);
        editTaskDescriptor.setPriority(optionalPriority);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

	private void assertEqualEditTaskDescriptor(EditTaskDescriptor descriptor1, EditTaskDescriptor descriptor2) {
		assertEquals(descriptor1.getName(), descriptor2.getName());<commit_msg>[V0.3][Test] eddit EditCommandParser to test for non-static mothods<commit_after>//@@author A0143049J

package seedu.address.logic.parser;

import static org.junit.Assert.assertEquals;

import java.lang.reflect.Field;
import java.util.Optional;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.EditCommand.EditTaskDescriptor;
import seedu.address.model.tag.Tag;
import seedu.address.model.task.Date;
import seedu.address.model.task.Description;
import seedu.address.model.task.Name;
import seedu.address.model.task.Priority;
import seedu.address.model.task.Time;
import seedu.address.model.task.Venue;

public class EditCommandParserTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    public EditTaskDescriptor editTaskDescriptor;

    @Before
    public void setUp() {
    	editTaskDescriptor = new EditTaskDescriptor();
    }

    @Test
    public void nameOnlyEditTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        EditCommandParser editCommandParser = new EditCommandParser();
        field.setAccessible(true);

        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        EditCommand editCommand =  (EditCommand) editCommandParser.parse("1 n/CS2103 Lecture \n");
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameAndDateTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        EditCommandParser editCommandParser = new EditCommandParser();
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) editCommandParser.parse("1 n/CS2103 Lecture due/10/3 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date editTaskDescriptorDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(editTaskDescriptorDate);
        editTaskDescriptor.setDate(optionalDate);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        EditCommandParser editCommandParser = new EditCommandParser();
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) editCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeDescriptionTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        EditCommandParser editCommandParser = new EditCommandParser();
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) editCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 d/Interesting \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        Description sampleDescription = new Description("Interesting");
        Optional<Description> optionalDescription = Optional.of(sampleDescription);
        editTaskDescriptor.setDescription(optionalDescription);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeDescriptionTagTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        EditCommandParser editCommandParser = new EditCommandParser();
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) editCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 d/Interesting #CS2103 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        Description sampleDescription = new Description("Interesting");
        Optional<Description> optionalDescription = Optional.of(sampleDescription);
        editTaskDescriptor.setDescription(optionalDescription);
        Tag sampleTag = new Tag("CS2103");
        Optional<Tag> optionalTag = Optional.of(sampleTag);
        editTaskDescriptor.setTag(optionalTag);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeDescriptionTagVenueTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        EditCommandParser editCommandParser = new EditCommandParser();
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) editCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 d/Interesting #CS2103 @I3 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        Description sampleDescription = new Description("Interesting");
        Optional<Description> optionalDescription = Optional.of(sampleDescription);
        editTaskDescriptor.setDescription(optionalDescription);
        Tag sampleTag = new Tag("CS2103");
        Optional<Tag> optionalTag = Optional.of(sampleTag);
        editTaskDescriptor.setTag(optionalTag);
        Venue sampleVenue = new Venue("I3");
        Optional<Venue> optionalVenue = Optional.of(sampleVenue);
        editTaskDescriptor.setVenue(optionalVenue);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

    @Test
    public void nameDateTimeDescriptionTagVenuePriorityTaskTest() throws Exception {

        Field field = EditCommand.class.getDeclaredField("editTaskDescriptor");
        EditCommandParser editCommandParser = new EditCommandParser();
        field.setAccessible(true);

        EditCommand editCommand =  (EditCommand) editCommandParser.parse("1 n/CS2103 Lecture due/10/3 t/16:00 d/Interesting #CS2103 @I3 p/3 \n");
        Name sampleName = new Name("CS2103 Lecture");
        Optional<Name> optionalName = Optional.of(sampleName);
        editTaskDescriptor.setName(optionalName);
        Date sampleDate = new Date("10/3");
        Optional<Date> optionalDate = Optional.of(sampleDate);
        editTaskDescriptor.setDate(optionalDate);
        Time sampleTime = new Time("16:00");
        Optional<Time> optionalTime = Optional.of(sampleTime);
        editTaskDescriptor.setTime(optionalTime);
        Description sampleDescription = new Description("Interesting");
        Optional<Description> optionalDescription = Optional.of(sampleDescription);
        editTaskDescriptor.setDescription(optionalDescription);
        Tag sampleTag = new Tag("CS2103");
        Optional<Tag> optionalTag = Optional.of(sampleTag);
        editTaskDescriptor.setTag(optionalTag);
        Venue sampleVenue = new Venue("I3");
        Optional<Venue> optionalVenue = Optional.of(sampleVenue);
        editTaskDescriptor.setVenue(optionalVenue);
        Priority samplePriority = new Priority("3");
        Optional<Priority> optionalPriority = Optional.of(samplePriority);
        editTaskDescriptor.setPriority(optionalPriority);
        assertEqualEditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);
    }

	private void assertEqualEditTaskDescriptor(EditTaskDescriptor descriptor1, EditTaskDescriptor descriptor2) {
		assertEquals(descriptor1.getName(), descriptor2.getName());
{'fraction_non_alphanumeric': 0.09860303310322335, 'fraction_numerical': 0.019677121269772245, 'mean_word_length': 4.000815438977983, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 59, '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': '6961453', 'n_tokens_mistral': 4981, 'n_tokens_neox': 4677, 'n_words': 944}