Skip to content

Commit ade0a6b

Browse files
authored
Merge pull request nus-cs2103-AY2021S1#84 from li-s/branch-untagCommand
Modify DeleteCommand, DeleteParser to UntagCommand, UntagParser
2 parents 1a06e2d + fa61628 commit ade0a6b

File tree

8 files changed

+57
-57
lines changed

8 files changed

+57
-57
lines changed

src/main/java/seedu/address/commons/core/Messages.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Messages {
77

88
public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
99
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
10-
public static final String MESSAGE_INVALID_TAG_DISPLAYED_INDEX = "The tag index provided is invalid";
10+
public static final String MESSAGE_INVALID_TAG_DISPLAYED_INDEX = "The Tag index provided is invalid";
1111
public static final String MESSAGE_TAGS_LISTED_OVERVIEW = "%1$d tags listed!";
1212

1313
}

src/main/java/seedu/address/logic/commands/DeleteCommand.java renamed to src/main/java/seedu/address/logic/commands/UntagCommand.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111
import seedu.address.model.tag.Tag;
1212

1313
/**
14-
* Deletes a person identified using it's displayed index from the address book.
14+
* Untags a Tag identified using it's displayed index from the address book.
1515
*/
16-
public class DeleteCommand extends Command {
16+
public class UntagCommand extends Command {
1717

18-
public static final String COMMAND_WORD = "delete";
18+
public static final String COMMAND_WORD = "untag";
1919

2020
public static final String MESSAGE_USAGE = COMMAND_WORD
21-
+ ": Deletes the person identified by the index number used in the displayed person list.\n"
21+
+ ": Untags the tagged file identified by the index number used in the displayed Tag list.\n"
2222
+ "Parameters: INDEX (must be a positive integer)\n"
2323
+ "Example: " + COMMAND_WORD + " 1";
2424

25-
public static final String MESSAGE_DELETE_TAG_SUCCESS = "Deleted Tag: %1$s";
25+
public static final String MESSAGE_UNTAG_TAG_SUCCESS = "Untagged Tag: %1$s";
2626

2727
private final Index targetIndex;
2828

29-
public DeleteCommand(Index targetIndex) {
29+
public UntagCommand(Index targetIndex) {
3030
this.targetIndex = targetIndex;
3131
}
3232

@@ -39,15 +39,15 @@ public CommandResult execute(Model model) throws CommandException {
3939
throw new CommandException(Messages.MESSAGE_INVALID_TAG_DISPLAYED_INDEX);
4040
}
4141

42-
Tag personToDelete = lastShownList.get(targetIndex.getZeroBased());
43-
model.deleteTag(personToDelete);
44-
return new CommandResult(String.format(MESSAGE_DELETE_TAG_SUCCESS, personToDelete));
42+
Tag tagToUntag = lastShownList.get(targetIndex.getZeroBased());
43+
model.deleteTag(tagToUntag);
44+
return new CommandResult(String.format(MESSAGE_UNTAG_TAG_SUCCESS, tagToUntag));
4545
}
4646

4747
@Override
4848
public boolean equals(Object other) {
4949
return other == this // short circuit if same object
50-
|| (other instanceof DeleteCommand // instanceof handles nulls
51-
&& targetIndex.equals(((DeleteCommand) other).targetIndex)); // state check
50+
|| (other instanceof UntagCommand // instanceof handles nulls
51+
&& targetIndex.equals(((UntagCommand) other).targetIndex)); // state check
5252
}
5353
}

src/main/java/seedu/address/logic/parser/AddressBookParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import seedu.address.logic.commands.AddCommand;
1010
import seedu.address.logic.commands.ClearCommand;
1111
import seedu.address.logic.commands.Command;
12-
import seedu.address.logic.commands.DeleteCommand;
1312
import seedu.address.logic.commands.ExitCommand;
1413
import seedu.address.logic.commands.FindCommand;
1514
import seedu.address.logic.commands.HelpCommand;
1615
import seedu.address.logic.commands.ListCommand;
16+
import seedu.address.logic.commands.UntagCommand;
1717
import seedu.address.logic.parser.exceptions.ParseException;
1818

1919
/**
@@ -46,8 +46,8 @@ public Command parseCommand(String userInput) throws ParseException {
4646
case AddCommand.COMMAND_WORD:
4747
return new AddCommandParser().parse(arguments);
4848

49-
case DeleteCommand.COMMAND_WORD:
50-
return new DeleteCommandParser().parse(arguments);
49+
case UntagCommand.COMMAND_WORD:
50+
return new UntagCommandParser().parse(arguments);
5151

5252
case ClearCommand.COMMAND_WORD:
5353
return new ClearCommand();

src/main/java/seedu/address/logic/parser/DeleteCommandParser.java renamed to src/main/java/seedu/address/logic/parser/UntagCommandParser.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
44

55
import seedu.address.commons.core.index.Index;
6-
import seedu.address.logic.commands.DeleteCommand;
6+
import seedu.address.logic.commands.UntagCommand;
77
import seedu.address.logic.parser.exceptions.ParseException;
88

99
/**
10-
* Parses input arguments and creates a new DeleteCommand object
10+
* Parses input arguments and creates a new UntagCommand object
1111
*/
12-
public class DeleteCommandParser implements Parser<DeleteCommand> {
12+
public class UntagCommandParser implements Parser<UntagCommand> {
1313

1414
/**
15-
* Parses the given {@code String} of arguments in the context of the DeleteCommand
16-
* and returns a DeleteCommand object for execution.
15+
* Parses the given {@code String} of arguments in the context of the UntagCommand
16+
* and returns a UntagCommand object for execution.
1717
* @throws ParseException if the user input does not conform the expected format
1818
*/
19-
public DeleteCommand parse(String args) throws ParseException {
19+
public UntagCommand parse(String args) throws ParseException {
2020
try {
2121
Index index = ParserUtil.parseIndex(args);
22-
return new DeleteCommand(index);
22+
return new UntagCommand(index);
2323
} catch (ParseException pe) {
2424
throw new ParseException(
25-
String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE), pe);
25+
String.format(MESSAGE_INVALID_COMMAND_FORMAT, UntagCommand.MESSAGE_USAGE), pe);
2626
}
2727
}
2828

src/test/java/seedu/address/logic/LogicManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public void execute_invalidCommandFormat_throwsParseException() {
5656

5757
@Test
5858
public void execute_commandExecutionError_throwsCommandException() {
59-
String deleteCommand = "delete 9";
60-
assertCommandException(deleteCommand, MESSAGE_INVALID_TAG_DISPLAYED_INDEX);
59+
String untagCommand = "untag 9";
60+
assertCommandException(untagCommand, MESSAGE_INVALID_TAG_DISPLAYED_INDEX);
6161
}
6262

6363
@Test

src/test/java/seedu/address/logic/commands/DeleteCommandTest.java renamed to src/test/java/seedu/address/logic/commands/UntagCommandTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,47 @@
2020

2121
/**
2222
* Contains integration tests (interaction with the Model, UndoCommand and RedoCommand) and unit tests for
23-
* {@code DeleteCommand}.
23+
* {@code UntagCommand}.
2424
*/
25-
public class DeleteCommandTest {
25+
public class UntagCommandTest {
2626

2727
private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
2828

2929
@Test
3030
public void execute_validIndexUnfilteredList_success() {
31-
Tag personToDelete = model.getFilteredTagList().get(INDEX_FIRST_TAG.getZeroBased());
32-
DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_TAG);
31+
Tag tagToDelete = model.getFilteredTagList().get(INDEX_FIRST_TAG.getZeroBased());
32+
UntagCommand untagCommand = new UntagCommand(INDEX_FIRST_TAG);
3333

34-
String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_TAG_SUCCESS, personToDelete);
34+
String expectedMessage = String.format(UntagCommand.MESSAGE_UNTAG_TAG_SUCCESS, tagToDelete);
3535

3636
ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
37-
expectedModel.deleteTag(personToDelete);
37+
expectedModel.deleteTag(tagToDelete);
3838

39-
assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel);
39+
assertCommandSuccess(untagCommand, model, expectedMessage, expectedModel);
4040
}
4141

4242
@Test
4343
public void execute_invalidIndexUnfilteredList_throwsCommandException() {
4444
Index outOfBoundIndex = Index.fromOneBased(model.getFilteredTagList().size() + 1);
45-
DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex);
45+
UntagCommand untagCommand = new UntagCommand(outOfBoundIndex);
4646

47-
assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_TAG_DISPLAYED_INDEX);
47+
assertCommandFailure(untagCommand, model, Messages.MESSAGE_INVALID_TAG_DISPLAYED_INDEX);
4848
}
4949

