From 3a52a78da543dbbde56185b8ccb5535f5b587d40 Mon Sep 17 00:00:00 2001 From: mingyu Date: Mon, 13 Nov 2023 12:47:49 +0800 Subject: [PATCH 1/6] add-client role and add developer role tests --- docs/DeveloperGuide.md | 4 +- .../addroles/AddClientRoleCommand.java | 4 +- .../addroles/AddDeveloperRoleCommand.java | 4 +- .../logic/commands/CommandTestUtil.java | 16 ++++ .../addroles/AddClientRoleCommandTest.java | 78 ++++++++++++++++++ .../addroles/AddDeveloperRoleCommandTest.java | 79 +++++++++++++++++++ .../commands/list/ListProjectCommandTest.java | 39 +++++++++ 7 files changed, 218 insertions(+), 6 deletions(-) create mode 100644 src/test/java/seedu/address/logic/commands/addroles/AddClientRoleCommandTest.java create mode 100644 src/test/java/seedu/address/logic/commands/addroles/AddDeveloperRoleCommandTest.java diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index a73d952a472..60b8635b067 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -439,7 +439,7 @@ trimmed to `Tester` and calls `AddDeveloperRoleCommand`. a new developer role if there is no such role.
:exclamation: **Note:** -Although no changes is made to the address book, but this stage is still committed so that the success command +Although no changes is made to the address book, this stage is still committed so that the success command message and tab index switched to can be changed, the currentPointer can also note that there is an action done here.
:exclamation: **Note:** @@ -488,7 +488,7 @@ trimmed to `Tester` and calls `DeleteDeveloperRoleCommand`. if `DeveloperRoles#isRemovableRole()` returns true.
:exclamation: **Note:** -Although no changes is made to the address book, but this stage is still committed so that the success command +Although no changes is made to the address book, this stage is still committed so that the success command message and tab index switched to can be changed, the currentPointer can also note that there is an action done here.
The following sequence diagram shows how the Delete-role operation works: diff --git a/src/main/java/seedu/address/logic/commands/addroles/AddClientRoleCommand.java b/src/main/java/seedu/address/logic/commands/addroles/AddClientRoleCommand.java index 2c69a62f41b..8ed119d0467 100644 --- a/src/main/java/seedu/address/logic/commands/addroles/AddClientRoleCommand.java +++ b/src/main/java/seedu/address/logic/commands/addroles/AddClientRoleCommand.java @@ -24,7 +24,7 @@ public class AddClientRoleCommand extends Command { + "Example: " + PREFIX_ROLE + "Developer "; public static final String MESSAGE_SUCCESS = "New role for client added: %1$s"; - public static final String MESSAGE_DUPLICATE_DEVELOPER = "This client role already exists in the address book!"; + public static final String MESSAGE_DUPLICATE_ROLE = "This client role already exists in the address book!"; private final String toAdd; /** @@ -49,7 +49,7 @@ public CommandResult execute(Model model) throws CommandException { requireNonNull(model); if (ClientRoles.isValidRole(toAdd)) { - throw new CommandException(MESSAGE_DUPLICATE_DEVELOPER); + throw new CommandException(MESSAGE_DUPLICATE_ROLE); } String successMessage = String.format(MESSAGE_SUCCESS, Messages.format(toAdd)); diff --git a/src/main/java/seedu/address/logic/commands/addroles/AddDeveloperRoleCommand.java b/src/main/java/seedu/address/logic/commands/addroles/AddDeveloperRoleCommand.java index d733bf1ede2..a0e6d2b1a98 100644 --- a/src/main/java/seedu/address/logic/commands/addroles/AddDeveloperRoleCommand.java +++ b/src/main/java/seedu/address/logic/commands/addroles/AddDeveloperRoleCommand.java @@ -25,7 +25,7 @@ public class AddDeveloperRoleCommand extends Command { + "Example: " + PREFIX_ROLE + "Developer "; public static final String MESSAGE_SUCCESS = "New role for developer added: %1$s"; - public static final String MESSAGE_DUPLICATE_DEVELOPER = "This developer role already exists in the address book!"; + public static final String MESSAGE_DUPLICATE_ROLE = "This developer role already exists in the address book!"; private final String toAdd; /** @@ -50,7 +50,7 @@ public CommandResult execute(Model model) throws CommandException { requireNonNull(model); if (DeveloperRoles.isValidRole(toAdd)) { - throw new CommandException(MESSAGE_DUPLICATE_DEVELOPER); + throw new CommandException(MESSAGE_DUPLICATE_ROLE); } String successMessage = String.format(MESSAGE_SUCCESS, Messages.format(toAdd)); diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 31b0995285b..399429c9e45 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -31,6 +31,8 @@ import seedu.address.model.client.NameClientContainsKeywordsPredicate; import seedu.address.model.developer.Developer; import seedu.address.model.developer.NameDeveloperContainsKeywordsPredicate; +import seedu.address.model.project.Project; +import seedu.address.model.project.ProjectNameContainsKeywordsPredicate; import seedu.address.testutil.EditClientDescriptorBuilder; import seedu.address.testutil.EditDeveloperDescriptorBuilder; @@ -282,4 +284,18 @@ public static void showClientAtIndex(Model model, Index targetIndex) { assertEquals(1, model.getFilteredClientList().size()); } + /** + * Updates {@code model}'s filtered list to show only the client at the given {@code targetIndex} in the + * {@code model}'s address book. + */ + public static void showProjectAtIndex(Model model, Index targetIndex) { + assertTrue(targetIndex.getZeroBased() < model.getFilteredProjectList().size()); + + Project project = model.getFilteredProjectList().get(targetIndex.getZeroBased()); + final String[] splitName = project.getName().split("\\s+"); + model.updateFilteredProjectList(new ProjectNameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); + + assertEquals(4, model.getFilteredProjectList().size()); + } + } diff --git a/src/test/java/seedu/address/logic/commands/addroles/AddClientRoleCommandTest.java b/src/test/java/seedu/address/logic/commands/addroles/AddClientRoleCommandTest.java new file mode 100644 index 00000000000..c20619ce962 --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/addroles/AddClientRoleCommandTest.java @@ -0,0 +1,78 @@ +package seedu.address.logic.commands.addroles; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; +import static seedu.address.testutil.TypicalClients.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.commands.deleteroles.DeleteClientRoleCommand; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.testutil.Assert; + +public class AddClientRoleCommandTest { + + private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + + @Test + public void constructor_nullRole_throwsNullPointerException() { + Assert.assertThrows(NullPointerException.class, () -> new AddClientRoleCommand(null)); + } + + @Test + public void execute_roleAcceptedByModel_addSuccessful() throws CommandException { + String validRole1 = "Tester"; + AddClientRoleCommand addClientRoleCommand = new AddClientRoleCommand(validRole1); + String expectedMessage = String.format(AddClientRoleCommand.MESSAGE_SUCCESS, validRole1); + + assertEquals(addClientRoleCommand.execute(model).getFeedbackToUser(), expectedMessage); + + DeleteClientRoleCommand deleteClientRoleCommand = new DeleteClientRoleCommand(validRole1); + deleteClientRoleCommand.execute(model); + } + + @Test + public void execute_duplicateRole_throwsCommandException() { + String duplicateRole = "Developer"; + AddClientRoleCommand addClientRoleCommand = new AddClientRoleCommand(duplicateRole); + + assertCommandFailure(addClientRoleCommand, model, AddClientRoleCommand.MESSAGE_DUPLICATE_ROLE); + } + + @Test + public void equals() { + String firstRole = "Tester"; + String secondRole = "Developer"; + AddClientRoleCommand addFirstCommand = new AddClientRoleCommand(firstRole); + AddClientRoleCommand addSecondCommand = new AddClientRoleCommand(secondRole); + + // same object -> returns true + assertTrue(addFirstCommand.equals(addFirstCommand)); + + // same values -> returns False because cannot add twice + AddClientRoleCommand addFirstCommandCopy = new AddClientRoleCommand(firstRole); + assertFalse(addFirstCommand.equals(addFirstCommandCopy)); + + // different types -> returns false + assertFalse(addFirstCommand.equals(1)); + + // null -> returns false + assertFalse(addFirstCommand.equals(null)); + + // different developer role -> returns false + assertFalse(addFirstCommand.equals(addSecondCommand)); + } + + @Test + public void toStringTest() { + String roleName = "Tester"; + AddClientRoleCommand addClientRoleCommand = new AddClientRoleCommand(roleName); + assertEquals(addClientRoleCommand.toString(), new AddClientRoleCommand(roleName).toString()); + } +} diff --git a/src/test/java/seedu/address/logic/commands/addroles/AddDeveloperRoleCommandTest.java b/src/test/java/seedu/address/logic/commands/addroles/AddDeveloperRoleCommandTest.java new file mode 100644 index 00000000000..655ea04bbdc --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/addroles/AddDeveloperRoleCommandTest.java @@ -0,0 +1,79 @@ +package seedu.address.logic.commands.addroles; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.testutil.TypicalDevelopers.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.commands.deleteroles.DeleteDeveloperRoleCommand; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.testutil.Assert; + +public class AddDeveloperRoleCommandTest { + + private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + + @Test + public void constructor_nullRole_throwsNullPointerException() { + Assert.assertThrows(NullPointerException.class, () -> new AddDeveloperRoleCommand(null)); + } + + @Test + public void execute_roleAcceptedByModel_addSuccessful() throws CommandException { + String validRole1 = "Tester"; + AddDeveloperRoleCommand addDeveloperRoleCommand = new AddDeveloperRoleCommand(validRole1); + String expectedMessage = String.format(AddDeveloperRoleCommand.MESSAGE_SUCCESS, validRole1); + + assertCommandSuccess(addDeveloperRoleCommand, model, expectedMessage, expectedModel); + + DeleteDeveloperRoleCommand deleteDeveloperRoleCommand = new DeleteDeveloperRoleCommand(validRole1); + deleteDeveloperRoleCommand.execute(model); + } + + @Test + public void execute_duplicateRole_throwsCommandException() { + String duplicateRole = "Developer"; + AddDeveloperRoleCommand addDeveloperRoleCommand = new AddDeveloperRoleCommand(duplicateRole); + + assertCommandFailure(addDeveloperRoleCommand, model, AddDeveloperRoleCommand.MESSAGE_DUPLICATE_ROLE); + } + + @Test + public void equals() { + String firstRole = "Tester"; + String secondRole = "Developer"; + AddDeveloperRoleCommand addFirstCommand = new AddDeveloperRoleCommand(firstRole); + AddDeveloperRoleCommand addSecondCommand = new AddDeveloperRoleCommand(secondRole); + + // same object -> returns true + assertTrue(addFirstCommand.equals(addFirstCommand)); + + // same values -> returns False because cannot add twice + AddDeveloperRoleCommand addFirstCommandCopy = new AddDeveloperRoleCommand(firstRole); + assertFalse(addFirstCommand.equals(addFirstCommandCopy)); + + // different types -> returns false + assertFalse(addFirstCommand.equals(1)); + + // null -> returns false + assertFalse(addFirstCommand.equals(null)); + + // different developer role -> returns false + assertFalse(addFirstCommand.equals(addSecondCommand)); + } + + @Test + public void toStringTest() { + String roleName = "Tester"; + AddDeveloperRoleCommand addDeveloperRoleCommand = new AddDeveloperRoleCommand(roleName); + assertEquals(addDeveloperRoleCommand.toString(), new AddDeveloperRoleCommand(roleName).toString()); + } +} diff --git a/src/test/java/seedu/address/logic/commands/list/ListProjectCommandTest.java b/src/test/java/seedu/address/logic/commands/list/ListProjectCommandTest.java index 36cd31b1c13..d7bfa327096 100644 --- a/src/test/java/seedu/address/logic/commands/list/ListProjectCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/list/ListProjectCommandTest.java @@ -1,4 +1,43 @@ package seedu.address.logic.commands.list; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static seedu.address.testutil.Assert.assertThrows; +import static seedu.address.testutil.TypicalProjects.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.commands.CommandResult; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; + public class ListProjectCommandTest { + + private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + + @Test + public void execute_listIsNotFiltered_showsSameList() { + ListProjectCommand listProjectCommand = new ListProjectCommand(); + CommandResult commandResult = listProjectCommand.execute(model); + + assertEquals(ListProjectCommand.MESSAGE_SUCCESS, commandResult.getFeedbackToUser()); + assertEquals(model.getAddressBook().getProjectList(), model.getFilteredProjectList()); + } + + @Test + public void execute_listIsFiltered_showsEverything() { + // Assume the list is filtered by some predicate + model.updateFilteredProjectList(project -> project.getProjectDeadlines().equals("2023-01-01")); + ListProjectCommand listProjectCommand = new ListProjectCommand(); + CommandResult commandResult = listProjectCommand.execute(model); + + assertEquals(ListProjectCommand.MESSAGE_SUCCESS, commandResult.getFeedbackToUser()); + assertEquals(model.getAddressBook().getProjectList(), model.getFilteredProjectList()); + } + + @Test + public void execute_modelIsNull_throwsAssertionError() { + ListProjectCommand listProjectCommand = new ListProjectCommand(); + assertThrows(AssertionError.class, () -> listProjectCommand.execute(null)); + } } From 3f79d3f6d4ed86660b199d2b9ac771da2053c8de Mon Sep 17 00:00:00 2001 From: mingyu Date: Mon, 13 Nov 2023 13:25:25 +0800 Subject: [PATCH 2/6] delete client and developer roles test cases --- .../addroles/AddClientRoleCommandTest.java | 1 - .../DeleteClientRoleCommandTest.java | 114 +++++++++++++++++ .../DeleteDeveloperRoleCommandTest.java | 116 ++++++++++++++++++ 3 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 src/test/java/seedu/address/logic/commands/deleteroles/DeleteClientRoleCommandTest.java create mode 100644 src/test/java/seedu/address/logic/commands/deleteroles/DeleteDeveloperRoleCommandTest.java diff --git a/src/test/java/seedu/address/logic/commands/addroles/AddClientRoleCommandTest.java b/src/test/java/seedu/address/logic/commands/addroles/AddClientRoleCommandTest.java index c20619ce962..30d5e67ff58 100644 --- a/src/test/java/seedu/address/logic/commands/addroles/AddClientRoleCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/addroles/AddClientRoleCommandTest.java @@ -18,7 +18,6 @@ public class AddClientRoleCommandTest { private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); @Test public void constructor_nullRole_throwsNullPointerException() { diff --git a/src/test/java/seedu/address/logic/commands/deleteroles/DeleteClientRoleCommandTest.java b/src/test/java/seedu/address/logic/commands/deleteroles/DeleteClientRoleCommandTest.java new file mode 100644 index 00000000000..913575056a8 --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/deleteroles/DeleteClientRoleCommandTest.java @@ -0,0 +1,114 @@ +package seedu.address.logic.commands.deleteroles; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; +import static seedu.address.testutil.TypicalDevelopers.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.Messages; +import seedu.address.logic.commands.addroles.AddClientRoleCommand; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.model.client.ClientRoles; +import seedu.address.testutil.Assert; +import seedu.address.testutil.ClientBuilder; + +public class DeleteClientRoleCommandTest { + + private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + + @Test + public void constructor_nullRole_throwsNullPointerException() { + Assert.assertThrows(NullPointerException.class, () -> new DeleteClientRoleCommand(null)); + } + + @Test + public void execute_roleAcceptedByModel_deleteSuccessful() throws CommandException { + + String validRole = "NewRole"; + AddClientRoleCommand addClientRoleCommand = new AddClientRoleCommand(validRole); + addClientRoleCommand.execute(model); + + DeleteClientRoleCommand deleteClientRoleCommand = new DeleteClientRoleCommand(validRole); + + String expectedMessage = String.format(DeleteClientRoleCommand.MESSAGE_SUCCESS, validRole); + assertEquals(deleteClientRoleCommand.execute(model).getFeedbackToUser(), expectedMessage); + } + + @Test + public void execute_roleSomeoneUsing_throwsCommandException() throws CommandException { + // Assign a client with the specified role + String roleWithClient = "NewRole"; + AddClientRoleCommand addClientRoleCommand = new AddClientRoleCommand(roleWithClient); + addClientRoleCommand.execute(model); + ClientBuilder clientBuilder = new ClientBuilder().withRole(roleWithClient); + model.addClient(clientBuilder.build()); + + // Attempt to delete the role + DeleteClientRoleCommand deleteClientRoleCommand = new DeleteClientRoleCommand(roleWithClient); + String expectedResult = String.format(DeleteClientRoleCommand.MESSAGE_CANNOT_DELETE_REPEAT, + Messages.format(roleWithClient)); + + // Assert that the command throws an exception + assertCommandFailure(deleteClientRoleCommand, model, expectedResult); + + model.deleteClient(clientBuilder.build()); + deleteClientRoleCommand.execute(model); + } + + + @Test + public void execute_roleNotInList_throwsCommandException() { + String nonExistingRole = "NonExistingRole"; + DeleteClientRoleCommand deleteClientRoleCommand = new DeleteClientRoleCommand(nonExistingRole); + + assertCommandFailure(deleteClientRoleCommand, model, + DeleteClientRoleCommand.MESSAGE_CANNOT_DELETE_NONEXISTING + + DeleteClientRoleCommand.MESSAGE_EXISTING_CLIENT_ROLES + + ClientRoles.printRoles()); + } + + @Test + public void execute_roleIsPredefined_throwsCommandException() { + String roleWithClient = "Client"; + DeleteClientRoleCommand deleteClientRoleCommand = new DeleteClientRoleCommand(roleWithClient); + assertThrows(CommandException.class, () -> deleteClientRoleCommand.execute(model)); + } + + @Test + public void equals() { + String firstRole = "Tester"; + String secondRole = "Client"; + DeleteClientRoleCommand deleteFirstCommand = new DeleteClientRoleCommand(firstRole); + DeleteClientRoleCommand deleteSecondCommand = new DeleteClientRoleCommand(secondRole); + + // same object -> returns true + assertTrue(deleteFirstCommand.equals(deleteFirstCommand)); + + // role will no longer exists-> returns false + DeleteClientRoleCommand deleteFirstCommandCopy = new DeleteClientRoleCommand(firstRole); + assertFalse(deleteFirstCommand.equals(deleteFirstCommandCopy)); + + // different types -> returns false + assertFalse(deleteFirstCommand.equals(1)); + + // null -> returns false + assertFalse(deleteFirstCommand.equals(null)); + + // different client role -> returns false + assertFalse(deleteFirstCommand.equals(deleteSecondCommand)); + } + + @Test + public void toStringTest() { + String roleName = "Tester"; + DeleteClientRoleCommand deleteClientRoleCommand = new DeleteClientRoleCommand(roleName); + assertEquals(deleteClientRoleCommand.toString(), new DeleteClientRoleCommand(roleName).toString()); + } +} diff --git a/src/test/java/seedu/address/logic/commands/deleteroles/DeleteDeveloperRoleCommandTest.java b/src/test/java/seedu/address/logic/commands/deleteroles/DeleteDeveloperRoleCommandTest.java new file mode 100644 index 00000000000..da5a1161a41 --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/deleteroles/DeleteDeveloperRoleCommandTest.java @@ -0,0 +1,116 @@ +package seedu.address.logic.commands.deleteroles; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.testutil.TypicalDevelopers.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.Messages; +import seedu.address.logic.commands.addroles.AddDeveloperRoleCommand; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.model.developer.DeveloperRoles; +import seedu.address.testutil.Assert; +import seedu.address.testutil.DeveloperBuilder; + +public class DeleteDeveloperRoleCommandTest { + + private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + + @Test + public void constructor_nullRole_throwsNullPointerException() { + Assert.assertThrows(NullPointerException.class, () -> new DeleteDeveloperRoleCommand(null)); + } + + @Test + public void execute_roleAcceptedByModel_deleteSuccessful() throws CommandException { + + String validRole = "NewRole"; + AddDeveloperRoleCommand addDeveloperRoleCommand = new AddDeveloperRoleCommand(validRole); + addDeveloperRoleCommand.execute(model); + + DeleteDeveloperRoleCommand deleteDeveloperRoleCommand = new DeleteDeveloperRoleCommand(validRole); + + String expectedMessage = String.format(DeleteDeveloperRoleCommand.MESSAGE_SUCCESS, validRole); + + assertCommandSuccess(deleteDeveloperRoleCommand, model, expectedMessage, model); + } + + @Test + public void execute_roleSomeoneUsing_throwsCommandException() throws CommandException { + // Assign a developer with the specified role + String roleWithDevelopers = "NewRole"; + AddDeveloperRoleCommand addDeveloperRoleCommand = new AddDeveloperRoleCommand(roleWithDevelopers); + addDeveloperRoleCommand.execute(model); + DeveloperBuilder developerBuilder = new DeveloperBuilder().withRole(roleWithDevelopers); + model.addDeveloper(developerBuilder.build()); + + // Attempt to delete the role + DeleteDeveloperRoleCommand deleteDeveloperRoleCommand = new DeleteDeveloperRoleCommand(roleWithDevelopers); + String expectedResult = String.format(DeleteDeveloperRoleCommand.MESSAGE_CANNOT_DELETE_REPEAT, + Messages.format(roleWithDevelopers)); + + // Assert that the command throws an exception + assertCommandFailure(deleteDeveloperRoleCommand, model, expectedResult); + + model.deleteDeveloper(developerBuilder.build()); + deleteDeveloperRoleCommand.execute(model); + } + + + @Test + public void execute_roleNotInList_throwsCommandException() { + String nonExistingRole = "NonExistingRole"; + DeleteDeveloperRoleCommand deleteDeveloperRoleCommand = new DeleteDeveloperRoleCommand(nonExistingRole); + + assertCommandFailure(deleteDeveloperRoleCommand, model, + DeleteDeveloperRoleCommand.MESSAGE_CANNOT_DELETE_NONEXISTING + + DeleteDeveloperRoleCommand.MESSAGE_EXISTING_DEVELOPERS_ROLES + + DeveloperRoles.printRoles()); + } + + @Test + public void execute_roleIsPredefined_throwsCommandException() { + String roleWithDevelopers = "Developer"; + DeleteDeveloperRoleCommand deleteDeveloperRoleCommand = new DeleteDeveloperRoleCommand(roleWithDevelopers); + assertThrows(CommandException.class, () -> deleteDeveloperRoleCommand.execute(model)); + } + + @Test + public void equals() { + String firstRole = "Tester"; + String secondRole = "Developer"; + DeleteDeveloperRoleCommand deleteFirstCommand = new DeleteDeveloperRoleCommand(firstRole); + DeleteDeveloperRoleCommand deleteSecondCommand = new DeleteDeveloperRoleCommand(secondRole); + + // same object -> returns true + assertTrue(deleteFirstCommand.equals(deleteFirstCommand)); + + // role will no longer exists-> returns false + DeleteDeveloperRoleCommand deleteFirstCommandCopy = new DeleteDeveloperRoleCommand(firstRole); + assertFalse(deleteFirstCommand.equals(deleteFirstCommandCopy)); + + // different types -> returns false + assertFalse(deleteFirstCommand.equals(1)); + + // null -> returns false + assertFalse(deleteFirstCommand.equals(null)); + + // different developer role -> returns false + assertFalse(deleteFirstCommand.equals(deleteSecondCommand)); + } + + @Test + public void toStringTest() { + String roleName = "Tester"; + DeleteDeveloperRoleCommand deleteDeveloperRoleCommand = new DeleteDeveloperRoleCommand(roleName); + assertEquals(deleteDeveloperRoleCommand.toString(), new DeleteDeveloperRoleCommand(roleName).toString()); + } +} From c760cd61f024ca374e40d6a7396e99dee564f144 Mon Sep 17 00:00:00 2001 From: mingyu Date: Mon, 13 Nov 2023 14:45:40 +0800 Subject: [PATCH 3/6] VersionedAddressBook test cases --- .../address/model/VersionedAddressBook.java | 18 ++++ .../model/VersionedAddressBookTest.java | 85 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 src/test/java/seedu/address/model/VersionedAddressBookTest.java diff --git a/src/main/java/seedu/address/model/VersionedAddressBook.java b/src/main/java/seedu/address/model/VersionedAddressBook.java index 7dad5cdc940..996ab17e9ed 100644 --- a/src/main/java/seedu/address/model/VersionedAddressBook.java +++ b/src/main/java/seedu/address/model/VersionedAddressBook.java @@ -137,6 +137,24 @@ public TabIndex getPreviousTabIndexForRedo() { return tabIndex.get(currentStatePointer - 1); } + /** + * Gets the current addressbook. + * + * @return The tab index from the previous command. + */ + public ReadOnlyAddressBook getCurrentState(int currentStatePointer) { + return addressBookStateList.get(currentStatePointer); + } + + /** + * Gets the current current state pointer. + * + * @return The tab index from the previous command. + */ + public int getCurrentStatePointer() { + return currentStatePointer; + } + /** * Changes the current model's address book to match the current state. * diff --git a/src/test/java/seedu/address/model/VersionedAddressBookTest.java b/src/test/java/seedu/address/model/VersionedAddressBookTest.java new file mode 100644 index 00000000000..0be58d4a166 --- /dev/null +++ b/src/test/java/seedu/address/model/VersionedAddressBookTest.java @@ -0,0 +1,85 @@ +package seedu.address.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.testutil.TypicalClients.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.commands.TabIndex; +import seedu.address.logic.commands.exceptions.CommandException; + + +public class VersionedAddressBookTest { + + private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private VersionedAddressBook versionedAddressBook = new VersionedAddressBook(model.getAddressBook()); + + @Test + public void commit_validModelState_successfullyCommits() { + versionedAddressBook.commit(model, "Committing state", TabIndex.Client); + + // Ensure that the model's address book is updated + assertEquals(model.getAddressBook(), versionedAddressBook.getCurrentState(1)); + + // Ensure that the state pointer has moved to the latest state + assertEquals(1, versionedAddressBook.getCurrentStatePointer()); + } + + @Test + public void undo_validModelState_successfullyUndoes() throws CommandException { + versionedAddressBook.commit(model, "Committing state", TabIndex.Client); + versionedAddressBook.undo(model); + + // Ensure that the model's address book is updated to the previous state + assertEquals(model.getAddressBook(), versionedAddressBook.getCurrentState(1)); + + // Ensure that the state pointer has moved to the previous state + assertEquals(0, versionedAddressBook.getCurrentStatePointer()); + + // Ensure that the success message and tab index are retrieved + assertEquals("Committing state", versionedAddressBook.getPreviousMessage()); + assertEquals(TabIndex.Client, versionedAddressBook.getPreviousTabIndex()); + } + + @Test + public void redo_validModelState_successfullyRedoes() throws CommandException { + versionedAddressBook.commit(model, "Committing state", TabIndex.Client); + versionedAddressBook.undo(model); + versionedAddressBook.redo(model); + + // Ensure that the model's address book is updated to the next state + assertEquals(model.getAddressBook(), versionedAddressBook.getCurrentState(1)); + + // Ensure that the state pointer has moved to the next state + assertEquals(1, versionedAddressBook.getCurrentStatePointer()); + + // Ensure that the success message and tab index are retrieved + assertEquals("Committing state", versionedAddressBook.getPreviousMessageForRedo()); + assertEquals(TabIndex.Client, versionedAddressBook.getPreviousTabIndexForRedo()); + } + + @Test + public void canUndo_noStatesToUndo_returnsFalse() { + assertFalse(versionedAddressBook.canUndo()); + } + + @Test + public void canRedo_noStatesToRedo_returnsFalse() { + assertFalse(versionedAddressBook.canRedo()); + } + + @Test + public void canUndo_hasStatesToUndo_returnsTrue() throws CommandException { + versionedAddressBook.commit(model, "Committing state", TabIndex.Client); + assertTrue(versionedAddressBook.canUndo()); + } + + @Test + public void canRedo_hasStatesToRedo_returnsTrue() throws CommandException { + versionedAddressBook.commit(model, "Committing state", TabIndex.Client); + versionedAddressBook.undo(model); + assertTrue(versionedAddressBook.canRedo()); + } +} From ff4c6a3191651d7ab87cbf1c145ce08ed6a44c18 Mon Sep 17 00:00:00 2001 From: mingyu Date: Mon, 13 Nov 2023 15:39:35 +0800 Subject: [PATCH 4/6] Undo Redo Command test cases --- .../address/logic/commands/RedoCommand.java | 5 +- .../address/logic/commands/UndoCommand.java | 6 +- .../logic/commands/RedoCommandTest.java | 101 ++++++++++++++ .../logic/commands/UndoCommandTest.java | 123 ++++++++++++++++++ 4 files changed, 233 insertions(+), 2 deletions(-) create mode 100644 src/test/java/seedu/address/logic/commands/RedoCommandTest.java create mode 100644 src/test/java/seedu/address/logic/commands/UndoCommandTest.java diff --git a/src/main/java/seedu/address/logic/commands/RedoCommand.java b/src/main/java/seedu/address/logic/commands/RedoCommand.java index d512ffeae36..17efa4b90e6 100644 --- a/src/main/java/seedu/address/logic/commands/RedoCommand.java +++ b/src/main/java/seedu/address/logic/commands/RedoCommand.java @@ -21,7 +21,11 @@ public CommandResult execute(Model model) throws CommandException { model.redoAddressBook(model); String previousCommand = model.getPreviousCommandForRedo(); TabIndex index = model.getPreviousTabIndexForRedo(); + handleRoleRedo(previousCommand); + return new CommandResult(MESSAGE_SUCCESS + "\n" + previousCommand, index); + } + private void handleRoleRedo(String previousCommand) { if (previousCommand.contains("New role for client added: ")) { ClientRoles.addClientRole(new ClientRoles(previousCommand.substring(27))); } else if (previousCommand.contains("New role for developer added: ")) { @@ -31,6 +35,5 @@ public CommandResult execute(Model model) throws CommandException { } else if (previousCommand.contains("Role for developers deleted: ")) { DeveloperRoles.deleteDeveloperRole(new DeveloperRoles(previousCommand.substring(29))); } - return new CommandResult(MESSAGE_SUCCESS + "\n" + previousCommand, index); } } diff --git a/src/main/java/seedu/address/logic/commands/UndoCommand.java b/src/main/java/seedu/address/logic/commands/UndoCommand.java index 3cfb932d7eb..faffb39a91a 100644 --- a/src/main/java/seedu/address/logic/commands/UndoCommand.java +++ b/src/main/java/seedu/address/logic/commands/UndoCommand.java @@ -31,6 +31,11 @@ public CommandResult execute(Model model) throws CommandException { String previousCommand = model.getPreviousCommandForUndo(); TabIndex index = model.getPreviousTabIndex(); // check if it is any of the role commands + handleRoleUndo(previousCommand); + return new CommandResult(MESSAGE_SUCCESS + "\n" + previousCommand, index); + } + + private void handleRoleUndo(String previousCommand) { if (previousCommand.contains("New role for client added: ")) { ClientRoles.deleteClientRole(new ClientRoles(previousCommand.substring(27))); } else if (previousCommand.contains("New role for developer added: ")) { @@ -40,6 +45,5 @@ public CommandResult execute(Model model) throws CommandException { } else if (previousCommand.contains("Role for developers deleted: ")) { DeveloperRoles.addDeveloperRole(new DeveloperRoles(previousCommand.substring(29))); } - return new CommandResult(MESSAGE_SUCCESS + "\n" + previousCommand, index); } } diff --git a/src/test/java/seedu/address/logic/commands/RedoCommandTest.java b/src/test/java/seedu/address/logic/commands/RedoCommandTest.java new file mode 100644 index 00000000000..da5bdaa4092 --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/RedoCommandTest.java @@ -0,0 +1,101 @@ +package seedu.address.logic.commands; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.testutil.Assert.assertThrows; +import static seedu.address.testutil.TypicalClients.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.model.client.ClientRoles; +import seedu.address.model.developer.DeveloperRoles; +import seedu.address.testutil.ClientBuilder; + +public class RedoCommandTest { + + private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model modelAfterChange = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private RedoCommand redoCommand = new RedoCommand(); + + @Test + public void execute_validRedo_success() throws CommandException { + ClientBuilder clientBuilder = new ClientBuilder(); + model.addClient(clientBuilder.build()); + model.commitAddressBook(model, "Add Benson", TabIndex.Client); + model.undoAddressBook(model); + + modelAfterChange = model; + + redoCommand.execute(model); + + assertEquals(model, modelAfterChange); // Ensure that the redo was successful + } + + @Test + public void execute_noRedoAvailable_throwsCommandException() { + assertThrows(CommandException.class, () -> redoCommand.execute(model)); + } + + @Test + public void execute_redoRoleCommand_success() throws CommandException { + // Undo a command that added a new role for a client + ClientRoles.addClientRole(new ClientRoles("NewRole")); + model.commitAddressBook(model, "New role for client added: NewRole", TabIndex.Client); + model.undoAddressBook(model); + + // Redo the role addition + redoCommand.execute(model); + + assertTrue(ClientRoles.isValidRole("NewRole")); + } + + @Test + public void execute_redoDeveloperRoleCommand_success() throws CommandException { + // Undo a command that added a new role for a developer + DeveloperRoles.addDeveloperRole(new DeveloperRoles("NewRole")); + model.commitAddressBook(model, "New role for developer added: NewRole", TabIndex.Developer); + model.undoAddressBook(model); + + // Redo the role addition + redoCommand.execute(model); + assertTrue(ClientRoles.isValidRole("NewRole")); + model.undoAddressBook(model); + } + + @Test + public void execute_redoDeleteClientRoleCommand_success() throws CommandException { + ClientRoles.addClientRole(new ClientRoles("RoleToDelete")); + model.commitAddressBook(model, "New role for client added: RoleToDelete", TabIndex.Client); + + // Undo a command that deleted a role for a client + ClientRoles.deleteClientRole(new ClientRoles("RoleToDelete")); + model.commitAddressBook(model, "Role for clients deleted: RoleToDelete", TabIndex.Client); + model.undoAddressBook(model); + + // Redo the role deletion + redoCommand.execute(model); + + assertFalse(ClientRoles.isValidRole("RoleToDelete")); + } + + @Test + public void execute_redoDeleteDeveloperRoleCommand_success() throws CommandException { + DeveloperRoles.addDeveloperRole(new DeveloperRoles("RoleToDelete")); + model.commitAddressBook(model, "New role for developer added: NewRole", TabIndex.Developer); + + // Undo a command that deleted a role for a developer + DeveloperRoles.deleteDeveloperRole(new DeveloperRoles("RoleToDelete")); + model.commitAddressBook(model, "Role for developers deleted: RoleToDelete", TabIndex.Developer); + model.undoAddressBook(model); + + // Redo the role deletion + redoCommand.execute(model); + + assertFalse(DeveloperRoles.isValidRole("RoleToDelete")); + } +} diff --git a/src/test/java/seedu/address/logic/commands/UndoCommandTest.java b/src/test/java/seedu/address/logic/commands/UndoCommandTest.java new file mode 100644 index 00000000000..34c24f0d3f9 --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/UndoCommandTest.java @@ -0,0 +1,123 @@ +package seedu.address.logic.commands; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.testutil.Assert.assertThrows; +import static seedu.address.testutil.TypicalClients.BOB; +import static seedu.address.testutil.TypicalClients.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.model.client.ClientRoles; +import seedu.address.model.developer.DeveloperRoles; +import seedu.address.testutil.ClientBuilder; +import seedu.address.testutil.DeveloperBuilder; + +public class UndoCommandTest { + + private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model modelAfterChange = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private UndoCommand undoCommand = new UndoCommand(); + + @Test + public void execute_validUndo_success() throws CommandException { + model.addClient(BOB); + model.commitAddressBook(model, "Add Alice", TabIndex.Client); + undoCommand.execute(model); + assertEquals(model, modelAfterChange); + } + + @Test + public void execute_noUndoAvailable_throwsCommandException() { + assertThrows(CommandException.class, () -> undoCommand.execute(model)); + } + + @Test + public void execute_undoNonRoleCommand_success() throws CommandException { + // Add a new role for a client + ClientBuilder clientBuilder = new ClientBuilder(); + model.addClient(clientBuilder.build()); + model.commitAddressBook(model, "New client added", TabIndex.Client); + + // Undo the role addition + undoCommand.execute(model); + + assertFalse(model.getFilteredClientList().contains(clientBuilder.build())); + } + + @Test + public void execute_undoRoleCommand_success() throws CommandException { + // Add a new role for a client + ClientRoles.addClientRole(new ClientRoles("NewRole")); + model.commitAddressBook(model, "New role for client added: NewRole", TabIndex.Client); + + // Undo the role addition + undoCommand.execute(model); + + assertFalse(ClientRoles.isValidRole("NewRole")); + } + + @Test + public void execute_undoNonDeveloperRoleCommand_success() throws CommandException { + // Add a new role for a client + DeveloperBuilder developerBuilder = new DeveloperBuilder(); + model.addDeveloper(developerBuilder.build()); + model.commitAddressBook(model, "New Developer Added", TabIndex.Developer); + + // Undo the role addition + undoCommand.execute(model); + + assertFalse(model.getFilteredClientList().contains(developerBuilder.build())); + } + + @Test + public void execute_undoDeveloperRoleCommand_success() throws CommandException { + // Add a new role for a client + DeveloperRoles.addDeveloperRole(new DeveloperRoles("NewRole")); + model.commitAddressBook(model, "New role for developer added: NewRole", TabIndex.Developer); + + // Undo the role addition + undoCommand.execute(model); + + assertFalse(DeveloperRoles.isValidRole("NewRole")); + } + + @Test + public void execute_undoDeleteClientRoleCommand_success() throws CommandException { + ClientRoles.addClientRole(new ClientRoles("NewRole")); + model.commitAddressBook(model, "New role for client added: NewRole", TabIndex.Client); + + // Delete a role for a client + ClientRoles.deleteClientRole(new ClientRoles("NewRole")); + model.commitAddressBook(model, "Role for clients deleted: NewRole", TabIndex.Client); + + // Undo the role deletion + undoCommand.execute(model); + + assertTrue(ClientRoles.isValidRole("NewRole")); + + undoCommand.execute(model); + } + + @Test + public void execute_undoDeleteDeveloperRoleCommand_success() throws CommandException { + DeveloperRoles.addDeveloperRole(new DeveloperRoles("RoleToDelete")); + model.commitAddressBook(model, "New role for client added: NewRole", TabIndex.Developer); + + // Delete a role for a developer + DeveloperRoles.deleteDeveloperRole(new DeveloperRoles("RoleToDelete")); + model.commitAddressBook(model, "Role for developers deleted: RoleToDelete", TabIndex.Developer); + + // Undo the role deletion + undoCommand.execute(model); + + assertTrue(DeveloperRoles.isValidRole("RoleToDelete")); + + undoCommand.execute(model); + } +} From 0a8ac05bae53b1e1812184b47560340336d6ff84 Mon Sep 17 00:00:00 2001 From: mingyu Date: Mon, 13 Nov 2023 15:53:57 +0800 Subject: [PATCH 5/6] fix test cases --- .../address/logic/commands/RedoCommandTest.java | 14 ++++++++------ .../address/logic/commands/UndoCommandTest.java | 9 ++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/RedoCommandTest.java b/src/test/java/seedu/address/logic/commands/RedoCommandTest.java index da5bdaa4092..4b62b132fc6 100644 --- a/src/test/java/seedu/address/logic/commands/RedoCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/RedoCommandTest.java @@ -21,6 +21,7 @@ public class RedoCommandTest { private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); private Model modelAfterChange = new ModelManager(getTypicalAddressBook(), new UserPrefs()); private RedoCommand redoCommand = new RedoCommand(); + private UndoCommand undoCommand = new UndoCommand(); @Test public void execute_validRedo_success() throws CommandException { @@ -46,12 +47,13 @@ public void execute_redoRoleCommand_success() throws CommandException { // Undo a command that added a new role for a client ClientRoles.addClientRole(new ClientRoles("NewRole")); model.commitAddressBook(model, "New role for client added: NewRole", TabIndex.Client); - model.undoAddressBook(model); + undoCommand.execute(model); // Redo the role addition redoCommand.execute(model); assertTrue(ClientRoles.isValidRole("NewRole")); + ClientRoles.deleteClientRole(new ClientRoles("NewRole")); } @Test @@ -59,12 +61,12 @@ public void execute_redoDeveloperRoleCommand_success() throws CommandException { // Undo a command that added a new role for a developer DeveloperRoles.addDeveloperRole(new DeveloperRoles("NewRole")); model.commitAddressBook(model, "New role for developer added: NewRole", TabIndex.Developer); - model.undoAddressBook(model); + undoCommand.execute(model); // Redo the role addition redoCommand.execute(model); - assertTrue(ClientRoles.isValidRole("NewRole")); - model.undoAddressBook(model); + assertTrue(DeveloperRoles.isValidRole("NewRole")); + DeveloperRoles.deleteDeveloperRole(new DeveloperRoles("NewRole")); } @Test @@ -75,7 +77,7 @@ public void execute_redoDeleteClientRoleCommand_success() throws CommandExceptio // Undo a command that deleted a role for a client ClientRoles.deleteClientRole(new ClientRoles("RoleToDelete")); model.commitAddressBook(model, "Role for clients deleted: RoleToDelete", TabIndex.Client); - model.undoAddressBook(model); + undoCommand.execute(model); // Redo the role deletion redoCommand.execute(model); @@ -91,7 +93,7 @@ public void execute_redoDeleteDeveloperRoleCommand_success() throws CommandExcep // Undo a command that deleted a role for a developer DeveloperRoles.deleteDeveloperRole(new DeveloperRoles("RoleToDelete")); model.commitAddressBook(model, "Role for developers deleted: RoleToDelete", TabIndex.Developer); - model.undoAddressBook(model); + undoCommand.execute(model); // Redo the role deletion redoCommand.execute(model); diff --git a/src/test/java/seedu/address/logic/commands/UndoCommandTest.java b/src/test/java/seedu/address/logic/commands/UndoCommandTest.java index 34c24f0d3f9..bc313d36e38 100644 --- a/src/test/java/seedu/address/logic/commands/UndoCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/UndoCommandTest.java @@ -9,6 +9,7 @@ import org.junit.jupiter.api.Test; +import seedu.address.logic.commands.deleteroles.DeleteClientRoleCommand; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.ModelManager; @@ -51,7 +52,7 @@ public void execute_undoNonRoleCommand_success() throws CommandException { } @Test - public void execute_undoRoleCommand_success() throws CommandException { + public void execute_undoClientRoleCommand_success() throws CommandException { // Add a new role for a client ClientRoles.addClientRole(new ClientRoles("NewRole")); model.commitAddressBook(model, "New role for client added: NewRole", TabIndex.Client); @@ -100,8 +101,7 @@ public void execute_undoDeleteClientRoleCommand_success() throws CommandExceptio undoCommand.execute(model); assertTrue(ClientRoles.isValidRole("NewRole")); - - undoCommand.execute(model); + ClientRoles.deleteClientRole(new ClientRoles("NewRole")); } @Test @@ -117,7 +117,6 @@ public void execute_undoDeleteDeveloperRoleCommand_success() throws CommandExcep undoCommand.execute(model); assertTrue(DeveloperRoles.isValidRole("RoleToDelete")); - - undoCommand.execute(model); + DeveloperRoles.deleteDeveloperRole(new DeveloperRoles("RoleToDelete")); } } From e3b2d8e869f27183900c24cd9259022b48441f5b Mon Sep 17 00:00:00 2001 From: mingyu-wan <112554073+mingyu-wan@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:00:05 +0800 Subject: [PATCH 6/6] fix checkstyles --- src/test/java/seedu/address/logic/commands/UndoCommandTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/commands/UndoCommandTest.java b/src/test/java/seedu/address/logic/commands/UndoCommandTest.java index bc313d36e38..6fa32d885b2 100644 --- a/src/test/java/seedu/address/logic/commands/UndoCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/UndoCommandTest.java @@ -9,7 +9,6 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.deleteroles.DeleteClientRoleCommand; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.ModelManager;