package seedu.address.logic.parser;

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

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

import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
 * As we are only doing white-box testing, our test cases do not cover path variations
 * outside of the DeleteCommand code. For example, inputs "1" and "1 abc" take the
 * same path through the DeleteCommand, and therefore we test only one of them.
 * The path variation for those two cases occur inside the ParserUtil, and
 * therefore should be covered by the ParserUtilTest.
 */
public class DeleteCommandParserTest {

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

    private DeleteCommandParser parser = new DeleteCommandParser();

    @Test
    public void parse_validArgs_returnsDeleteCommand() throws Exception {
        DeleteCommand command = parser.parse("1");
        assertEquals(new DeleteCommand(INDEX_FIRST_PERSON), command);
    }

    @Test
    public void parse_invalidArgs_throwsParseException() throws Exception {
        thrown.expect(ParseException.class);
        thrown.expectMessage(String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE));

        parser.parse("a");
    }
}

@@ -34,53 +34,8 @@
 r;%0A%0A
-import static org.junit.Assert.assertEquals;%0A
 impo
@@ -144,99 +144,219 @@
 ess.
-testu
+logic.parser.CommandParserTestU
 til.
-TypicalPersons.INDEX_FIRST_PERSON
+assertParseFailure
 ;%0A
-%0A
 import 
-org.junit.Rule;%0Aimport org.junit.Test
+static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;%0Aimport static seedu.address.testutil.TypicalPersons.INDEX_FIRST_PERSON
 ;%0A
+%0A
 impo
@@ -372,31 +372,12 @@
 nit.
-rules.ExpectedException
+Test
 ;%0A%0Ai
@@ -429,69 +429,8 @@
 and;
-%0Aimport seedu.address.logic.parser.exceptions.ParseException;
 %0A%0A/*
@@ -858,83 +858,8 @@
  %7B%0A%0A
-    @Rule%0A    public ExpectedException thrown = ExpectedException.none();%0A%0A
     
@@ -1019,72 +1019,40 @@
     
-DeleteCommand command = parser.parse(%221%22);%0A        assertEquals(
+assertParseSuccess(parser, %221%22, 
 new 
@@ -1088,17 +1088,8 @@
 SON)
-, command
 );%0A 
@@ -1192,74 +1192,40 @@
     
-thrown.expect(ParseException.class);%0A        thrown.expectMessage(
+assertParseFailure(parser, %22a%22, 
 Stri
@@ -1300,36 +1300,8 @@
 E));
-%0A%0A        parser.parse(%22a%22);
 %0A   

Use helper methods in CommandParserTestUtil