5050
@Test
5151
public void execute_validIndexFilteredList_success() {
5252
showTagAtIndex(model, INDEX_FIRST_TAG);
5353

54-
Tag personToDelete = model.getFilteredTagList().get(INDEX_FIRST_TAG.getZeroBased());
55-
DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_TAG);
54+
Tag tagToDelete = model.getFilteredTagList().get(INDEX_FIRST_TAG.getZeroBased());
55+
UntagCommand untagCommand = new UntagCommand(INDEX_FIRST_TAG);
5656

57-
String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_TAG_SUCCESS, personToDelete);
57+
String expectedMessage = String.format(untagCommand.MESSAGE_UNTAG_TAG_SUCCESS, tagToDelete);
5858

5959
Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
60-
expectedModel.deleteTag(personToDelete);
60+
expectedModel.deleteTag(tagToDelete);
6161
showNoTag(expectedModel);
6262

63-
assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel);
63+
assertCommandSuccess(untagCommand, model, expectedMessage, expectedModel);
6464
}
6565

6666
@Test
@@ -71,21 +71,21 @@ public void execute_invalidIndexFilteredList_throwsCommandException() {
7171
// ensures that outOfBoundIndex is still in bounds of address book list
7272
assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getTagList().size());
7373

74-
DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex);
74+
UntagCommand untagCommand = new UntagCommand(outOfBoundIndex);
7575

