diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeletePersonCommand.java similarity index 86% rename from src/main/java/seedu/address/logic/commands/DeleteCommand.java rename to src/main/java/seedu/address/logic/commands/DeletePersonCommand.java index 1135ac19b74..78216699f26 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeletePersonCommand.java @@ -14,9 +14,9 @@ /** * Deletes a person identified using it's displayed index from the address book. */ -public class DeleteCommand extends Command { +public class DeletePersonCommand extends Command { - public static final String COMMAND_WORD = "delete"; + public static final String COMMAND_WORD = "deletePerson"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Deletes the person identified by the index number used in the displayed person list.\n" @@ -27,7 +27,7 @@ public class DeleteCommand extends Command { private final Index targetIndex; - public DeleteCommand(Index targetIndex) { + public DeletePersonCommand(Index targetIndex) { this.targetIndex = targetIndex; } @@ -52,11 +52,11 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof DeleteCommand)) { + if (!(other instanceof DeletePersonCommand)) { return false; } - DeleteCommand otherDeleteCommand = (DeleteCommand) other; + DeletePersonCommand otherDeleteCommand = (DeletePersonCommand) other; return targetIndex.equals(otherDeleteCommand.targetIndex); } diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 7691d2fe352..00367e1b18b 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -11,7 +11,7 @@ import seedu.address.logic.commands.AddPersonCommand; import seedu.address.logic.commands.ClearCommand; import seedu.address.logic.commands.Command; -import seedu.address.logic.commands.DeleteCommand; +import seedu.address.logic.commands.DeletePersonCommand; import seedu.address.logic.commands.EditCommand; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.FindCommand; @@ -59,8 +59,8 @@ public Command parseCommand(String userInput) throws ParseException { case EditCommand.COMMAND_WORD: return new EditCommandParser().parse(arguments); - case DeleteCommand.COMMAND_WORD: - return new DeleteCommandParser().parse(arguments); + case DeletePersonCommand.COMMAND_WORD: + return new DeletePersonCommandParser().parse(arguments); case ClearCommand.COMMAND_WORD: return new ClearCommand(); diff --git a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java b/src/main/java/seedu/address/logic/parser/DeletePersonCommandParser.java similarity index 57% rename from src/main/java/seedu/address/logic/parser/DeleteCommandParser.java rename to src/main/java/seedu/address/logic/parser/DeletePersonCommandParser.java index 3527fe76a3e..6331f7aca5a 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/DeletePersonCommandParser.java @@ -3,26 +3,26 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.DeleteCommand; +import seedu.address.logic.commands.DeletePersonCommand; import seedu.address.logic.parser.exceptions.ParseException; /** - * Parses input arguments and creates a new DeleteCommand object + * Parses input arguments and creates a new DeletePersonCommand object */ -public class DeleteCommandParser implements Parser { +public class DeletePersonCommandParser implements Parser { /** - * Parses the given {@code String} of arguments in the context of the DeleteCommand - * and returns a DeleteCommand object for execution. + * Parses the given {@code String} of arguments in the context of the DeletePersonCommand + * and returns a DeletePersonCommand object for execution. * @throws ParseException if the user input does not conform the expected format */ - public DeleteCommand parse(String args) throws ParseException { + public DeletePersonCommand parse(String args) throws ParseException { try { Index index = ParserUtil.parseIndex(args); - return new DeleteCommand(index); + return new DeletePersonCommand(index); } catch (ParseException pe) { throw new ParseException( - String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE), pe); + String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeletePersonCommand.MESSAGE_USAGE), pe); } } diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 1490583d6f0..8b662c91864 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -60,8 +60,8 @@ public void execute_invalidCommandFormat_throwsParseException() { @Test public void execute_commandExecutionError_throwsCommandException() { - String deleteCommand = "delete 9"; - assertCommandException(deleteCommand, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + String deletePersonCommand = "deletePerson 9"; + assertCommandException(deletePersonCommand, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } @Test diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeletePersonCommandTest.java similarity index 61% rename from src/test/java/seedu/address/logic/commands/DeleteCommandTest.java rename to src/test/java/seedu/address/logic/commands/DeletePersonCommandTest.java index b6f332eabca..86698c56fa8 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeletePersonCommandTest.java @@ -21,32 +21,32 @@ /** * Contains integration tests (interaction with the Model) and unit tests for - * {@code DeleteCommand}. + * {@code DeletePersonCommand}. */ -public class DeleteCommandTest { +public class DeletePersonCommandTest { private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); @Test public void execute_validIndexUnfilteredList_success() { Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); + DeletePersonCommand deletePersonCommand = new DeletePersonCommand(INDEX_FIRST_PERSON); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, + String expectedMessage = String.format(DeletePersonCommand.MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); expectedModel.deletePerson(personToDelete); - assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); + assertCommandSuccess(deletePersonCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexUnfilteredList_throwsCommandException() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); - DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); + DeletePersonCommand deletePersonCommand = new DeletePersonCommand(outOfBoundIndex); - assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(deletePersonCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } @Test @@ -54,16 +54,16 @@ public void execute_validIndexFilteredList_success() { showPersonAtIndex(model, INDEX_FIRST_PERSON); Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); + DeletePersonCommand deletePersonCommand = new DeletePersonCommand(INDEX_FIRST_PERSON); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, + String expectedMessage = String.format(DeletePersonCommand.MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); expectedModel.deletePerson(personToDelete); showNoPerson(expectedModel); - assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); + assertCommandSuccess(deletePersonCommand, model, expectedMessage, expectedModel); } @Test @@ -74,39 +74,39 @@ public void execute_invalidIndexFilteredList_throwsCommandException() { // ensures that outOfBoundIndex is still in bounds of address book list assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); - DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); + DeletePersonCommand deletePersonCommand = new DeletePersonCommand(outOfBoundIndex); - assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(deletePersonCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } @Test public void equals() { - DeleteCommand deleteFirstCommand = new DeleteCommand(INDEX_FIRST_PERSON); - DeleteCommand deleteSecondCommand = new DeleteCommand(INDEX_SECOND_PERSON); + DeletePersonCommand deletePersonFirstCommand = new DeletePersonCommand(INDEX_FIRST_PERSON); + DeletePersonCommand deletePersonSecondCommand = new DeletePersonCommand(INDEX_SECOND_PERSON); // same object -> returns true - assertTrue(deleteFirstCommand.equals(deleteFirstCommand)); + assertTrue(deletePersonFirstCommand.equals(deletePersonFirstCommand)); // same values -> returns true - DeleteCommand deleteFirstCommandCopy = new DeleteCommand(INDEX_FIRST_PERSON); - assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy)); + DeletePersonCommand deletePersonFirstCommandCopy = new DeletePersonCommand(INDEX_FIRST_PERSON); + assertTrue(deletePersonFirstCommand.equals(deletePersonFirstCommandCopy)); // different types -> returns false - assertFalse(deleteFirstCommand.equals(1)); + assertFalse(deletePersonFirstCommand.equals(1)); // null -> returns false - assertFalse(deleteFirstCommand.equals(null)); + assertFalse(deletePersonFirstCommand.equals(null)); // different person -> returns false - assertFalse(deleteFirstCommand.equals(deleteSecondCommand)); + assertFalse(deletePersonFirstCommand.equals(deletePersonSecondCommand)); } @Test public void toStringMethod() { Index targetIndex = Index.fromOneBased(1); - DeleteCommand deleteCommand = new DeleteCommand(targetIndex); - String expected = DeleteCommand.class.getCanonicalName() + "{targetIndex=" + targetIndex + "}"; - assertEquals(expected, deleteCommand.toString()); + DeletePersonCommand deletePersonCommand = new DeletePersonCommand(targetIndex); + String expected = DeletePersonCommand.class.getCanonicalName() + "{targetIndex=" + targetIndex + "}"; + assertEquals(expected, deletePersonCommand.toString()); } /** diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index c7feb31685a..982dd5263b1 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -15,7 +15,7 @@ import seedu.address.logic.commands.AddPersonCommand; import seedu.address.logic.commands.ClearCommand; -import seedu.address.logic.commands.DeleteCommand; +import seedu.address.logic.commands.DeletePersonCommand; import seedu.address.logic.commands.EditCommand; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; import seedu.address.logic.commands.ExitCommand; @@ -47,10 +47,10 @@ public void parseCommand_clear() throws Exception { } @Test - public void parseCommand_delete() throws Exception { - DeleteCommand command = (DeleteCommand) parser.parseCommand( - DeleteCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased()); - assertEquals(new DeleteCommand(INDEX_FIRST_PERSON), command); + public void parseCommand_deletePerson() throws Exception { + DeletePersonCommand command = (DeletePersonCommand) parser.parseCommand( + DeletePersonCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased()); + assertEquals(new DeletePersonCommand(INDEX_FIRST_PERSON), command); } @Test diff --git a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java b/src/test/java/seedu/address/logic/parser/DeletePersonCommandParserTest.java similarity index 57% rename from src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java rename to src/test/java/seedu/address/logic/parser/DeletePersonCommandParserTest.java index 6a40e14a649..122a7e296f5 100644 --- a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/DeletePersonCommandParserTest.java @@ -7,26 +7,27 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.DeleteCommand; +import seedu.address.logic.commands.DeletePersonCommand; /** * As we are only doing white-box testing, our test cases do not cover path variations - * outside of the DeleteCommand code. For example, inputs "1" and "1 abc" take the - * same path through the DeleteCommand, and therefore we test only one of them. + * outside of the DeletePersonCommand code. For example, inputs "1" and "1 abc" take the + * same path through the DeletePersonCommand, and therefore we test only one of them. * The path variation for those two cases occur inside the ParserUtil, and * therefore should be covered by the ParserUtilTest. */ -public class DeleteCommandParserTest { +public class DeletePersonCommandParserTest { - private DeleteCommandParser parser = new DeleteCommandParser(); + private DeletePersonCommandParser parser = new DeletePersonCommandParser(); @Test - public void parse_validArgs_returnsDeleteCommand() { - assertParseSuccess(parser, "1", new DeleteCommand(INDEX_FIRST_PERSON)); + public void parse_validArgs_returnsDeletePersonCommand() { + assertParseSuccess(parser, "1", new DeletePersonCommand(INDEX_FIRST_PERSON)); } @Test public void parse_invalidArgs_throwsParseException() { - assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE)); + assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, + DeletePersonCommand.MESSAGE_USAGE)); } }