//@@author A0143049J

package seedu.address.logic.parser;

import static org.junit.Assert.assertEquals;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

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.AddCommand;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.IncorrectCommand;
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 DeleteCommandParserTest {

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

    @Before
    public void setUp() {
    }

    @Test
    public void nullTest() throws Exception{

        Field field = DeleteCommand.class.getDeclaredField("targetIndex");
        field.setAccessible(true);

        DeleteCommand deleteCommand =  (DeleteCommand) DeleteCommandParser.parse(null);
        assertEquals(field.get(deleteCommand), null);
    }

    @Test
    public void zeroTargetIndexTest() throws Exception {

        Field field = DeleteCommand.class.getDeclaredField("targetIndex");
        field.setAccessible(true);

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

	private void assertEqualEditTaskDescriptor(EditTaskDescriptor descriptor1, EditTaskDescriptor descriptor2) {
		assertEquals(descriptor1.getName(), descriptor2.getName());
        assertEquals(descriptor1.getDate(), descriptor2.getDate());
        assertEquals(descriptor1.getTime(), descriptor2.getTime());
        assertEquals(descriptor1.getDescription(), descriptor2.getDescription());
        assertEquals(descriptor1.getTag(), descriptor2.getTag());
        assertEquals(descriptor1.getVenue(), descriptor2.getVenue());
        assertEquals(descriptor1.getPriority(), descriptor2.getPriority());
	}
}

@@ -215,35 +215,8 @@
 eld;
-%0Aimport java.util.Optional;
 %0A%0Aim
@@ -331,56 +331,8 @@
 n;%0A%0A
-import seedu.address.logic.commands.AddCommand;%0A
 impo
@@ -435,284 +435,8 @@
 and;
-%0Aimport seedu.address.model.tag.Tag;%0Aimport seedu.address.model.task.Date;%0Aimport seedu.address.model.task.Description;%0Aimport seedu.address.model.task.Name;%0Aimport seedu.address.model.task.Priority;%0Aimport seedu.address.model.task.Time;%0Aimport seedu.address.model.task.Venue;
 %0A%0Apu
@@ -663,38 +663,41 @@
   Field field = 
-Delete
+Incorrect
 Command.class.ge
@@ -708,35 +708,38 @@
 laredField(%22
-targetIndex
+feedbackToUser
 %22);%0A        
@@ -778,28 +778,34 @@
     
-DeleteCommand delete
+IncorrectCommand incorrect
 Comm
@@ -804,38 +804,41 @@
 rectCommand =  (
-Delete
+Incorrect
 Command) DeleteC
@@ -856,20 +856,18 @@
 r.parse(
-null
+%22%22
 );%0A     
@@ -896,28 +896,101 @@
 get(
-deleteCommand), null
+incorrectCommand), String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE)
 );%0A 
@@ -1085,22 +1085,25 @@
 field = 
-Delete
+Incorrect
 Command.
@@ -1130,19 +1130,22 @@
 ld(%22
-targetIndex
+feedbackToUser
 %22);%0A
@@ -1192,192 +1192,33 @@
     
-Name sampleName = new Name(%22CS2103 Lecture%22);%0A        Optional%3CName%3E optionalName = Optional.of(sampleName);%0A        editTaskDescriptor.setName(optionalName);%0A        DeleteCommand edi
+IncorrectCommand incorrec
 tCom
@@ -1226,22 +1226,25 @@
 and =  (
-Delete
+Incorrect
 Command)
@@ -1275,27 +1275,9 @@
 se(%22
-1 n/CS2103 Lecture 
+0
 %5Cn%22)
@@ -1301,703 +1301,120 @@
 qual
-EditTaskDescriptor((EditTaskDescriptor) field.get(editCommand), editTaskDescriptor);%0A    %7D%0A%0A%09private void assertEqualEditTaskDescriptor(EditTaskDescriptor descriptor1, EditTaskDescriptor descriptor2) %7B%0A%09%09assertEquals(descriptor1.getName(), descriptor2.getName());%0A        assertEquals(descriptor1.getDate(), descriptor2.getDate());%0A        assertEquals(descriptor1.getTime(), descriptor2.getTime());%0A        assertEquals(descriptor1.getDescription(), descriptor2.getDescription());%0A        assertEquals(descriptor1.getTag(), descriptor2.getTag());%0A        assertEquals(descriptor1.getVenue(), descriptor2.getVenue());%0A        assertEquals(descriptor1.getPriority(), descriptor2.getPriority());%0A%09
+s(field.get(incorrectCommand), String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE));%0A    
 %7D%0A%7D%0A

Update testcases for DeleteComandParser