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.SelectCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
 * Test scope: similar to {@code DeleteCommandParserTest}.
 * @see DeleteCommandParserTest
 */
public class SelectCommandParserTest {

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

    private SelectCommandParser parser = new SelectCommandParser();

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

    @Test
    public void parse_invalidArgs_throwsParseException() throws Exception {
        thrown.expect(ParseException.class);
        thrown.expectMessage(String.format(MESSAGE_INVALID_COMMAND_FORMAT, SelectCommand.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/*
@@ -570,83 +570,8 @@
  %7B%0A%0A
-    @Rule%0A    public ExpectedException thrown = ExpectedException.none();%0A%0A
     
@@ -731,72 +731,40 @@
     
-SelectCommand command = parser.parse(%221%22);%0A        assertEquals(
+assertParseSuccess(parser, %221%22, 
 new 
@@ -800,17 +800,8 @@
 SON)
-, command
 );%0A 
@@ -904,74 +904,40 @@
     
-thrown.expect(ParseException.class);%0A        thrown.expectMessage(
+assertParseFailure(parser, %22a%22, 
 Stri
@@ -1012,36 +1012,8 @@
 E));
-%0A%0A        parser.parse(%22a%22);
 %0A   

Use helper methods in CommandParserTestUtil