33import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
44import static org .junit .jupiter .api .Assertions .assertEquals ;
55import static org .junit .jupiter .api .Assertions .assertThrows ;
6- import static org .junit .jupiter .api .Assertions .fail ;
76
87import java .time .LocalDate ;
98
1312
1413public class CommandParserTest {
1514 @ Test
16- public void commandParser_invalidCommand_success () {
17- try {
18- assertEquals (Command .INVALID , new CommandParser ("any any any" ).getCmd ());
19- } catch (GloqiException e ) {
20- fail ("Unexpected exception: " + e .getMessage ());
21- }
15+ public void commandParser_invalidCommand_success () throws GloqiException {
16+ assertEquals (Command .INVALID , new CommandParser ("any any any" ).getCmd ());
17+ }
18+
19+ @ Test
20+ public void commandParser_listCommand_success () throws GloqiException {
21+ assertEquals (Command .LIST , new CommandParser ("list" ).getCmd ());
22+ }
23+
24+ @ Test
25+ public void commandParser_unmarkCommand_success () throws GloqiException {
26+ CommandParser parser = new CommandParser ("unmark 1" );
27+ assertEquals (Command .UNMARK , parser .getCmd ());
28+ assertArrayEquals (new int []{0 }, parser .getIntArg ());
29+ }
30+
31+ @ Test
32+ public void commandParser_byeCommand_success () throws GloqiException {
33+ assertEquals (Command .BYE , new CommandParser ("bye" ).getCmd ());
34+ }
35+
36+ @ Test
37+ public void commandParser_deleteCommand_success () throws GloqiException {
38+ CommandParser parser = new CommandParser ("delete 1,2" );
39+ assertEquals (Command .DELETE , parser .getCmd ());
40+ assertArrayEquals (new int []{0 , 1 }, parser .getIntArg ());
41+ }
42+
43+ @ Test
44+ public void commandParser_findCommand_success () throws GloqiException {
45+ CommandParser parser = new CommandParser ("find star" );
46+ assertEquals (Command .FIND , parser .getCmd ());
47+ assertArrayEquals (new String []{"star" }, parser .getStringArg ());
2248 }
2349
2450 @ Test
@@ -32,7 +58,7 @@ public void getShowArg_noArg_exceptionThrow() {
3258 "Show" ));
3359 assertEquals ("""
3460 Missing argument!!! Please follow following format:
35- show <date:yyyy-MM-dd >""" , exception .getMessage ());
61+ show <date>""" , exception .getMessage ());
3662 }
3763
3864 @ Test
@@ -41,7 +67,7 @@ public void getShowArg_invalidDateFormat_exceptionThrow() {
4167 "Show 2019/5/5" ));
4268 assertEquals ("""
4369 Date for the show is Invalid!!!Please follow my show format:
44- show <date: yyyy-MM-dd>""" , exception .getMessage ());
70+ show <yyyy-MM-dd>""" , exception .getMessage ());
4571 }
4672
4773 @ Test
0 commit comments