Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test Cases for ListMeeting and Improve Code Quality #326

Merged
merged 2 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ public CommandResult execute(Model model) {
return new CommandResult(MESSAGE_SUCCESS, CommandSpecific.MEETING);
}

@Override
public boolean equals(Object other) {
if (!(other instanceof ListMeetingCommand)) {
return false;
}
ListMeetingCommand otherCmd = (ListMeetingCommand) other;
return otherCmd.dateKeyword == this.dateKeyword;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package seedu.address.logic.parser;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE;

import seedu.address.logic.commands.ListMeetingCommand;
Expand All @@ -18,12 +17,7 @@ public ListMeetingCommand parse(String args) throws ParseException {
return new ListMeetingCommand(DateKeyword.ALL_TIME);
}

try {
DateKeyword dateKeyword = ParserUtil.parseDateKeyword(argumentMultimap.getValue(PREFIX_DATE).get());
return new ListMeetingCommand(dateKeyword);
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
ListMeetingCommand.MESSAGE_USAGE), pe);
}
DateKeyword dateKeyword = ParserUtil.parseDateKeyword(argumentMultimap.getValue(PREFIX_DATE).get());
return new ListMeetingCommand(dateKeyword);
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ParserUtil {

public static final String MESSAGE_INVALID_INDEX = "Index is not a non-zero unsigned integer.";
public static final String MESSAGE_INVALID_DATE_KEYWORD =
"The date keyword should be one of tomorrow, week, or month";
"The date keyword should be either tomorrow, week, or month";

/**
* Parses {@code oneBasedIndex} into an {@code Index} and returns it. Leading and trailing whitespaces will be
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package seedu.address.logic.parser;

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.ListMeetingCommand;

public class ListMeetingCommandParserTest {

private ListMeetingCommandParser parser = new ListMeetingCommandParser();

@Test
public void parse_validArguments_success() {
// Without any arguments
assertParseSuccess(parser, "", new ListMeetingCommand(DateKeyword.ALL_TIME));

// With tomorrow date keyword
assertParseSuccess(parser, " d/tomorrow", new ListMeetingCommand(DateKeyword.TOMORROW));

// With week date keyword
assertParseSuccess(parser, " d/week", new ListMeetingCommand(DateKeyword.THIS_WEEK));

// With month date keyword
assertParseSuccess(parser, " d/month", new ListMeetingCommand(DateKeyword.THIS_MONTH));
}

@Test
public void parse_invalidDateKeyword_failure() {
// Invalid date keyword
assertParseFailure(parser, " d/thismonth", ParserUtil.MESSAGE_INVALID_DATE_KEYWORD);
}

}