forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
109 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,49 +106,97 @@ public void parseCommand_exit() throws Exception { | |
|
||
@Test | ||
public void parseCommand_findName() throws Exception { | ||
List<String> keywords = Arrays.asList("foo", "bar", "baz"); | ||
List<String> keywords = Arrays.asList("foo"); | ||
FindNameCommand command = (FindNameCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " n/" + keywords.stream().collect(Collectors.joining(" "))); | ||
FindCommand.COMMAND_WORD + " n/ foo"); | ||
assertEquals(new FindNameCommand(new NameContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findMultipleName() throws Exception { | ||
List<String> keywords = Arrays.asList("Amy", "Bob", "Clarissa"); | ||
FindNameCommand command = (FindNameCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " n/Amy n/Bob n/Clarissa"); | ||
assertEquals(new FindNameCommand(new NameContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findAddress() throws Exception { | ||
List<String> keywords = Arrays.asList("Jurong West Street"); | ||
FindAddressCommand command = (FindAddressCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " a/" + keywords.stream().collect(Collectors.joining(" "))); | ||
FindCommand.COMMAND_WORD + " a/Jurong West Street"); | ||
assertEquals(new FindAddressCommand(new AddressContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findMultipleAddress() throws Exception { | ||
List<String> keywords = Arrays.asList("Jurong West Street", "Tampines East"); | ||
FindAddressCommand command = (FindAddressCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " a/Jurong West Street a/Tampines East"); | ||
assertEquals(new FindAddressCommand(new AddressContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findEmail() throws Exception { | ||
List<String> keywords = Arrays.asList("[email protected]"); | ||
FindEmailCommand command = (FindEmailCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " e/[email protected]"); | ||
assertEquals(new FindEmailCommand(new EmailContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findMultipleEmails() throws Exception { | ||
List<String> keywords = Arrays.asList("[email protected]", "[email protected]"); | ||
FindEmailCommand command = (FindEmailCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " e/" + keywords.stream().collect(Collectors.joining(" "))); | ||
FindCommand.COMMAND_WORD + " e/[email protected] e/[email protected]"); | ||
assertEquals(new FindEmailCommand(new EmailContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findPhone() throws Exception { | ||
List<String> keywords = Arrays.asList("99394835"); | ||
FindPhoneCommand command = (FindPhoneCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " p/" + keywords.stream().collect(Collectors.joining(" "))); | ||
FindCommand.COMMAND_WORD + " p/99394835"); | ||
assertEquals(new FindPhoneCommand(new PhoneContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findMultiplePhone() throws Exception { | ||
List<String> keywords = Arrays.asList("99394835", "283384"); | ||
FindPhoneCommand command = (FindPhoneCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " p/99394835 p/283384"); | ||
assertEquals(new FindPhoneCommand(new PhoneContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findTag() throws Exception { | ||
List<String> keywords = Arrays.asList("florist"); | ||
FindTagCommand command = (FindTagCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " t/" + keywords.stream().collect(Collectors.joining(" "))); | ||
FindCommand.COMMAND_WORD + " t/florist"); | ||
assertEquals(new FindTagCommand(new TagContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findMultipleTags() throws Exception { | ||
List<String> keywords = Arrays.asList("florist", "photographer"); | ||
FindTagCommand command = (FindTagCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " t/florist t/photographer"); | ||
assertEquals(new FindTagCommand(new TagContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findWedding() throws Exception { | ||
List<String> keywords = Arrays.asList("Snoopy's", "wedding"); | ||
List<String> keywords = Arrays.asList("Snoopy's wedding"); | ||
FindWeddingCommand command = (FindWeddingCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " w/ Snoopy's wedding"); | ||
assertEquals(new FindWeddingCommand(new WeddingContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
@Test | ||
public void parseCommand_findMultipleWeddings() throws Exception { | ||
List<String> keywords = Arrays.asList("Snoopy's wedding", "Wedding 2029"); | ||
FindWeddingCommand command = (FindWeddingCommand) parser.parseCommand( | ||
FindCommand.COMMAND_WORD + " w/" + keywords.stream().collect(Collectors.joining(" "))); | ||
FindCommand.COMMAND_WORD + " w/Snoopy's wedding w/Wedding 2029"); | ||
assertEquals(new FindWeddingCommand(new WeddingContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,13 +43,24 @@ public void parse_missingPrefix_throwsParseException() { | |
|
||
@Test | ||
public void parse_validFindNameArgs_returnsFindNameCommand() { | ||
// no leading and trailing whitespaces | ||
FindNameCommand expectedFindCommand = | ||
new FindNameCommand(new NameContainsKeywordsPredicate(Arrays.asList("Alice"))); | ||
assertParseSuccess(parser, "find n/Alice", expectedFindCommand); | ||
|
||
// search multiple names using multiple prefixes | ||
assertParseSuccess(parser, "find n/ \n Alice \n \t \t", expectedFindCommand); | ||
} | ||
|
||
@Test | ||
public void parse_validMultipleFindNameArgs_returnsFindNameCommand() { | ||
// no leading and trailing whitespaces | ||
FindNameCommand expectedFindCommand = | ||
new FindNameCommand(new NameContainsKeywordsPredicate(Arrays.asList("Alice", "Bob"))); | ||
assertParseSuccess(parser, "find n/Alice Bob", expectedFindCommand); | ||
assertParseSuccess(parser, "find n/Alice n/Bob", expectedFindCommand); | ||
|
||
// multiple whitespaces between keywords | ||
assertParseSuccess(parser, "find n/ \n Alice \n \t Bob \t", expectedFindCommand); | ||
// search multiple names using multiple prefixes | ||
assertParseSuccess(parser, "find n/ \n Alice \n \t n/ \tBob \t", expectedFindCommand); | ||
} | ||
|
||
@Test | ||
|
@@ -143,6 +154,17 @@ public void parse_validFindPhoneArgs_returnsFindPhoneCommand() { | |
assertParseSuccess(parser, "find p/ \n91234567 \t", expectedFindCommand); | ||
} | ||
|
||
@Test | ||
public void parse_validMultipleFindPhoneArgs_returnsFindPhoneCommand() { | ||
// no leading and trailing whitespaces | ||
FindPhoneCommand expectedFindCommand = | ||
new FindPhoneCommand(new PhoneContainsKeywordsPredicate(Arrays.asList("91234567", "285"))); | ||
assertParseSuccess(parser, "find p/91234567 p/285", expectedFindCommand); | ||
|
||
// multiple whitespaces between keywords | ||
assertParseSuccess(parser, "find p/ \n91234567 \t p/\t 285", expectedFindCommand); | ||
} | ||
|
||
@Test | ||
public void parse_missingPhoneAfterPrefix_throwsParseException() { | ||
String input = "find p/"; // Nothing after phone prefix | ||
|
@@ -177,6 +199,19 @@ public void parse_validFindEmailArgs_returnsFindEmailCommand() { | |
assertParseSuccess(parser, "find e/ \t [email protected]", expectedFindCommand); | ||
} | ||
|
||
@Test | ||
public void parse_validMultipleFindEmailArgs_returnsFindEmailCommand() { | ||
// no leading and trailing whitespaces | ||
FindEmailCommand expectedFindCommand = | ||
new FindEmailCommand(new EmailContainsKeywordsPredicate(Arrays.asList("[email protected]", | ||
"[email protected]"))); | ||
assertParseSuccess(parser, "find e/[email protected] e/[email protected]", expectedFindCommand); | ||
|
||
// multiple whitespaces between keywords | ||
assertParseSuccess(parser, "find e/ \t [email protected] e/ \t [email protected]", expectedFindCommand); | ||
} | ||
|
||
|
||
@Test | ||
public void parse_missingEmailAfterPrefix_throwsParseException() { | ||
String input = "find e/"; // Nothing after email prefix | ||
|
@@ -211,6 +246,17 @@ public void parse_validFindTagArgs_returnsFindTagCommand() { | |
assertParseSuccess(parser, "find t/ \t florist", expectedFindCommand); | ||
} | ||
|
||
@Test | ||
public void parse_validMultipleFindTagArgs_returnsFindTagCommand() { | ||
// no leading and trailing whitespaces | ||
FindTagCommand expectedFindCommand = | ||
new FindTagCommand(new TagContainsKeywordsPredicate(Arrays.asList("florist", "DJ"))); | ||
assertParseSuccess(parser, "find t/florist t/DJ", expectedFindCommand); | ||
|
||
// multiple whitespaces between keywords | ||
assertParseSuccess(parser, "find t/ \t florist t/ \t DJ", expectedFindCommand); | ||
} | ||
|
||
@Test | ||
public void parse_missingTagAfterPrefix_throwsParseException() { | ||
String input = "find t/"; // Nothing after tag prefix | ||
|
@@ -237,11 +283,12 @@ public void parse_missingTagWithTrailingWhiteSpace_throwsParseException() { | |
public void parse_validFindWeddingArgs_returnsFindWeddingCommand() { | ||
// no leading and trailing whitespaces | ||
FindWeddingCommand expectedFindCommand = | ||
new FindWeddingCommand(new WeddingContainsKeywordsPredicate(Arrays.asList("Dave's", "wedding"))); | ||
assertParseSuccess(parser, "find w/Dave's wedding", expectedFindCommand); | ||
new FindWeddingCommand(new WeddingContainsKeywordsPredicate(Arrays.asList("Dave's wedding", | ||
"Wedding 2"))); | ||
assertParseSuccess(parser, "find w/Dave's wedding w/Wedding 2", expectedFindCommand); | ||
|
||
// multiple whitespaces between keywords | ||
assertParseSuccess(parser, "find w/ \t Dave's wedding", expectedFindCommand); | ||
assertParseSuccess(parser, "find w/ \t Dave's wedding w/ \t Wedding 2", expectedFindCommand); | ||
} | ||
|
||
@Test | ||
|