//@@ author A0143409J

package seedu.address.logic.parser;

import static org.junit.Assert.assertEquals;

import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;

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

import seedu.address.logic.commands.ListAllCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.ListFavoriteCommand;
import seedu.address.logic.commands.ListFinishedCommand;

public class ListCommandParserTest {

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

    @Test
    public void nullTest() throws Exception {

        Field field = ListCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListCommand listCommand =  (ListCommand) ListCommandParser.parse(null);
        Set<String> set = new HashSet<String>();
        assertEquals(field.get(listCommand), set);
    }

    @Test
    public void singleFieldTest() throws Exception {

        Field field = ListCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListCommand listCommand = (ListCommand) ListCommandParser.parse("personal");

        Set<String> set = new HashSet<String>();
        set.add("personal");

        assertEquals(field.get(listCommand), set);
    }

    @Test
    public void multipleFieldTest() throws Exception {

        Field field = ListCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListCommand listCommand = (ListCommand) ListCommandParser.parse("personal school");

        Set<String> set = new HashSet<String>();
        set.add("personal");
        set.add("school");

        assertEquals(field.get(listCommand), set);
    }

    @Test
    public void singleFieldFinishedTest() throws Exception {

        Field field = ListFinishedCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListFinishedCommand listFinishedCommand =
                (ListFinishedCommand) ListCommandParser.parse("finished personal");

        Set<String> set = new HashSet<String>();
        set.add("personal");

        assertEquals(field.get(listFinishedCommand), set);
    }

    @Test
    public void multipleFieldFinishedTest() throws Exception {

        Field field = ListFinishedCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListFinishedCommand listFinishedCommand =
                (ListFinishedCommand) ListCommandParser.parse("finished personal school");

        Set<String> set = new HashSet<String>();
        set.add("personal");
        set.add("school");

        assertEquals(field.get(listFinishedCommand), set);
    }

    @Test
    public void singleFieldAllTest() throws Exception {

        Field field = ListAllCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListAllCommand listAllCommand =
                (ListAllCommand) ListCommandParser.parse("all personal");

        Set<String> set = new HashSet<String>();
        set.add("personal");

        assertEquals(field.get(listAllCommand), set);
    }

    @Test
    public void multipleFieldAllTest() throws Exception {

        Field field = ListAllCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListAllCommand listAllCommand =
                (ListAllCommand) ListCommandParser.parse("all personal school");

        Set<String> set = new HashSet<String>();
        set.add("personal");
        set.add("school");

        assertEquals(field.get(listAllCommand), set);
    }

    @Test
    public void singleFieldFavoriteTest() throws Exception {

        Field field = ListFavoriteCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListFavoriteCommand listFavoriteCommand =
                (ListFavoriteCommand) ListCommandParser.parse("favorite personal");

        Set<String> set = new HashSet<String>();
        set.add("personal");

        assertEquals(field.get(listFavoriteCommand), set);
    }

    @Test
    public void multipleFieldFavoriteTest() throws Exception {

        Field field = ListFavoriteCommand.class.getDeclaredField("keywords");
        field.setAccessible(true);

        ListFavoriteCommand listFavoriteCommand =
                (ListFavoriteCommand) ListCommandParser.parse("favorite personal school");

        Set<String> set = new HashSet<String>();
        set.add("personal");
        set.add("school");

        assertEquals(field.get(listFavoriteCommand), set);
    }
}

@@ -628,16 +628,40 @@
 oid 
-nullTest
+listParse_nullString_listCommand
 () t
@@ -1002,23 +1002,37 @@
 oid 
-singleFieldTest
+listParse_oneWord_listCommand
 () t
@@ -1409,25 +1409,42 @@
 oid 
-multipleFieldTest
+listParse_multipleWord_listCommand
 () t
@@ -1855,27 +1855,46 @@
 oid 
-singleField
+listFinishedParse_oneWord_list
 Finished
 Test
@@ -1881,36 +1881,39 @@
 ord_listFinished
-Test
+Command
 () throws Except
@@ -2343,29 +2343,50 @@
 oid 
+listFinishedParse_
 mult
-i
 ple
-Field
+Word_list
 Finished
 Test
@@ -2381,20 +2381,23 @@
 Finished
-Test
+Command
 () throw
@@ -2869,26 +2869,43 @@
 oid 
-singleFieldAllTest
+listAllParse_oneWord_listAllCommand
 () t
@@ -3317,28 +3317,48 @@
 oid 
-multipleFieldAllTest
+listAllParse_multipleWord_listAllCommand
 () t
@@ -3804,31 +3804,53 @@
 oid 
-singleFieldFavoriteTest
+listFavoriteParse_oneWord_listFavoriteCommand
 () t
@@ -4292,29 +4292,51 @@
 oid 
-multipleField
+listFavoriteParse_multipleWord_list
 Favorite
 Test
@@ -4331,20 +4331,23 @@
 Favorite
-Test
+Command
 () throw

Update naming convention of ListCommandParserTest