diff --git a/src/main/java/seedu/address/logic/parser/ThemeCommandParser.java b/src/main/java/seedu/address/logic/parser/ThemeCommandParser.java index 67302996d3f..1ac4b4ca77e 100644 --- a/src/main/java/seedu/address/logic/parser/ThemeCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/ThemeCommandParser.java @@ -23,7 +23,13 @@ public ThemeCommand parse(String args) throws ParseException { String.format(MESSAGE_INVALID_COMMAND_FORMAT, ThemeCommand.MESSAGE_USAGE)); } - String theme = trimmedArgs.split("\\s+")[0]; + String[] splitArgs = trimmedArgs.split("\\s+"); + if (splitArgs.length > 1) { + throw new ParseException( + String.format(MESSAGE_UNKNOWN_THEME, ThemeCommand.MESSAGE_USAGE)); + } + + String theme = splitArgs[0]; switch(theme) { diff --git a/src/test/java/seedu/address/logic/parser/ThemeCommandParserTest.java b/src/test/java/seedu/address/logic/parser/ThemeCommandParserTest.java index 4fd91ebcb99..baba32d905e 100644 --- a/src/test/java/seedu/address/logic/parser/ThemeCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/ThemeCommandParserTest.java @@ -24,6 +24,12 @@ public void parse_unknownTheme_throwsParseException() { ThemeCommand.MESSAGE_USAGE)); } + @Test + public void parse_twoThemes_throwsParseException() { + assertParseFailure(parser, "blue green", String.format(MESSAGE_UNKNOWN_THEME, + ThemeCommand.MESSAGE_USAGE)); + } + @Test public void parse_validArgs_returnsThemeCommand() { ThemeCommand expectedThemeCommand1 =