forked from nus-cs2103-AY1718S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add set command functionality (nus-cs2103-AY1718S2#50)
Set command can now keep a set of custom command words on top of default command words. Test cases written for set command and parser.
- Loading branch information
1 parent
4b549da
commit 7395cda
Showing
6 changed files
with
181 additions
and
52 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
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
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
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
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
40 changes: 40 additions & 0 deletions
40
src/test/java/seedu/address/logic/parser/SetCommandParserTest.java
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
|
||
import org.junit.Test; | ||
|
||
import seedu.address.logic.commands.AddCommand; | ||
import seedu.address.logic.commands.SetCommand; | ||
|
||
public class SetCommandParserTest { | ||
private SetCommandParser parser = new SetCommandParser(); | ||
|
||
@Test | ||
public void parse_twoCommandWords_success() { | ||
String currentWord = AddCommand.COMMAND_WORD; | ||
String newWord = getWord(); | ||
String args = String.join(" ", currentWord, newWord); | ||
assertParseSuccess(parser, args, new SetCommand(currentWord, newWord)); | ||
} | ||
|
||
@Test | ||
public void parse_noCommandWord_failure() { | ||
String currentWord = ""; | ||
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, SetCommand.MESSAGE_USAGE); | ||
assertParseFailure(parser, currentWord, expectedMessage); | ||
} | ||
|
||
@Test | ||
public void parse_oneCommandWord_failure() { | ||
String currentWord = AddCommand.COMMAND_WORD; | ||
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, SetCommand.MESSAGE_USAGE); | ||
assertParseFailure(parser, currentWord, expectedMessage); | ||
} | ||
|
||
public static String getWord() { | ||
return "a"; | ||
} | ||
} |