Skip to content

Commit

Permalink
Merge branch 'master' into branch-addPageBreaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Incogdino authored Nov 7, 2024
2 parents 438bc99 + c3bd1d6 commit 0e42e7d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/commands/SortCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class SortCommand extends Command {

public static final String MESSAGE_SUCCESS = "List sorted based on %1$s in %2$s order";
public static final String RESET_MESSAGE_SUCCESS = "List sorting set to default order.";
public static final String MESSAGE_INVALID_ORDER = "Order should only be asc or desc.";
public static final String MESSAGE_INVALID_FIELD = "Field should only be github, name, telegram or reset.";
private final PersonComparator comparator;

public SortCommand(PersonComparator comparator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public DeleteCommand parse(String args) throws ParseException {
if (!arePrefixesPresent(argMultimap, PREFIX_NAME) || !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE));
}
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME);

Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());

return new DeleteCommand(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static SortOrder parseSortOrder(String userInput) throws ParseException
} else if (userInput.trim().equalsIgnoreCase("desc")) {
return SortOrder.DESC;
} else {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE));
throw new ParseException(SortCommand.MESSAGE_INVALID_ORDER);
}
}

Expand All @@ -87,7 +87,7 @@ private static SortField parseSortField(String userInput) throws ParseException
case "telegram" -> SortField.TELEGRAM;
case "reset" -> SortField.NONE;
default ->
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE));
throw new ParseException(SortCommand.MESSAGE_INVALID_FIELD);
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public void parse_emptyArg_throwsParseException() {
public void parse_invalidValues_throwsParseException() {
// invalid field
assertParseFailure(parser, PREAMBLE_NON_EMPTY + ORDER_DESC_DESC,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE));
SortCommand.MESSAGE_INVALID_FIELD);

// invalid order
assertParseFailure(parser, VALID_FIELD_NAME + INVALID_ORDER_DESC,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, SortCommand.MESSAGE_USAGE));
SortCommand.MESSAGE_INVALID_ORDER);
}

@Test
Expand Down

0 comments on commit 0e42e7d

Please sign in to comment.