76-
assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_TAG_DISPLAYED_INDEX);
76+
assertCommandFailure(untagCommand, model, Messages.MESSAGE_INVALID_TAG_DISPLAYED_INDEX);
7777
}
7878

7979
@Test
8080
public void equals() {
81-
DeleteCommand deleteFirstCommand = new DeleteCommand(INDEX_FIRST_TAG);
82-
DeleteCommand deleteSecondCommand = new DeleteCommand(INDEX_SECOND_TAG);
81+
UntagCommand deleteFirstCommand = new UntagCommand(INDEX_FIRST_TAG);
82+
UntagCommand deleteSecondCommand = new UntagCommand(INDEX_SECOND_TAG);
8383

8484
// same object -> returns true
8585
assertTrue(deleteFirstCommand.equals(deleteFirstCommand));
8686

8787
// same values -> returns true
88-
DeleteCommand deleteFirstCommandCopy = new DeleteCommand(INDEX_FIRST_TAG);
88+
UntagCommand deleteFirstCommandCopy = new UntagCommand(INDEX_FIRST_TAG);
8989
assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy));
9090

9191
// different types -> returns false

src/test/java/seedu/address/logic/parser/AddressBookParserTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
import seedu.address.logic.commands.AddCommand;
1717
import seedu.address.logic.commands.ClearCommand;
18-
import seedu.address.logic.commands.DeleteCommand;
1918
import seedu.address.logic.commands.ExitCommand;
2019
import seedu.address.logic.commands.FindCommand;
2120
import seedu.address.logic.commands.HelpCommand;
2221
import seedu.address.logic.commands.ListCommand;
22+
import seedu.address.logic.commands.UntagCommand;
2323
import seedu.address.logic.parser.exceptions.ParseException;
2424
import seedu.address.model.tag.Tag;
2525
import seedu.address.model.tag.TagNameContainsKeywordsPredicate;
@@ -44,10 +44,10 @@ public void parseCommand_clear() throws Exception {
4444
}
4545

4646
@Test
47-
public void parseCommand_delete() throws Exception {
48-
DeleteCommand command = (DeleteCommand) parser.parseCommand(
49-
DeleteCommand.COMMAND_WORD + " " + INDEX_FIRST_TAG.getOneBased());
50-
assertEquals(new DeleteCommand(INDEX_FIRST_TAG), command);
47+
public void parseCommand_untag() throws Exception {
48+
UntagCommand command = (UntagCommand) parser.parseCommand(
49+
UntagCommand.COMMAND_WORD + " " + INDEX_FIRST_TAG.getOneBased());
50+
assertEquals(new UntagCommand(INDEX_FIRST_TAG), command);
5151
}
5252

5353
@Test

src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java renamed to src/test/java/seedu/address/logic/parser/UntagCommandParserTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@
77

88
import org.junit.jupiter.api.Test;
99

10-
import seedu.address.logic.commands.DeleteCommand;
10+
import seedu.address.logic.commands.UntagCommand;
1111

1212
/**
1313
* As we are only doing white-box testing, our test cases do not cover path variations
14-
* outside of the DeleteCommand code. For example, inputs "1" and "1 abc" take the
15-
* same path through the DeleteCommand, and therefore we test only one of them.
14+
* outside of the UntagCommand code. For example, inputs "1" and "1 abc" take the
15+
* same path through the UntagCommand, and therefore we test only one of them.
1616
* The path variation for those two cases occur inside the ParserUtil, and
1717
* therefore should be covered by the ParserUtilTest.
1818
*/
19-
public class DeleteCommandParserTest {
19+
public class UntagCommandParserTest {
2020

21-
private DeleteCommandParser parser = new DeleteCommandParser();
21+
private UntagCommandParser parser = new UntagCommandParser();
2222

2323
@Test
24-
public void parse_validArgs_returnsDeleteCommand() {
25-
assertParseSuccess(parser, "1", new DeleteCommand(INDEX_FIRST_TAG));
24+
public void parse_validArgs_returnsUntagCommand() {
25+
assertParseSuccess(parser, "1", new UntagCommand(INDEX_FIRST_TAG));
2626
}
2727

2828
@Test
2929
public void parse_invalidArgs_throwsParseException() {
30-
assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE));
30+
assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, UntagCommand.MESSAGE_USAGE));
3131
}
3232
}

0 commit comments

Comments
 (0)