forked from nus-cs2103-AY2122S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
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 #178 from AryanSarswat/showevents-upcoming-events
Update `showevents` to only upcoming events
- Loading branch information
Showing
7 changed files
with
100 additions
and
8 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
29 changes: 29 additions & 0 deletions
29
src/main/java/seedu/address/logic/parser/ShowEventsCommandParser.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,29 @@ | ||
package seedu.address.logic.parser; | ||
|
||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.ArgumentMultimap.arePrefixesPresent; | ||
import static seedu.address.logic.parser.CliSyntax.FLAG_ALL; | ||
|
||
import seedu.address.logic.commands.ShowEventsCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
|
||
public class ShowEventsCommandParser implements Parser<ShowEventsCommand> { | ||
/** | ||
* Parses the given {@code String} of arguments in the context of the ShowEventsCommand | ||
* and returns a ShowEventsCommand object for execution. | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public ShowEventsCommand parse(String args) throws ParseException { | ||
requireNonNull(args); | ||
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, FLAG_ALL); | ||
|
||
if (!argMultimap.getPreamble().isEmpty()) { | ||
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ShowEventsCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
return new ShowEventsCommand(arePrefixesPresent(argMultimap, FLAG_ALL)); | ||
} | ||
|
||
} |
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
34 changes: 34 additions & 0 deletions
34
src/test/java/seedu/address/logic/parser/ShowEventsCommandParserTest.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,34 @@ | ||
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.jupiter.api.Test; | ||
|
||
import seedu.address.logic.commands.ShowEventsCommand; | ||
|
||
public class ShowEventsCommandParserTest { | ||
private ShowEventsCommandParser parser = new ShowEventsCommandParser(); | ||
|
||
@Test | ||
public void parse_validArgument_returnsShowEventsCommand() { | ||
ShowEventsCommand showEventsCommand = new ShowEventsCommand(true); | ||
|
||
assertParseSuccess(parser, " -a", showEventsCommand); | ||
} | ||
|
||
@Test | ||
public void parse_validNoArgument_returnsShowEventsCommand() { | ||
ShowEventsCommand showEventsCommand = new ShowEventsCommand(false); | ||
|
||
assertParseSuccess(parser, "", showEventsCommand); | ||
} | ||
|
||
@Test | ||
public void parse_invalidArgs_throwsParseException() { | ||
//random input of special characters | ||
assertParseFailure(parser, "@%^", String.format(MESSAGE_INVALID_COMMAND_FORMAT, ShowEventsCommand.MESSAGE_USAGE)); | ||
} | ||
} |