forked from nus-cs2103-AY2324S1/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.
Merge pull request #242 from kwangthiag/sortparsers
Add Tests for Sort Command parsers and Add equals to Sort Command
- Loading branch information
Showing
6 changed files
with
109 additions
and
0 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
36 changes: 36 additions & 0 deletions
36
src/test/java/seedu/address/logic/parser/appointmentparser/SortCommandParserTest.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,36 @@ | ||
package seedu.address.logic.parser.appointmentparser; | ||
|
||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.Messages.MESSAGE_INVALID_SORT_ATTRIBUTE; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.appointmentcommands.SortCommand; | ||
|
||
public class SortCommandParserTest { | ||
|
||
private static final String INVALID_PREAMBLE_1 = " descending"; | ||
private static final String INVALID_ATTRIBUTE_DESC = " by= friend"; | ||
private static final String VALID_PREAMBLE_1 = " desc"; | ||
private static final String VALID_ATTRIBUTE_DESC = " by= time"; | ||
private static final String VALID_ATTRIBUTE_1 = "time"; | ||
private SortCommandParser parser = new SortCommandParser(); | ||
@Test | ||
public void parse_invalidPreamble_failure() { | ||
assertParseFailure(parser, INVALID_PREAMBLE_1 + VALID_ATTRIBUTE_DESC, | ||
String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE)); | ||
} | ||
@Test | ||
public void parse_invalidAttribute_failure() { | ||
assertParseFailure(parser, VALID_PREAMBLE_1 + INVALID_ATTRIBUTE_DESC, | ||
String.format(MESSAGE_INVALID_SORT_ATTRIBUTE, SortCommandParser.printAttributes())); | ||
} | ||
|
||
@Test | ||
public void parse_validPreambleAndAttribute_success() { | ||
SortCommand expectedSortCommand = new SortCommand(false, VALID_ATTRIBUTE_1); | ||
assertParseSuccess(parser, VALID_PREAMBLE_1 + VALID_ATTRIBUTE_DESC, expectedSortCommand); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/seedu/address/logic/parser/personparser/SortPatientCommandParserTest.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,36 @@ | ||
package seedu.address.logic.parser.personparser; | ||
|
||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.Messages.MESSAGE_INVALID_SORT_ATTRIBUTE; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.personcommands.SortPatientCommand; | ||
|
||
public class SortPatientCommandParserTest { | ||
|
||
private static final String INVALID_PREAMBLE_1 = " ascending"; | ||
private static final String INVALID_ATTRIBUTE_DESC = " by= friend"; | ||
private static final String VALID_PREAMBLE_1 = " asc"; | ||
private static final String VALID_ATTRIBUTE_DESC = " by= name"; | ||
private static final String VALID_ATTRIBUTE_1 = "name"; | ||
private SortPatientCommandParser parser = new SortPatientCommandParser(); | ||
@Test | ||
public void parse_invalidPreamble_failure() { | ||
assertParseFailure(parser, INVALID_PREAMBLE_1 + VALID_ATTRIBUTE_DESC, | ||
String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortPatientCommand.MESSAGE_USAGE)); | ||
} | ||
@Test | ||
public void parse_invalidAttribute_failure() { | ||
assertParseFailure(parser, VALID_PREAMBLE_1 + INVALID_ATTRIBUTE_DESC, | ||
String.format(MESSAGE_INVALID_SORT_ATTRIBUTE, SortPatientCommandParser.printAttributes())); | ||
} | ||
|
||
@Test | ||
public void parse_validPreambleAndAttribute_success() { | ||
SortPatientCommand expectedSortPatientCommand = new SortPatientCommand(true, VALID_ATTRIBUTE_1); | ||
assertParseSuccess(parser, VALID_PREAMBLE_1 + VALID_ATTRIBUTE_DESC, expectedSortPatientCommand); | ||
} | ||
} |