diff --git a/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java b/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java index b5e469f2d62..a7d7f39c9bc 100644 --- a/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java +++ b/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java @@ -28,6 +28,8 @@ public abstract class AbstractFindCommand extends Command { + COMMAND_WORD + PHONE_COMMAND_WORD + "12345678\n" + COMMAND_WORD + TAG_COMMAND_WORD + "CS2100_classmate\n"; + public static final String MESSAGE_NO_PERSONS_FOUND = "No persons found!"; + private final ContainsKeywordsPredicate predicate; public AbstractFindCommand(ContainsKeywordsPredicate predicate) { @@ -45,7 +47,7 @@ public CommandResult execute(Model model) { // if the result find list is empty if (model.getFilteredPersonList().isEmpty()) { - return new CommandResult(String.format("No persons found!")); + return new CommandResult(String.format(MESSAGE_NO_PERSONS_FOUND)); } return new CommandResult( diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 903678c8ca9..239b914a021 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -25,6 +25,8 @@ public class DeleteCommand extends Command { public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s"; + public static final String MESSAGE_DELETE_LIST_EMPTY = "\nThe contact list is empty! :("; + private final Index targetIndex; public DeleteCommand(Index targetIndex) { @@ -43,9 +45,9 @@ public CommandResult execute(Model model) throws CommandException { Person personToDelete = lastShownList.get(targetIndex.getZeroBased()); model.deletePerson(personToDelete); - String result = String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete); + String result = String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)); if (model.getFilteredPersonList().isEmpty()) { - result += "\nThe contact list is empty! :("; + result += MESSAGE_DELETE_LIST_EMPTY; } return new CommandResult(result); } diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 8988440ed0e..54ac31206d1 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -57,7 +57,7 @@ public void execute_validIndexFilteredList_success() { DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, - Messages.format(personToDelete)); + Messages.format(personToDelete) + DeleteCommand.MESSAGE_DELETE_LIST_EMPTY); Model expectedModel = new ModelManager(model.getCampusConnect(), new UserPrefs()); expectedModel.deletePerson(personToDelete); diff --git a/src/test/java/seedu/address/logic/commands/FindByEmailCommandTest.java b/src/test/java/seedu/address/logic/commands/FindByEmailCommandTest.java index 27df0b523f9..52083bf5f2a 100644 --- a/src/test/java/seedu/address/logic/commands/FindByEmailCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindByEmailCommandTest.java @@ -52,7 +52,7 @@ public void equals() { @Test public void execute_zeroKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); + String expectedMessage = AbstractFindCommand.MESSAGE_NO_PERSONS_FOUND; EmailContainsKeywordsPredicate predicate = preparePredicate(" "); FindByEmailCommand command = new FindByEmailCommand(predicate); expectedModel.updateFilteredPersonList(predicate); diff --git a/src/test/java/seedu/address/logic/commands/FindByNameCommandTest.java b/src/test/java/seedu/address/logic/commands/FindByNameCommandTest.java index 56ea054c7be..53f4190c9b2 100644 --- a/src/test/java/seedu/address/logic/commands/FindByNameCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindByNameCommandTest.java @@ -59,7 +59,7 @@ public void equals() { @Test public void execute_zeroKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); + String expectedMessage = AbstractFindCommand.MESSAGE_NO_PERSONS_FOUND; NameContainsKeywordsPredicate predicate = preparePredicate(" "); FindByNameCommand command = new FindByNameCommand(predicate); expectedModel.updateFilteredPersonList(predicate); diff --git a/src/test/java/seedu/address/logic/commands/FindByPhoneCommandTest.java b/src/test/java/seedu/address/logic/commands/FindByPhoneCommandTest.java index d8a7270737d..1b99f23006d 100644 --- a/src/test/java/seedu/address/logic/commands/FindByPhoneCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindByPhoneCommandTest.java @@ -58,7 +58,7 @@ public void equals() { @Test public void execute_zeroKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); + String expectedMessage = AbstractFindCommand.MESSAGE_NO_PERSONS_FOUND; PhoneContainsKeywordsPredicate predicate = preparePredicate(" "); FindByPhoneCommand command = new FindByPhoneCommand(predicate); expectedModel.updateFilteredPersonList(predicate); diff --git a/src/test/java/seedu/address/logic/commands/FindByTagCommandTest.java b/src/test/java/seedu/address/logic/commands/FindByTagCommandTest.java index 16aaa1e8554..fb538eccf27 100644 --- a/src/test/java/seedu/address/logic/commands/FindByTagCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindByTagCommandTest.java @@ -54,7 +54,7 @@ public void equals() { @Test public void execute_zeroKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); + String expectedMessage = AbstractFindCommand.MESSAGE_NO_PERSONS_FOUND; TagContainsKeywordsPredicate predicate = preparePredicate(" "); FindByTagCommand command = new FindByTagCommand(predicate); expectedModel.updateFilteredPersonList(predicate);