diff --git a/build.gradle b/build.gradle index 03e3e121521..6f45dd25754 100644 --- a/build.gradle +++ b/build.gradle @@ -75,7 +75,7 @@ dependencies { } shadowJar { - archiveFileName = 'addressbook.jar' + archiveFileName = 'CodeContact.jar' } defaultTasks 'clean', 'test' diff --git a/src/main/java/seedu/address/model/client/Client.java b/src/main/java/seedu/address/model/client/Client.java index facd16681fb..f107ca34aa2 100644 --- a/src/main/java/seedu/address/model/client/Client.java +++ b/src/main/java/seedu/address/model/client/Client.java @@ -66,7 +66,7 @@ public boolean isSameClient(Client otherClient) { } return otherClient != null - && otherClient.getName().equals(getName()); + && otherClient.getName().fullName.toLowerCase().equals(getName().fullName.toLowerCase()); } @Override diff --git a/src/main/java/seedu/address/model/developer/Developer.java b/src/main/java/seedu/address/model/developer/Developer.java index 05142f7e92a..217554a1540 100644 --- a/src/main/java/seedu/address/model/developer/Developer.java +++ b/src/main/java/seedu/address/model/developer/Developer.java @@ -66,7 +66,7 @@ public boolean isSameDeveloper(Developer otherDeveloper) { } return otherDeveloper != null - && otherDeveloper.getName().equals(getName()); + && otherDeveloper.getName().fullName.toLowerCase().equals(getName().fullName.toLowerCase()); } public GithubId getGithubId() { diff --git a/src/main/resources/view/DeveloperListCard.fxml b/src/main/resources/view/DeveloperListCard.fxml index 15434ecf0a8..b51f4672463 100644 --- a/src/main/resources/view/DeveloperListCard.fxml +++ b/src/main/resources/view/DeveloperListCard.fxml @@ -1,6 +1,5 @@ - @@ -10,48 +9,50 @@ - + + + - + - + - - + - - - + diff --git a/src/test/java/seedu/address/commons/core/ConfigTest.java b/src/test/java/seedu/address/commons/core/ConfigTest.java index d3ba2a52a89..f79f4538909 100644 --- a/src/test/java/seedu/address/commons/core/ConfigTest.java +++ b/src/test/java/seedu/address/commons/core/ConfigTest.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -20,7 +19,7 @@ public void toStringMethod() { public void equalsMethod() { Config defaultConfig = new Config(); assertNotNull(defaultConfig); - assertTrue(defaultConfig.equals(defaultConfig)); + assertEquals(defaultConfig, defaultConfig); } diff --git a/src/test/java/seedu/address/commons/core/VersionTest.java b/src/test/java/seedu/address/commons/core/VersionTest.java index 653bc23bb27..105778ec819 100644 --- a/src/test/java/seedu/address/commons/core/VersionTest.java +++ b/src/test/java/seedu/address/commons/core/VersionTest.java @@ -27,7 +27,7 @@ public void versionConstructor_correctParameter_valueAsExpected() { assertEquals(19, version.getMajor()); assertEquals(10, version.getMinor()); assertEquals(20, version.getPatch()); - assertEquals(true, version.isEarlyAccess()); + assertTrue(version.isEarlyAccess()); } @Test @@ -53,11 +53,11 @@ public void versionComparable_validVersion_compareToIsCorrect() { // Tests equality one = new Version(0, 0, 0, true); another = new Version(0, 0, 0, true); - assertTrue(one.compareTo(another) == 0); + assertEquals(0, one.compareTo(another)); one = new Version(11, 12, 13, false); another = new Version(11, 12, 13, false); - assertTrue(one.compareTo(another) == 0); + assertEquals(0, one.compareTo(another)); // Tests different patch one = new Version(0, 0, 5, false); @@ -121,11 +121,11 @@ public void versionComparable_validVersion_equalIsCorrect() { one = new Version(0, 0, 0, false); another = new Version(0, 0, 0, false); - assertTrue(one.equals(another)); + assertEquals(one, another); one = new Version(100, 191, 275, true); another = new Version(100, 191, 275, true); - assertTrue(one.equals(another)); + assertEquals(one, another); } private void verifyVersionParsedCorrectly(String versionString, diff --git a/src/test/java/seedu/address/commons/util/CollectionUtilTest.java b/src/test/java/seedu/address/commons/util/CollectionUtilTest.java index b467a3dc025..2c21d11b040 100644 --- a/src/test/java/seedu/address/commons/util/CollectionUtilTest.java +++ b/src/test/java/seedu/address/commons/util/CollectionUtilTest.java @@ -40,14 +40,14 @@ public void requireAllNonNullVarargs() { assertNullPointerExceptionThrown((Object[]) null); // confirms nulls inside lists in the argument list are not considered - List containingNull = Arrays.asList((Object) null); + List containingNull = Collections.singletonList((Object) null); assertNullPointerExceptionNotThrown(containingNull, new Object()); } @Test public void requireAllNonNullCollection() { // lists containing nulls in the front - assertNullPointerExceptionThrown(Arrays.asList((Object) null)); + assertNullPointerExceptionThrown(Collections.singletonList((Object) null)); assertNullPointerExceptionThrown(Arrays.asList(null, new Object(), "")); // lists containing nulls in the middle @@ -66,10 +66,10 @@ public void requireAllNonNullCollection() { // list with all non-null elements assertNullPointerExceptionNotThrown(Arrays.asList(new Object(), "ham", Integer.valueOf(1))); - assertNullPointerExceptionNotThrown(Arrays.asList(new Object())); + assertNullPointerExceptionNotThrown(List.of(new Object())); // confirms nulls inside nested lists are not considered - List containingNull = Arrays.asList((Object) null); + List containingNull = Collections.singletonList((Object) null); assertNullPointerExceptionNotThrown(Arrays.asList(containingNull, new Object())); } diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index cf37ec968eb..a391179bc7e 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -40,7 +40,7 @@ public class LogicManagerTest { @TempDir public Path temporaryFolder; - private Model model = new ModelManager(); + private final Model model = new ModelManager(); private Logic logic; @BeforeEach diff --git a/src/test/java/seedu/address/logic/commands/AddDeveloperCommandTest.java b/src/test/java/seedu/address/logic/commands/AddDeveloperCommandTest.java index 3696a76778f..53177106179 100644 --- a/src/test/java/seedu/address/logic/commands/AddDeveloperCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddDeveloperCommandTest.java @@ -2,14 +2,13 @@ import static java.util.Objects.requireNonNull; 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 org.junit.jupiter.api.Assertions.assertNotEquals; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalDevelopers.ALICE; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Arrays; +import java.util.List; import java.util.function.Predicate; import org.junit.jupiter.api.Test; @@ -46,7 +45,7 @@ public void execute_personAcceptedByModel_addSuccessful() throws Exception { assertEquals(String.format(AddDeveloperCommand.MESSAGE_SUCCESS, Messages.format(validDeveloper)), commandResult.getFeedbackToUser()); - assertEquals(Arrays.asList(validDeveloper), modelStub.developersAdded); + assertEquals(List.of(validDeveloper), modelStub.developersAdded); } @Test @@ -55,7 +54,8 @@ public void execute_duplicatePerson_throwsCommandException() { AddDeveloperCommand addDeveloperCommand = new AddDeveloperCommand(validDeveloper); ModelStub modelStub = new ModelStubWithDeveloper(validDeveloper); - assertThrows(CommandException.class, AddDeveloperCommand.MESSAGE_DUPLICATE_DEVELOPER, () -> addDeveloperCommand.execute(modelStub)); + assertThrows(CommandException.class, AddDeveloperCommand.MESSAGE_DUPLICATE_DEVELOPER, () + -> addDeveloperCommand.execute(modelStub)); } @Test @@ -66,20 +66,20 @@ public void equals() { AddDeveloperCommand addBobCommand = new AddDeveloperCommand(bob); // same object -> returns true - assertTrue(addAliceCommand.equals(addAliceCommand)); + assertEquals(addAliceCommand, addAliceCommand); // same values -> returns true AddDeveloperCommand addAliceCommandCopy = new AddDeveloperCommand(alice); - assertTrue(addAliceCommand.equals(addAliceCommandCopy)); + assertEquals(addAliceCommand, addAliceCommandCopy); // different types -> returns false - assertFalse(addAliceCommand.equals(1)); + assertNotEquals(1, addAliceCommand); // null -> returns false - assertFalse(addAliceCommand.equals(null)); + assertNotEquals(null, addAliceCommand); // different developer -> returns false - assertFalse(addAliceCommand.equals(addBobCommand)); + assertNotEquals(addAliceCommand, addBobCommand); } @Test diff --git a/src/test/java/seedu/address/logic/commands/CommandResultTest.java b/src/test/java/seedu/address/logic/commands/CommandResultTest.java index 7b8c7cd4546..c5e075a7f4f 100644 --- a/src/test/java/seedu/address/logic/commands/CommandResultTest.java +++ b/src/test/java/seedu/address/logic/commands/CommandResultTest.java @@ -10,11 +10,11 @@ public class CommandResultTest { @Test public void equals() { - CommandResult commandResult = new CommandResult("feedback"); + CommandResult commandResult = new CommandResult("feedback", TabIndex.Developer); // same values -> returns true - assertTrue(commandResult.equals(new CommandResult("feedback"))); - assertTrue(commandResult.equals(new CommandResult("feedback", false, false))); + assertTrue(commandResult.equals(new CommandResult("feedback", TabIndex.Developer))); + assertTrue(commandResult.equals(new CommandResult("feedback", false, false, TabIndex.Developer))); // same object -> returns true assertTrue(commandResult.equals(commandResult)); @@ -26,35 +26,40 @@ public void equals() { assertFalse(commandResult.equals(0.5f)); // different feedbackToUser value -> returns false - assertFalse(commandResult.equals(new CommandResult("different"))); + assertFalse(commandResult.equals(new CommandResult("different", TabIndex.Developer))); // different showHelp value -> returns false - assertFalse(commandResult.equals(new CommandResult("feedback", true, false))); + assertFalse(commandResult.equals(new CommandResult("feedback", true, false, TabIndex.Developer))); // different exit value -> returns false - assertFalse(commandResult.equals(new CommandResult("feedback", false, true))); + assertFalse(commandResult.equals(new CommandResult("feedback", false, true, TabIndex.Developer))); } @Test public void hashcode() { - CommandResult commandResult = new CommandResult("feedback"); + CommandResult commandResult = new CommandResult("feedback", TabIndex.Developer); // same values -> returns same hashcode - assertEquals(commandResult.hashCode(), new CommandResult("feedback").hashCode()); + assertEquals(commandResult.hashCode(), new CommandResult("feedback", TabIndex.Developer) + .hashCode()); // different feedbackToUser value -> returns different hashcode - assertNotEquals(commandResult.hashCode(), new CommandResult("different").hashCode()); + assertNotEquals(commandResult.hashCode(), + new CommandResult("different", TabIndex.Developer) + .hashCode()); // different showHelp value -> returns different hashcode - assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", true, false).hashCode()); + assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", true, false, + TabIndex.Developer).hashCode()); // different exit value -> returns different hashcode - assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", false, true).hashCode()); + assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", false, true, + TabIndex.Developer).hashCode()); } @Test public void toStringMethod() { - CommandResult commandResult = new CommandResult("feedback"); + CommandResult commandResult = new CommandResult("feedback", TabIndex.Developer); String expected = CommandResult.class.getCanonicalName() + "{feedbackToUser=" + commandResult.getFeedbackToUser() + ", showHelp=" + commandResult.isShowHelp() + ", exit=" + commandResult.isExit() + "}"; diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 4eb73ebab2a..21ff2752f4c 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -3,19 +3,19 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DATEJOINED; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GITHUBID; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT; +import static seedu.address.logic.parser.CliSyntax.PREFIX_RATING; import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE; import static seedu.address.logic.parser.CliSyntax.PREFIX_SALARY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DATEJOINED; -import static seedu.address.logic.parser.CliSyntax.PREFIX_GITHUBID; -import static seedu.address.logic.parser.CliSyntax.PREFIX_RATING; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT; import static seedu.address.testutil.Assert.assertThrows; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import seedu.address.commons.core.index.Index; @@ -79,12 +79,11 @@ public class CommandTestUtil { public static final String RATING_DEC_BOB = " " + PREFIX_RATING + VALID_RATING_BOB; - public static final String INVALID_NAME_DESC = " " + PREFIX_NAME + "James&"; // '&' not allowed in names public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses - public static final String INVALID_ROLE_DESC = " " + PREFIX_ROLE; // + public static final String INVALID_ROLE_DESC = " " + PREFIX_ROLE; // public static final String INVALID_SALARY_DESC = "abc" + PREFIX_SALARY; // public static final String INVALID_DATEJOINED_DESC = "2003-23" + PREFIX_DATEJOINED; // public static final String INVALID_GITHUBID_DESC = " " + PREFIX_GITHUBID; // @@ -158,12 +157,13 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri * Updates {@code model}'s filtered list to show only the developer at the given {@code targetIndex} in the * {@code model}'s address book. */ - public static void showPersonAtIndex(Model model, Index targetIndex) { + public static void showDeveloperAtIndex(Model model, Index targetIndex) { assertTrue(targetIndex.getZeroBased() < model.getFilteredDeveloperList().size()); Developer developer = model.getFilteredDeveloperList().get(targetIndex.getZeroBased()); final String[] splitName = developer.getName().fullName.split("\\s+"); - model.updateFilteredDeveloperList(new NameDeveloperContainsKeywordsPredicate(Arrays.asList(splitName[0]))); + model.updateFilteredDeveloperList(new NameDeveloperContainsKeywordsPredicate(Collections + .singletonList(splitName[0]))); assertEquals(1, model.getFilteredDeveloperList().size()); } diff --git a/src/test/java/seedu/address/logic/commands/DeleteDeveloperCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteDeveloperCommandTest.java index 9d775e23348..30006b82d0d 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteDeveloperCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteDeveloperCommandTest.java @@ -1,14 +1,14 @@ 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.assertNotEquals; 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.logic.commands.CommandTestUtil.showPersonAtIndex; +import static seedu.address.logic.commands.CommandTestUtil.showDeveloperAtIndex; +import static seedu.address.testutil.TypicalDevelopers.getTypicalAddressBook; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -import static seedu.address.testutil.TypicalDevelopers.getTypicalAddressBook; import org.junit.jupiter.api.Test; @@ -26,42 +26,42 @@ */ public class DeleteDeveloperCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); @Test public void execute_validIndexUnfilteredList_success() { - Developer developerToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Developer developerToDelete = model.getFilteredDeveloperList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteDeveloperCommand deleteDeveloperCommand = new DeleteDeveloperCommand(INDEX_FIRST_PERSON); - String expectedMessage = String.format(DeleteDeveloperCommand.MESSAGE_DELETE_PERSON_SUCCESS, + String expectedMessage = String.format(DeleteDeveloperCommand.MESSAGE_DELETE_DEVELOPER_SUCCESS, Messages.format(developerToDelete)); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(developerToDelete); + expectedModel.deleteDeveloper(developerToDelete); assertCommandSuccess(deleteDeveloperCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexUnfilteredList_throwsCommandException() { - Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredDeveloperList().size() + 1); DeleteDeveloperCommand deleteDeveloperCommand = new DeleteDeveloperCommand(outOfBoundIndex); - assertCommandFailure(deleteDeveloperCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(deleteDeveloperCommand, model, Messages.MESSAGE_INVALID_DEVELOPER_DISPLAYED_INDEX); } @Test public void execute_validIndexFilteredList_success() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); - Developer developerToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Developer developerToDelete = model.getFilteredDeveloperList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteDeveloperCommand deleteDeveloperCommand = new DeleteDeveloperCommand(INDEX_FIRST_PERSON); - String expectedMessage = String.format(DeleteDeveloperCommand.MESSAGE_DELETE_PERSON_SUCCESS, + String expectedMessage = String.format(DeleteDeveloperCommand.MESSAGE_DELETE_DEVELOPER_SUCCESS, Messages.format(developerToDelete)); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(developerToDelete); + expectedModel.deleteDeveloper(developerToDelete); showNoPerson(expectedModel); assertCommandSuccess(deleteDeveloperCommand, model, expectedMessage, expectedModel); @@ -69,15 +69,15 @@ public void execute_validIndexFilteredList_success() { @Test public void execute_invalidIndexFilteredList_throwsCommandException() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); Index outOfBoundIndex = INDEX_SECOND_PERSON; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getDeveloperList().size()); DeleteDeveloperCommand deleteDeveloperCommand = new DeleteDeveloperCommand(outOfBoundIndex); - assertCommandFailure(deleteDeveloperCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(deleteDeveloperCommand, model, Messages.MESSAGE_INVALID_DEVELOPER_DISPLAYED_INDEX); } @Test @@ -86,20 +86,20 @@ public void equals() { DeleteDeveloperCommand deleteSecondCommand = new DeleteDeveloperCommand(INDEX_SECOND_PERSON); // same object -> returns true - assertTrue(deleteFirstCommand.equals(deleteFirstCommand)); + assertEquals(deleteFirstCommand, deleteFirstCommand); // same values -> returns true DeleteDeveloperCommand deleteFirstCommandCopy = new DeleteDeveloperCommand(INDEX_FIRST_PERSON); - assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy)); + assertEquals(deleteFirstCommand, deleteFirstCommandCopy); // different types -> returns false - assertFalse(deleteFirstCommand.equals(1)); + assertNotEquals(1, deleteFirstCommand); // null -> returns false - assertFalse(deleteFirstCommand.equals(null)); + assertNotEquals(null, deleteFirstCommand); // different developer -> returns false - assertFalse(deleteFirstCommand.equals(deleteSecondCommand)); + assertNotEquals(deleteFirstCommand, deleteSecondCommand); } @Test @@ -114,8 +114,8 @@ public void toStringMethod() { * Updates {@code model}'s filtered list to show no one. */ private void showNoPerson(Model model) { - model.updateFilteredPersonList(p -> false); + model.updateFilteredDeveloperList(p -> false); - assertTrue(model.getFilteredPersonList().isEmpty()); + assertTrue(model.getFilteredDeveloperList().isEmpty()); } } diff --git a/src/test/java/seedu/address/logic/commands/EditClientCommandTest.java b/src/test/java/seedu/address/logic/commands/EditClientCommandTest.java new file mode 100644 index 00000000000..9f72a9b7f62 --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/EditClientCommandTest.java @@ -0,0 +1,195 @@ +package seedu.address.logic.commands; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_1_BOB; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.logic.commands.CommandTestUtil.showDeveloperAtIndex; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; +import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; + +import org.junit.jupiter.api.Test; + +import seedu.address.commons.core.index.Index; +import seedu.address.logic.Messages; +import seedu.address.logic.commands.edit.EditDeveloperCommand; +import seedu.address.model.AddressBook; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.model.developer.Developer; +import seedu.address.testutil.DeveloperBuilder; +import seedu.address.testutil.EditDeveloperDescriptorBuilder; + +/** + * Contains integration tests (interaction with the Model) and unit tests for EditDeveloperCommand. + */ +public class EditClientCommandTest { + + private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + + @Test + public void execute_allFieldsSpecifiedUnfilteredList_success() { + Developer editedDeveloper = new DeveloperBuilder().build(); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder(editedDeveloper) + .build(); + EditDeveloperCommand editCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, descriptor); + + String expectedMessage = String.format(EditDeveloperCommand.MESSAGE_EDIT_DEVELOPER_SUCCESS, + Messages.format(editedDeveloper)); + + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + expectedModel.setDeveloper(model.getFilteredDeveloperList().get(0), editedDeveloper); + + assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); + } + + @Test + public void execute_someFieldsSpecifiedUnfilteredList_success() { + Index indexLastDeveloper = Index.fromOneBased(model.getFilteredDeveloperList().size()); + Developer lastDeveloper = model.getFilteredDeveloperList().get(indexLastDeveloper.getZeroBased()); + + DeveloperBuilder developerInList = new DeveloperBuilder(lastDeveloper); + Developer editedDeveloper = developerInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + .withProjects(VALID_PROJECT_1_BOB).build(); + + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder() + .withName(VALID_NAME_BOB) + .withPhone(VALID_PHONE_BOB).withProjects(VALID_PROJECT_1_BOB).build(); + EditDeveloperCommand editCommand = new EditDeveloperCommand(indexLastDeveloper, descriptor); + + String expectedMessage = String.format(EditDeveloperCommand.MESSAGE_EDIT_DEVELOPER_SUCCESS, + Messages.format(editedDeveloper)); + + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + expectedModel.setDeveloper(lastDeveloper, editedDeveloper); + + assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); + } + + @Test + public void execute_noFieldSpecifiedUnfilteredList_success() { + EditDeveloperCommand editCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, + new EditDeveloperCommand.EditDeveloperDescriptor()); + Developer editedDeveloper = model.getFilteredDeveloperList().get(INDEX_FIRST_PERSON.getZeroBased()); + + String expectedMessage = String.format(EditDeveloperCommand.MESSAGE_EDIT_DEVELOPER_SUCCESS, + Messages.format(editedDeveloper)); + + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + + assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); + } + + @Test + public void execute_filteredList_success() { + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); + + Developer developerInFilteredList = model.getFilteredDeveloperList().get(INDEX_FIRST_PERSON.getZeroBased()); + Developer editedDeveloper = new DeveloperBuilder(developerInFilteredList).withName(VALID_NAME_BOB).build(); + EditDeveloperCommand editCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, + new EditDeveloperDescriptorBuilder().withName(VALID_NAME_BOB).build()); + + String expectedMessage = String.format(EditDeveloperCommand.MESSAGE_EDIT_DEVELOPER_SUCCESS, + Messages.format(editedDeveloper)); + + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + expectedModel.setDeveloper(model.getFilteredDeveloperList().get(0), editedDeveloper); + + assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); + } + + @Test + public void execute_duplicateDeveloperUnfilteredList_failure() { + Developer firstDeveloper = model.getFilteredDeveloperList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder(firstDeveloper) + .build(); + EditDeveloperCommand editCommand = new EditDeveloperCommand(INDEX_SECOND_PERSON, descriptor); + + assertCommandFailure(editCommand, model, EditDeveloperCommand.MESSAGE_DUPLICATE_DEVELOPER); + } + + @Test + public void execute_duplicateDeveloperFilteredList_failure() { + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); + + // edit developer in filtered list into a duplicate in address book + Developer developerInList = model.getAddressBook().getDeveloperList().get(INDEX_SECOND_PERSON.getZeroBased()); + EditDeveloperCommand editCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, + new EditDeveloperDescriptorBuilder(developerInList).build()); + + assertCommandFailure(editCommand, model, EditDeveloperCommand.MESSAGE_DUPLICATE_DEVELOPER); + } + + @Test + public void execute_invalidDeveloperIndexUnfilteredList_failure() { + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredDeveloperList().size() + 1); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder() + .withName(VALID_NAME_BOB).build(); + EditDeveloperCommand editCommand = new EditDeveloperCommand(outOfBoundIndex, descriptor); + + assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_DEVELOPER_DISPLAYED_INDEX); + } + + /** + * Edit filtered list where index is larger than size of filtered list, + * but smaller than size of address book + */ + @Test + public void execute_invalidDeveloperIndexFilteredList_failure() { + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); + Index outOfBoundIndex = INDEX_SECOND_PERSON; + // ensures that outOfBoundIndex is still in bounds of address book list + assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getDeveloperList().size()); + + EditDeveloperCommand editCommand = new EditDeveloperCommand(outOfBoundIndex, + new EditDeveloperDescriptorBuilder().withName(VALID_NAME_BOB).build()); + + assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_DEVELOPER_DISPLAYED_INDEX); + } + + @Test + public void equals() { + final EditDeveloperCommand standardCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, DESC_AMY); + + // same values -> returns true + EditDeveloperCommand.EditDeveloperDescriptor copyDescriptor = new EditDeveloperCommand + .EditDeveloperDescriptor(DESC_AMY); + EditDeveloperCommand commandWithSameValues = new EditDeveloperCommand(INDEX_FIRST_PERSON, copyDescriptor); + assertEquals(standardCommand, commandWithSameValues); + + // same object -> returns true + assertEquals(standardCommand, standardCommand); + + // null -> returns false + assertNotEquals(null, standardCommand); + + // different types -> returns false + assertNotEquals(standardCommand, new ClearCommand()); + + // different index -> returns false + assertNotEquals(standardCommand, new EditDeveloperCommand(INDEX_SECOND_PERSON, DESC_AMY)); + + // different descriptor -> returns false + assertNotEquals(standardCommand, new EditDeveloperCommand(INDEX_FIRST_PERSON, DESC_BOB)); + } + + @Test + public void toStringMethod() { + Index index = Index.fromOneBased(1); + EditDeveloperCommand.EditDeveloperDescriptor editDeveloperDescriptor = new EditDeveloperCommand + .EditDeveloperDescriptor(); + EditDeveloperCommand editCommand = new EditDeveloperCommand(index, editDeveloperDescriptor); + String expected = EditDeveloperCommand.class.getCanonicalName() + "{index=" + index + + ", editDeveloperDescriptor=" + + editDeveloperDescriptor + "}"; + assertEquals(expected, editCommand.toString()); + } +} diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java deleted file mode 100644 index a1d49ee2df5..00000000000 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ /dev/null @@ -1,179 +0,0 @@ -package seedu.address.logic.commands; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -import static seedu.address.testutil.TypicalDevelopers.getTypicalAddressBook; - -import org.junit.jupiter.api.Test; - -import seedu.address.commons.core.index.Index; -import seedu.address.logic.Messages; -import seedu.address.logic.commands.edit.EditDeveloperCommand; -import seedu.address.model.AddressBook; -import seedu.address.model.Model; -import seedu.address.model.ModelManager; -import seedu.address.model.UserPrefs; -import seedu.address.model.developer.Developer; -import seedu.address.testutil.DeveloperBuilder; -import seedu.address.testutil.EditDeveloperDescriptorBuilder; -/** - * Contains integration tests (interaction with the Model) and unit tests for EditCommand. - */ -public class EditCommandTest { - - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - - @Test - public void execute_allFieldsSpecifiedUnfilteredList_success() { - Developer editedDeveloper = new DeveloperBuilder().build(); - EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder(editedDeveloper).build(); - EditDeveloperCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, descriptor); - - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDeveloper)); - - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedDeveloper); - - assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); - } - - @Test - public void execute_someFieldsSpecifiedUnfilteredList_success() { - Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); - Developer lastDeveloper = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); - - DeveloperBuilder personInList = new DeveloperBuilder(lastDeveloper); - Developer editedDeveloper = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withProjects(VALID_TAG_HUSBAND).build(); - - EditDeveloperDescriptorBuilder descriptor = new EditDeveloperDescriptorBuilder().withName(VALID_NAME_BOB) - .withPhone(VALID_PHONE_BOB).withProjects(VALID_TAG_HUSBAND).build(); - EditCommand editCommand = new EditCommand(indexLastPerson, descriptor); - - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDeveloper)); - - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(lastDeveloper, editedDeveloper); - - assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); - } - - @Test - public void execute_noFieldSpecifiedUnfilteredList_success() { - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptor()); - Developer editedDeveloper = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDeveloper)); - - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - - assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); - } - - @Test - public void execute_filteredList_success() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); - - Developer developerInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - Developer editedDeveloper = new DeveloperBuilder(developerInFilteredList).withName(VALID_NAME_BOB).build(); - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, - new EditDeveloperDescriptorBuilder().withName(VALID_NAME_BOB).build()); - - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDeveloper)); - - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedDeveloper); - - assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); - } - - @Test - public void execute_duplicatePersonUnfilteredList_failure() { - Developer firstDeveloper = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - EditDeveloperDescriptorBuilder descriptor = new EditDeveloperDescriptorBuilder(firstDeveloper).build(); - EditCommand editCommand = new EditCommand(INDEX_SECOND_PERSON, descriptor); - - assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); - } - - @Test - public void execute_duplicatePersonFilteredList_failure() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); - - // edit developer in filtered list into a duplicate in address book - Developer developerInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, - new EditDeveloperDescriptorBuilder(developerInList).build()); - - assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); - } - - @Test - public void execute_invalidPersonIndexUnfilteredList_failure() { - Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); - EditDeveloperDescriptorBuilder descriptor = new EditDeveloperDescriptorBuilder().withName(VALID_NAME_BOB).build(); - EditCommand editCommand = new EditCommand(outOfBoundIndex, descriptor); - - assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); - } - - /** - * Edit filtered list where index is larger than size of filtered list, - * but smaller than size of address book - */ - @Test - public void execute_invalidPersonIndexFilteredList_failure() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); - Index outOfBoundIndex = INDEX_SECOND_PERSON; - // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); - - EditCommand editCommand = new EditCommand(outOfBoundIndex, - new EditDeveloperDescriptorBuilder().withName(VALID_NAME_BOB).build()); - - assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); - } - - @Test - public void equals() { - final EditCommand standardCommand = new EditCommand(INDEX_FIRST_PERSON, DESC_AMY); - - // same values -> returns true - EditPersonDescriptor copyDescriptor = new EditPersonDescriptor(DESC_AMY); - EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_PERSON, copyDescriptor); - assertTrue(standardCommand.equals(commandWithSameValues)); - - // same object -> returns true - assertTrue(standardCommand.equals(standardCommand)); - - // null -> returns false - assertFalse(standardCommand.equals(null)); - - // different types -> returns false - assertFalse(standardCommand.equals(new ClearCommand())); - - // different index -> returns false - assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_PERSON, DESC_AMY))); - - // different descriptor -> returns false - assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_PERSON, DESC_BOB))); - } - - @Test - public void toStringMethod() { - Index index = Index.fromOneBased(1); - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); - EditCommand editCommand = new EditCommand(index, editPersonDescriptor); - String expected = EditCommand.class.getCanonicalName() + "{index=" + index + ", editPersonDescriptor=" - + editPersonDescriptor + "}"; - assertEquals(expected, editCommand.toString()); - } - -} diff --git a/src/test/java/seedu/address/logic/commands/EditDeveloperCommandTest.java b/src/test/java/seedu/address/logic/commands/EditDeveloperCommandTest.java new file mode 100644 index 00000000000..577a394e3b4 --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/EditDeveloperCommandTest.java @@ -0,0 +1,198 @@ +package seedu.address.logic.commands; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_1_BOB; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.logic.commands.CommandTestUtil.showDeveloperAtIndex; +import static seedu.address.testutil.TypicalDevelopers.getTypicalAddressBook; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; + +import org.junit.jupiter.api.Test; + +import seedu.address.commons.core.index.Index; +import seedu.address.logic.Messages; +import seedu.address.logic.commands.edit.EditDeveloperCommand; +import seedu.address.model.AddressBook; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.model.developer.Developer; +import seedu.address.testutil.DeveloperBuilder; +import seedu.address.testutil.EditDeveloperDescriptorBuilder; + +/** + * Contains integration tests (interaction with the Model) and unit tests for EditCommand. + */ +public class EditDeveloperCommandTest { + + private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + + @Test + public void execute_allFieldsSpecifiedUnfilteredList_success() { + // + Developer editedDeveloper = new DeveloperBuilder().build(); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder(editedDeveloper) + .build(); + EditDeveloperCommand editCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, descriptor); + + String expectedMessage = String.format(EditDeveloperCommand.MESSAGE_EDIT_DEVELOPER_SUCCESS, + Messages.format(editedDeveloper)); + + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + expectedModel.setDeveloper(model.getFilteredDeveloperList().get(0), editedDeveloper); + + assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); + } + + @Test + public void execute_someFieldsSpecifiedUnfilteredList_success() { + //Fix Errors + Index indexLastPerson = Index.fromOneBased(model.getFilteredDeveloperList().size()); + Developer lastDeveloper = model.getFilteredDeveloperList().get(indexLastPerson.getZeroBased()); + + DeveloperBuilder personInList = new DeveloperBuilder(lastDeveloper); + Developer editedDeveloper = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + .withProjects(VALID_PROJECT_1_BOB).build(); + + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder() + .withName(VALID_NAME_BOB) + .withPhone(VALID_PHONE_BOB).withProjects(VALID_PROJECT_1_BOB).build(); + EditDeveloperCommand editDeveloperCommand = new EditDeveloperCommand(indexLastPerson, descriptor); + + String expectedMessage = String.format(EditDeveloperCommand.MESSAGE_EDIT_DEVELOPER_SUCCESS, + Messages.format(editedDeveloper)); + + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + expectedModel.setDeveloper(lastDeveloper, editedDeveloper); + + assertCommandSuccess(editDeveloperCommand, model, expectedMessage, expectedModel); + } + + @Test + public void execute_noFieldSpecifiedUnfilteredList_success() { + EditDeveloperCommand editDeveloperCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, + new EditDeveloperCommand.EditDeveloperDescriptor()); + Developer editedDeveloper = model.getFilteredDeveloperList().get(INDEX_FIRST_PERSON.getZeroBased()); + + String expectedMessage = String.format(EditDeveloperCommand.MESSAGE_EDIT_DEVELOPER_SUCCESS, + Messages.format(editedDeveloper)); + + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + + assertCommandSuccess(editDeveloperCommand, model, expectedMessage, expectedModel); + } + + @Test + public void execute_filteredList_success() { + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); + + Developer developerInFilteredList = model.getFilteredDeveloperList().get(INDEX_FIRST_PERSON.getZeroBased()); + Developer editedDeveloper = new DeveloperBuilder(developerInFilteredList).withName(VALID_NAME_BOB).build(); + EditDeveloperCommand editDeveloperCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, + new EditDeveloperDescriptorBuilder().withName(VALID_NAME_BOB).build()); + + String expectedMessage = String.format(EditDeveloperCommand.MESSAGE_EDIT_DEVELOPER_SUCCESS, + Messages.format(editedDeveloper)); + + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + expectedModel.setDeveloper(model.getFilteredDeveloperList().get(0), editedDeveloper); + + assertCommandSuccess(editDeveloperCommand, model, expectedMessage, expectedModel); + } + + @Test + public void execute_duplicatePersonUnfilteredList_failure() { + Developer firstDeveloper = model.getFilteredDeveloperList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder(firstDeveloper) + .build(); + EditDeveloperCommand editDeveloperCommand = new EditDeveloperCommand(INDEX_SECOND_PERSON, descriptor); + + assertCommandFailure(editDeveloperCommand, model, EditDeveloperCommand.MESSAGE_DUPLICATE_DEVELOPER); + } + + @Test + public void execute_duplicatePersonFilteredList_failure() { + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); + + // edit developer in filtered list into a duplicate in address book + Developer developerInList = model.getAddressBook().getDeveloperList().get(INDEX_SECOND_PERSON.getZeroBased()); + EditDeveloperCommand editDeveloperCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, + new EditDeveloperDescriptorBuilder(developerInList).build()); + + assertCommandFailure(editDeveloperCommand, model, EditDeveloperCommand.MESSAGE_DUPLICATE_DEVELOPER); + } + + @Test + public void execute_invalidPersonIndexUnfilteredList_failure() { + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredDeveloperList().size() + 1); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder() + .withName(VALID_NAME_BOB).build(); + EditDeveloperCommand editDeveloperCommand = new EditDeveloperCommand(outOfBoundIndex, descriptor); + + assertCommandFailure(editDeveloperCommand, model, Messages.MESSAGE_INVALID_DEVELOPER_DISPLAYED_INDEX); + } + + /** + * Edit filtered list where index is larger than size of filtered list, + * but smaller than size of address book + */ + @Test + public void execute_invalidPersonIndexFilteredList_failure() { + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); + Index outOfBoundIndex = INDEX_SECOND_PERSON; + // ensures that outOfBoundIndex is still in bounds of address book list + assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getDeveloperList().size()); + + EditDeveloperCommand editDeveloperCommand = new EditDeveloperCommand(outOfBoundIndex, + new EditDeveloperDescriptorBuilder().withName(VALID_NAME_BOB).build()); + + assertCommandFailure(editDeveloperCommand, model, Messages.MESSAGE_INVALID_DEVELOPER_DISPLAYED_INDEX); + } + + @Test + public void equals() { + final EditDeveloperCommand standardCommand = new EditDeveloperCommand(INDEX_FIRST_PERSON, DESC_AMY); + + // same values -> returns true + EditDeveloperCommand.EditDeveloperDescriptor copyDescriptor = + new EditDeveloperCommand.EditDeveloperDescriptor(DESC_AMY); + EditDeveloperCommand commandWithSameValues = new EditDeveloperCommand(INDEX_FIRST_PERSON, copyDescriptor); + assertEquals(standardCommand, commandWithSameValues); + + // same object -> returns true + assertEquals(standardCommand, standardCommand); + + // null -> returns false + assertNotEquals(null, standardCommand); + + // different types -> returns false + assertNotEquals(standardCommand, new ClearCommand()); + + // different index -> returns false + assertNotEquals(standardCommand, new EditDeveloperCommand(INDEX_SECOND_PERSON, DESC_AMY)); + + // different descriptor -> returns false + assertNotEquals(standardCommand, new EditDeveloperCommand(INDEX_FIRST_PERSON, DESC_BOB)); + } + + @Test + public void toStringMethod() { + Index index = Index.fromOneBased(1); + EditDeveloperCommand.EditDeveloperDescriptor editDevelopeDescriptor = + new EditDeveloperCommand.EditDeveloperDescriptor(); + EditDeveloperCommand editDeveloperCommand = new EditDeveloperCommand(index, editDevelopeDescriptor); + String expected = EditDeveloperCommand.class.getCanonicalName() + "{index=" + index + + ", editDevelopeDescriptor=" + + editDevelopeDescriptor + "}"; + assertEquals(expected, editDeveloperCommand.toString()); + } + +} diff --git a/src/test/java/seedu/address/logic/commands/EditDeveloperDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditDeveloperDescriptorTest.java index bb88e7446d0..fdf12d0bd33 100644 --- a/src/test/java/seedu/address/logic/commands/EditDeveloperDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditDeveloperDescriptorTest.java @@ -1,7 +1,14 @@ package seedu.address.logic.commands; -import static org.junit.jupiter.api.Assertions.*; -import static seedu.address.logic.commands.CommandTestUtil.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_1_BOB; import org.junit.jupiter.api.Test; @@ -14,39 +21,40 @@ public class EditDeveloperDescriptorTest { public void equals() { // same values -> returns true EditDeveloperDescriptorBuilder descriptorWithSameValues = new EditDeveloperDescriptorBuilder(DESC_AMY); - assertTrue(DESC_AMY.equals(descriptorWithSameValues)); + assertEquals(DESC_AMY, descriptorWithSameValues); // same object -> returns true - assertTrue(DESC_AMY.equals(DESC_AMY)); + assertEquals(DESC_AMY, DESC_AMY); // null -> returns false - assertFalse(DESC_AMY.equals(null)); + assertNotEquals(null, DESC_AMY); // different types -> returns false - assertFalse(DESC_AMY.equals(5)); + assertNotEquals(5, DESC_AMY); // different values -> returns false - assertFalse(DESC_AMY.equals(DESC_BOB)); + assertNotEquals(DESC_AMY, DESC_BOB); // different name -> returns false - EditDeveloperCommand.EditDeveloperDescriptor editedAmy = new EditDeveloperDescriptorBuilder(DESC_AMY).withName(VALID_NAME_BOB).build(); - assertFalse(DESC_AMY.equals(editedAmy)); + EditDeveloperCommand.EditDeveloperDescriptor editedAmy = new EditDeveloperDescriptorBuilder(DESC_AMY) + .withName(VALID_NAME_BOB).build(); + assertNotEquals(DESC_AMY, editedAmy); // different phone -> returns false editedAmy = new EditDeveloperDescriptorBuilder(DESC_AMY).withPhone(VALID_PHONE_BOB).build(); - assertFalse(DESC_AMY.equals(editedAmy)); + assertNotEquals(DESC_AMY, editedAmy); // different email -> returns false editedAmy = new EditDeveloperDescriptorBuilder(DESC_AMY).withEmail(VALID_EMAIL_BOB).build(); - assertFalse(DESC_AMY.equals(editedAmy)); + assertNotEquals(DESC_AMY, editedAmy); // different address -> returns false editedAmy = new EditDeveloperDescriptorBuilder(DESC_AMY).withAddress(VALID_ADDRESS_BOB).build(); - assertFalse(DESC_AMY.equals(editedAmy)); + assertNotEquals(DESC_AMY, editedAmy); // different tags -> returns false editedAmy = new EditDeveloperDescriptorBuilder(DESC_AMY).withProjects(VALID_PROJECT_1_BOB).build(); - assertFalse(DESC_AMY.equals(editedAmy)); + assertNotEquals(DESC_AMY, editedAmy); } @Test diff --git a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java index c4acfca05a6..c935c6c3c51 100644 --- a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java @@ -9,8 +9,8 @@ import seedu.address.model.ModelManager; public class ExitCommandTest { - private Model model = new ModelManager(); - private Model expectedModel = new ModelManager(); + private final Model model = new ModelManager(); + private final Model expectedModel = new ModelManager(); @Test public void execute_exit_success() { diff --git a/src/test/java/seedu/address/logic/commands/FindDeveloperCommandTest.java b/src/test/java/seedu/address/logic/commands/FindDeveloperCommandTest.java index 3b05c85188b..44a933d2ae0 100644 --- a/src/test/java/seedu/address/logic/commands/FindDeveloperCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindDeveloperCommandTest.java @@ -1,8 +1,7 @@ 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 org.junit.jupiter.api.Assertions.assertNotEquals; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.testutil.TypicalDevelopers.CARL; import static seedu.address.testutil.TypicalDevelopers.ELLE; @@ -11,6 +10,7 @@ import java.util.Arrays; import java.util.Collections; +import java.util.List; import org.junit.jupiter.api.Test; @@ -24,8 +24,8 @@ * Contains integration tests (interaction with the Model) for {@code FindDeveloperCommand}. */ public class FindDeveloperCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - private Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); @Test public void equals() { @@ -38,20 +38,20 @@ public void equals() { FindDeveloperCommand findSecondCommand = new FindDeveloperCommand(secondPredicate); // same object -> returns true - assertTrue(findFirstCommand.equals(findFirstCommand)); + assertEquals(findFirstCommand, findFirstCommand); // same values -> returns true FindDeveloperCommand findFirstCommandCopy = new FindDeveloperCommand(firstPredicate); - assertTrue(findFirstCommand.equals(findFirstCommandCopy)); + assertEquals(findFirstCommand, findFirstCommandCopy); // different types -> returns false - assertFalse(findFirstCommand.equals(1)); + assertNotEquals(1, findFirstCommand); // null -> returns false - assertFalse(findFirstCommand.equals(null)); + assertNotEquals(null, findFirstCommand); // different developer -> returns false - assertFalse(findFirstCommand.equals(findSecondCommand)); + assertNotEquals(findFirstCommand, findSecondCommand); } @Test @@ -78,7 +78,8 @@ public void execute_multipleKeywords_multiplePersonsFound() { @Test public void toStringMethod() { - NameDeveloperContainsKeywordsPredicate predicate = new NameDeveloperContainsKeywordsPredicate(Arrays.asList("keyword")); + NameDeveloperContainsKeywordsPredicate predicate = + new NameDeveloperContainsKeywordsPredicate(List.of("keyword")); FindDeveloperCommand findDeveloperCommand = new FindDeveloperCommand(predicate); String expected = FindDeveloperCommand.class.getCanonicalName() + "{predicate=" + predicate + "}"; assertEquals(expected, findDeveloperCommand.toString()); diff --git a/src/test/java/seedu/address/logic/commands/HelpCommandTest.java b/src/test/java/seedu/address/logic/commands/HelpCommandTest.java index 4904fc4352e..0a1ebe91cf9 100644 --- a/src/test/java/seedu/address/logic/commands/HelpCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/HelpCommandTest.java @@ -9,12 +9,12 @@ import seedu.address.model.ModelManager; public class HelpCommandTest { - private Model model = new ModelManager(); - private Model expectedModel = new ModelManager(); + private final Model model = new ModelManager(); + private final Model expectedModel = new ModelManager(); @Test public void execute_help_success() { - CommandResult expectedCommandResult = new CommandResult(SHOWING_HELP_MESSAGE, true, false); + CommandResult expectedCommandResult = new CommandResult(SHOWING_HELP_MESSAGE, true, false, TabIndex.Developer); assertCommandSuccess(new HelpCommand(), model, expectedCommandResult, expectedModel); } } diff --git a/src/test/java/seedu/address/logic/commands/ListClientCommandTest.java b/src/test/java/seedu/address/logic/commands/ListClientCommandTest.java index cc9329aadc2..b0d0e51a407 100644 --- a/src/test/java/seedu/address/logic/commands/ListClientCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListClientCommandTest.java @@ -1,9 +1,9 @@ package seedu.address.logic.commands; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.logic.commands.CommandTestUtil.showDeveloperAtIndex; import static seedu.address.testutil.TypicalDevelopers.getTypicalAddressBook; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +34,7 @@ public void execute_listIsNotFiltered_showsSameList() { @Test public void execute_listIsFiltered_showsEverything() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showDeveloperAtIndex(model, INDEX_FIRST_PERSON); assertCommandSuccess(new ListClientCommand(), model, ListClientCommand.MESSAGE_SUCCESS, expectedModel); } } diff --git a/src/test/java/seedu/address/logic/parser/AddDeveloperCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddDeveloperCommandParserTest.java index 140b0aea582..615b6f7f18c 100644 --- a/src/test/java/seedu/address/logic/parser/AddDeveloperCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddDeveloperCommandParserTest.java @@ -34,14 +34,14 @@ import seedu.address.logic.commands.add.AddDeveloperCommand; import seedu.address.logic.parser.add.AddDeveloperCommandParser; import seedu.address.model.commons.Name; -import seedu.address.model.person.Address; import seedu.address.model.developer.Developer; +import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Phone; import seedu.address.testutil.DeveloperBuilder; public class AddDeveloperCommandParserTest { - private AddDeveloperCommandParser parser = new AddDeveloperCommandParser(); + private final AddDeveloperCommandParser parser = new AddDeveloperCommandParser(); @Test public void parse_allFieldsPresent_success() { @@ -160,20 +160,21 @@ public void parse_compulsoryFieldMissing_failure() { @Test public void parse_invalidValue_failure() { // invalid name - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - , Name.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, + Name.MESSAGE_CONSTRAINTS); // invalid phone - assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - , Phone.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, + Phone.MESSAGE_CONSTRAINTS); // invalid email - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB - , Email.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB, + Email.MESSAGE_CONSTRAINTS); + // invalid address - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC - , Address.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC, + Address.MESSAGE_CONSTRAINTS); // invalid tag //assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 1f2576dc44c..30ca4fe4233 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -55,9 +55,12 @@ public void parseCommand_delete() throws Exception { @Test public void parseCommand_edit() throws Exception { Developer developer = new DeveloperBuilder().build(); - EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder(developer).build(); - EditDeveloperCommand command = (EditDeveloperCommand) parser.parseCommand(EditDeveloperCommand.COMMAND_WORD + " " - + INDEX_FIRST_PERSON.getOneBased() + " " + DeveloperUtil.getEditDeveloperDescriptorDetails(descriptor)); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = + new EditDeveloperDescriptorBuilder(developer).build(); + EditDeveloperCommand command = (EditDeveloperCommand) parser + .parseCommand(EditDeveloperCommand.COMMAND_WORD + " " + + INDEX_FIRST_PERSON.getOneBased() + + " " + DeveloperUtil.getEditDeveloperDescriptorDetails(descriptor)); assertEquals(new EditDeveloperCommand(INDEX_FIRST_PERSON, descriptor), command); } diff --git a/src/test/java/seedu/address/logic/parser/DeleteDeveloperCommandParserTest.java b/src/test/java/seedu/address/logic/parser/DeleteDeveloperCommandParserTest.java index c3520062e0f..9d0806ba43b 100644 --- a/src/test/java/seedu/address/logic/parser/DeleteDeveloperCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/DeleteDeveloperCommandParserTest.java @@ -19,7 +19,7 @@ */ public class DeleteDeveloperCommandParserTest { - private DeleteDeveloperCommandParser parser = new DeleteDeveloperCommandParser(); + private final DeleteDeveloperCommandParser parser = new DeleteDeveloperCommandParser(); @Test public void parse_validArgs_returnsDeleteCommand() { @@ -28,6 +28,7 @@ public void parse_validArgs_returnsDeleteCommand() { @Test public void parse_invalidArgs_throwsParseException() { - assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteDeveloperCommand.MESSAGE_USAGE)); + assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT, + DeleteDeveloperCommand.MESSAGE_USAGE)); } } diff --git a/src/test/java/seedu/address/logic/parser/EditDeveloperCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditDeveloperCommandParserTest.java index 3d392ff026f..45ed5f2a8ef 100644 --- a/src/test/java/seedu/address/logic/parser/EditDeveloperCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditDeveloperCommandParserTest.java @@ -1,7 +1,32 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.commands.CommandTestUtil.*; +import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATEJOINED_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_GITHUBID_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_PROJECT_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_RATING_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_ROLE_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_SALARY_DESC; +import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.PROJECT_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.PROJECT_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_1_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_2_AMY; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -25,8 +50,6 @@ import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Phone; -import seedu.address.model.project.Project; -import seedu.address.model.developer.DeveloperRoles; import seedu.address.testutil.EditDeveloperDescriptorBuilder; public class EditDeveloperCommandParserTest { @@ -36,7 +59,7 @@ public class EditDeveloperCommandParserTest { private static final String MESSAGE_INVALID_FORMAT = String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditDeveloperCommand.MESSAGE_USAGE); - private EditDeveloperCommandParser parser = new EditDeveloperCommandParser(); + private final EditDeveloperCommandParser parser = new EditDeveloperCommandParser(); @Test public void parse_missingParts_failure() { @@ -70,13 +93,18 @@ public void parse_invalidValue_failure() { assertParseFailure(parser, "1" + INVALID_NAME_DESC, Name.MESSAGE_CONSTRAINTS); // invalid name assertParseFailure(parser, "1" + INVALID_PHONE_DESC, Phone.MESSAGE_CONSTRAINTS); // invalid phone assertParseFailure(parser, "1" + INVALID_EMAIL_DESC, Email.MESSAGE_CONSTRAINTS); // invalid email - assertParseFailure(parser, "1" + INVALID_ADDRESS_DESC, Address.MESSAGE_CONSTRAINTS); // invalid address - assertParseFailure(parser, "1" + INVALID_ROLE_DESC, "DeveloperRoles.MESSAGE_CONSTRAINTS"); // invalid role + assertParseFailure(parser, "1" + INVALID_ADDRESS_DESC, + Address.MESSAGE_CONSTRAINTS); // invalid address + assertParseFailure(parser, "1" + INVALID_ROLE_DESC, + "DeveloperRoles.MESSAGE_CONSTRAINTS"); // invalid role assertParseFailure(parser, "1" + INVALID_SALARY_DESC, Salary.MESSAGE_CONSTRAINTS); // invalid salary - assertParseFailure(parser, "1" + INVALID_DATEJOINED_DESC, Date.MESSAGE_CONSTRAINTS); // invalid datejoined - assertParseFailure(parser, "1" + INVALID_GITHUBID_DESC, GithubId.MESSAGE_CONSTRAINTS); // invalid githubid + assertParseFailure(parser, "1" + INVALID_DATEJOINED_DESC, + Date.MESSAGE_CONSTRAINTS); // invalid datejoined + assertParseFailure(parser, "1" + INVALID_GITHUBID_DESC, + GithubId.MESSAGE_CONSTRAINTS); // invalid githubid assertParseFailure(parser, "1" + INVALID_RATING_DESC, Rating.MESSAGE_CONSTRAINTS); // invalid rating - assertParseFailure(parser, "1" + INVALID_PROJECT_DESC, "Project.MESSAGE_CONSTRAINTS"); // invalid project + assertParseFailure(parser, "1" + INVALID_PROJECT_DESC, + "Project.MESSAGE_CONSTRAINTS"); // invalid project // invalid phone followed by valid email assertParseFailure(parser, "1" + INVALID_PHONE_DESC + EMAIL_DESC_AMY, Phone.MESSAGE_CONSTRAINTS); @@ -88,7 +116,8 @@ public void parse_invalidValue_failure() { //assertParseFailure(parser, "1" + TAG_EMPTY + TAG_DESC_FRIEND + TAG_DESC_HUSBAND, Tag.MESSAGE_CONSTRAINTS); // multiple invalid values, but only the first invalid value is captured - assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_ADDRESS_AMY + VALID_PHONE_AMY, + assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_ADDRESS_AMY + + VALID_PHONE_AMY, Name.MESSAGE_CONSTRAINTS); } @@ -98,7 +127,8 @@ public void parse_allFieldsSpecified_success() { String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + PROJECT_DESC_BOB + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY; - EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder().withName(VALID_NAME_AMY) + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder() + .withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) .withProjects(VALID_PROJECT_1_AMY, VALID_PROJECT_2_AMY).build(); EditDeveloperCommand expectedCommand = new EditDeveloperCommand(targetIndex, descriptor); @@ -111,7 +141,8 @@ public void parse_someFieldsSpecified_success() { Index targetIndex = INDEX_FIRST_PERSON; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + EMAIL_DESC_AMY; - EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder().withPhone(VALID_PHONE_BOB) + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder() + .withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_AMY).build(); EditDeveloperCommand expectedCommand = new EditDeveloperCommand(targetIndex, descriptor); @@ -123,7 +154,8 @@ public void parse_oneFieldSpecified_success() { // name Index targetIndex = INDEX_THIRD_PERSON; String userInput = targetIndex.getOneBased() + NAME_DESC_AMY; - EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder().withName(VALID_NAME_AMY).build(); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder() + .withName(VALID_NAME_AMY).build(); EditDeveloperCommand expectedCommand = new EditDeveloperCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); @@ -190,7 +222,8 @@ public void parse_resetTags_success() { Index targetIndex = INDEX_THIRD_PERSON; String userInput = targetIndex.getOneBased() + TAG_EMPTY; - EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder().withProjects().build(); + EditDeveloperCommand.EditDeveloperDescriptor descriptor = new EditDeveloperDescriptorBuilder() + .withProjects().build(); EditDeveloperCommand expectedCommand = new EditDeveloperCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); diff --git a/src/test/java/seedu/address/logic/parser/FindDeveloperCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindDeveloperCommandParserTest.java index 8fb9b56bf34..531de31cb48 100644 --- a/src/test/java/seedu/address/logic/parser/FindDeveloperCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FindDeveloperCommandParserTest.java @@ -14,11 +14,12 @@ public class FindDeveloperCommandParserTest { - private FindDeveloperCommandParser parser = new FindDeveloperCommandParser(); + private final FindDeveloperCommandParser parser = new FindDeveloperCommandParser(); @Test public void parse_emptyArg_throwsParseException() { - assertParseFailure(parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindDeveloperCommand.MESSAGE_USAGE)); + assertParseFailure(parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT, + FindDeveloperCommand.MESSAGE_USAGE)); } @Test diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index c3299a496f0..9c5564e7496 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -5,11 +5,6 @@ import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; @@ -31,7 +26,6 @@ public class ParserUtilTest { private static final String INVALID_PROJECT = " "; - private static final String VALID_NAME = "Rachel Walker"; private static final String VALID_PHONE = "123456"; private static final String VALID_ADDRESS = "123 Main Street #0505"; @@ -68,7 +62,7 @@ public void parseIndex_validInput_success() throws Exception { @Test public void parseName_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseName((String) null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseName(null)); } @Test @@ -91,7 +85,7 @@ public void parseName_validValueWithWhitespace_returnsTrimmedName() throws Excep @Test public void parsePhone_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parsePhone((String) null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parsePhone(null)); } @Test @@ -114,7 +108,7 @@ public void parsePhone_validValueWithWhitespace_returnsTrimmedPhone() throws Exc @Test public void parseAddress_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseAddress((String) null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseAddress(null)); } @Test @@ -137,7 +131,7 @@ public void parseAddress_validValueWithWhitespace_returnsTrimmedAddress() throws @Test public void parseEmail_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail((String) null)); + assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail(null)); } @Test diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index 40fa48ab6fb..56d827e2c98 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -1,6 +1,8 @@ package seedu.address.model; -import static org.junit.jupiter.api.Assertions.*; +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.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_2_AMY; import static seedu.address.testutil.Assert.assertThrows; @@ -109,12 +111,12 @@ public ObservableList getDeveloperList() { } @Override - public ObservableList getClientList () { + public ObservableList getClientList() { return clients; } @Override - public ObservableList getProjectList () { + public ObservableList getProjectList() { return projects; } } diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index b08130a450e..b36d3f7f8b2 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_DEVELOPERS; import static seedu.address.testutil.Assert.assertThrows; @@ -102,24 +103,24 @@ public void equals() { // same values -> returns true modelManager = new ModelManager(addressBook, userPrefs); ModelManager modelManagerCopy = new ModelManager(addressBook, userPrefs); - assertTrue(modelManager.equals(modelManagerCopy)); + assertEquals(modelManager, modelManagerCopy); // same object -> returns true - assertTrue(modelManager.equals(modelManager)); + assertEquals(modelManager, modelManager); // null -> returns false - assertFalse(modelManager.equals(null)); + assertNotEquals(null, modelManager); // different types -> returns false - assertFalse(modelManager.equals(5)); + assertNotEquals(5, modelManager); // different addressBook -> returns false - assertFalse(modelManager.equals(new ModelManager(differentAddressBook, userPrefs))); + assertNotEquals(modelManager, new ModelManager(differentAddressBook, userPrefs)); // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); modelManager.updateFilteredDeveloperList(new NameDeveloperContainsKeywordsPredicate(Arrays.asList(keywords))); - assertFalse(modelManager.equals(new ModelManager(addressBook, userPrefs))); + assertNotEquals(modelManager, new ModelManager(addressBook, userPrefs)); // resets modelManager to initial state for upcoming tests modelManager.updateFilteredDeveloperList(PREDICATE_SHOW_ALL_DEVELOPERS); @@ -127,6 +128,6 @@ public void equals() { // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); differentUserPrefs.setAddressBookFilePath(Paths.get("differentFilePath")); - assertFalse(modelManager.equals(new ModelManager(addressBook, differentUserPrefs))); + assertNotEquals(modelManager, new ModelManager(addressBook, differentUserPrefs)); } } diff --git a/src/test/java/seedu/address/model/person/DeveloperTest.java b/src/test/java/seedu/address/model/person/DeveloperTest.java index e5276b8a7c3..e1de4058381 100644 --- a/src/test/java/seedu/address/model/person/DeveloperTest.java +++ b/src/test/java/seedu/address/model/person/DeveloperTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; @@ -56,40 +57,41 @@ public void isSamePerson() { public void equals() { // same values -> returns true Developer aliceCopy = new DeveloperBuilder(ALICE).build(); - assertTrue(ALICE.equals(aliceCopy)); + assertEquals(ALICE, aliceCopy); // same object -> returns true - assertTrue(ALICE.equals(ALICE)); + assertEquals(ALICE, ALICE); // null -> returns false - assertFalse(ALICE.equals(null)); + assertNotEquals(null, ALICE); // different type -> returns false - assertFalse(ALICE.equals(5)); + assertNotEquals(5, ALICE); // different developer -> returns false - assertFalse(ALICE.equals(BOB)); + assertNotEquals(ALICE, BOB); // different name -> returns false Developer editedAlice = new DeveloperBuilder(ALICE).withName(VALID_NAME_BOB).build(); - assertFalse(ALICE.equals(editedAlice)); + assertNotEquals(ALICE, editedAlice); // different phone -> returns false editedAlice = new DeveloperBuilder(ALICE).withPhone(VALID_PHONE_BOB).build(); - assertFalse(ALICE.equals(editedAlice)); + assertNotEquals(ALICE, editedAlice); // different email -> returns false editedAlice = new DeveloperBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build(); - assertFalse(ALICE.equals(editedAlice)); + assertNotEquals(ALICE, editedAlice); // different address -> returns false editedAlice = new DeveloperBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build(); - assertFalse(ALICE.equals(editedAlice)); + assertNotEquals(ALICE, editedAlice); } @Test public void toStringMethod() { - String expected = Developer.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone() + String expected = Developer.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + + ALICE.getPhone() + ", email=" + ALICE.getEmail() + ", address=" + ALICE.getAddress() + "}"; assertEquals(expected, ALICE.toString()); } diff --git a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java index c7cb5722239..d16c459a236 100644 --- a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java +++ b/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; @@ -20,30 +21,35 @@ public void equals() { List firstPredicateKeywordList = Collections.singletonList("first"); List secondPredicateKeywordList = Arrays.asList("first", "second"); - NameDeveloperContainsKeywordsPredicate firstPredicate = new NameDeveloperContainsKeywordsPredicate(firstPredicateKeywordList); - NameDeveloperContainsKeywordsPredicate secondPredicate = new NameDeveloperContainsKeywordsPredicate(secondPredicateKeywordList); + NameDeveloperContainsKeywordsPredicate firstPredicate = + new NameDeveloperContainsKeywordsPredicate(firstPredicateKeywordList); + NameDeveloperContainsKeywordsPredicate secondPredicate = + new NameDeveloperContainsKeywordsPredicate(secondPredicateKeywordList); // same object -> returns true - assertTrue(firstPredicate.equals(firstPredicate)); + assertEquals(firstPredicate, firstPredicate); // same values -> returns true - NameDeveloperContainsKeywordsPredicate firstPredicateCopy = new NameDeveloperContainsKeywordsPredicate(firstPredicateKeywordList); - assertTrue(firstPredicate.equals(firstPredicateCopy)); + NameDeveloperContainsKeywordsPredicate firstPredicateCopy = + new NameDeveloperContainsKeywordsPredicate(firstPredicateKeywordList); + assertEquals(firstPredicate, firstPredicateCopy); // different types -> returns false - assertFalse(firstPredicate.equals(1)); + assertNotEquals(1, firstPredicate); // null -> returns false - assertFalse(firstPredicate.equals(null)); + assertNotEquals(null, firstPredicate); // different developer -> returns false - assertFalse(firstPredicate.equals(secondPredicate)); + assertNotEquals(firstPredicate, secondPredicate); } + @Test public void test_nameContainsKeywords_returnsTrue() { // One keyword - NameDeveloperContainsKeywordsPredicate predicate = new NameDeveloperContainsKeywordsPredicate(Collections.singletonList("Alice")); + NameDeveloperContainsKeywordsPredicate predicate = + new NameDeveloperContainsKeywordsPredicate(Collections.singletonList("Alice")); assertTrue(predicate.test(new DeveloperBuilder().withName("Alice Bob").build())); // Multiple keywords @@ -62,15 +68,18 @@ public void test_nameContainsKeywords_returnsTrue() { @Test public void test_nameDoesNotContainKeywords_returnsFalse() { // Zero keywords - NameDeveloperContainsKeywordsPredicate predicate = new NameDeveloperContainsKeywordsPredicate(Collections.emptyList()); + NameDeveloperContainsKeywordsPredicate predicate = + new NameDeveloperContainsKeywordsPredicate(Collections.emptyList()); assertFalse(predicate.test(new DeveloperBuilder().withName("Alice").build())); // Non-matching keyword - predicate = new NameDeveloperContainsKeywordsPredicate(Arrays.asList("Carol")); + predicate = new NameDeveloperContainsKeywordsPredicate(List.of("Carol")); assertFalse(predicate.test(new DeveloperBuilder().withName("Alice Bob").build())); // Keywords match phone, email and address, but does not match name - predicate = new NameDeveloperContainsKeywordsPredicate(Arrays.asList("12345", "alice@email.com", "Main", "Street")); + predicate = + new NameDeveloperContainsKeywordsPredicate(Arrays.asList("12345", + "alice@email.com", "Main", "Street")); assertFalse(predicate.test(new DeveloperBuilder().withName("Alice").withPhone("12345") .withEmail("alice@email.com").withAddress("Main Street").build())); } @@ -80,7 +89,8 @@ public void toStringMethod() { List keywords = List.of("keyword1", "keyword2"); NameDeveloperContainsKeywordsPredicate predicate = new NameDeveloperContainsKeywordsPredicate(keywords); - String expected = NameDeveloperContainsKeywordsPredicate.class.getCanonicalName() + "{keywords=" + keywords + "}"; + String expected = + NameDeveloperContainsKeywordsPredicate.class.getCanonicalName() + "{keywords=" + keywords + "}"; assertEquals(expected, predicate.toString()); } } diff --git a/src/test/java/seedu/address/model/person/UniqueDeveloperListTest.java b/src/test/java/seedu/address/model/person/UniqueDeveloperListTest.java index e1908a4e7c3..fcdeba6b148 100644 --- a/src/test/java/seedu/address/model/person/UniqueDeveloperListTest.java +++ b/src/test/java/seedu/address/model/person/UniqueDeveloperListTest.java @@ -1,7 +1,11 @@ package seedu.address.model.person; -import static org.junit.jupiter.api.Assertions.*; -import static seedu.address.logic.commands.CommandTestUtil.*; +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.VALID_ADDRESS_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_1_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_2_AMY; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalDevelopers.ALICE; import static seedu.address.testutil.TypicalDevelopers.BOB; @@ -159,8 +163,8 @@ public void setDevelopers_list_replacesOwnListWithProvidedList() { @Test public void setDevelopers_listWithDuplicateDevelopers_throwsDuplicateDeveloperException() { List listWithDuplicateDevelopers = Arrays.asList(ALICE, ALICE); - assertThrows(DuplicateDeveloperException.class, - () -> uniqueDeveloperList.setDevelopers(listWithDuplicateDevelopers)); + assertThrows(DuplicateDeveloperException.class, () + -> uniqueDeveloperList.setDevelopers(listWithDuplicateDevelopers)); } @Test diff --git a/src/test/java/seedu/address/storage/JsonAdaptedDeveloperTest.java b/src/test/java/seedu/address/storage/JsonAdaptedDeveloperTest.java index 391baab6d9f..61cc855cf78 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedDeveloperTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedDeveloperTest.java @@ -162,7 +162,7 @@ public void toModelType_invalidRating_throwsIllegalValueException() { public void toModelType_nullRating_throwsIllegalValueException() { JsonAdaptedDeveloper person = new JsonAdaptedDeveloper( VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_DATE_JOINED, - VALID_ROLE, VALID_SALARY, VALID_PROJECTS, VALID_GITHUBID, null); + VALID_ROLE, VALID_SALARY, VALID_PROJECTS, VALID_GITHUBID, null); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Rating.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } diff --git a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java b/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java index 1c73929dd48..c25e7e9cfe3 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java +++ b/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java @@ -12,7 +12,6 @@ import seedu.address.commons.util.JsonUtil; import seedu.address.model.AddressBook; import seedu.address.testutil.TypicalDevelopers; -import seedu.address.testutil.TypicalDevelopers; public class JsonSerializableAddressBookTest { diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index 8f82b115887..1c764187722 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -10,7 +10,7 @@ */ public class AddressBookBuilder { - private AddressBook addressBook; + private final AddressBook addressBook; public AddressBookBuilder() { addressBook = new AddressBook(); diff --git a/src/test/java/seedu/address/testutil/DeveloperBuilder.java b/src/test/java/seedu/address/testutil/DeveloperBuilder.java index 44335e17f15..489f4a72b7d 100644 --- a/src/test/java/seedu/address/testutil/DeveloperBuilder.java +++ b/src/test/java/seedu/address/testutil/DeveloperBuilder.java @@ -40,7 +40,9 @@ public class DeveloperBuilder { private GithubId githubId; private Rating rating; - + /** + * Creates a {@code DeveloperBuilder} with the default details. + */ public DeveloperBuilder() { name = new Name(DEFAULT_NAME); phone = new Phone(DEFAULT_PHONE); @@ -54,6 +56,10 @@ public DeveloperBuilder() { rating = new Rating(DEFAULT_RATING); } + /** + * Initializes the DeveloperBuilder with the data of {@code developerToCopy}. + * @param developerToCopy + */ public DeveloperBuilder(Developer developerToCopy) { name = developerToCopy.getName(); phone = developerToCopy.getPhone(); @@ -67,56 +73,67 @@ public DeveloperBuilder(Developer developerToCopy) { rating = developerToCopy.getRating(); } + /** Sets the {@code Name} of the {@code Developer} that we are building. */ public DeveloperBuilder withName(String name) { this.name = new Name(name); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withProjects(String... projects) { this.projects = SampleDataUtil.getProjectSet(projects); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withGithubId(String githubId) { this.githubId = new GithubId(githubId); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withRating(String rating) { this.rating = new Rating(rating); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withAddress(String address) { this.address = new Address(address); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withPhone(String phone) { this.phone = new Phone(phone); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withEmail(String email) { this.email = new Email(email); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withDateJoined(String dateJoined) { this.dateJoined = new Date(dateJoined); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withRole(String role) { this.role = new DeveloperRoles(role); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public DeveloperBuilder withSalary(String salary) { this.salary = new Salary(salary); return this; } + /** Sets the {@code Phone} of the {@code Developer} that we are building. */ public Developer build() { return new Developer(name, phone, email, address, role, projects, salary, dateJoined, githubId, rating); } diff --git a/src/test/java/seedu/address/testutil/DeveloperUtil.java b/src/test/java/seedu/address/testutil/DeveloperUtil.java index ed6d44d31e3..595b0e29df8 100644 --- a/src/test/java/seedu/address/testutil/DeveloperUtil.java +++ b/src/test/java/seedu/address/testutil/DeveloperUtil.java @@ -3,19 +3,19 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_DATEJOINED; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GITHUBID; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT; import static seedu.address.logic.parser.CliSyntax.PREFIX_RATING; +import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_SALARY; import java.util.Set; import seedu.address.logic.commands.add.AddDeveloperCommand; import seedu.address.logic.commands.edit.EditDeveloperCommand; import seedu.address.model.developer.Developer; -import seedu.address.model.project.Project; - -import static seedu.address.logic.parser.CliSyntax.*; /** * A utility class for Developer. @@ -62,12 +62,12 @@ public static String getEditDeveloperDescriptorDetails(EditDeveloperCommand.Edit descriptor.getEmail().ifPresent(email -> sb.append(PREFIX_EMAIL).append(email.value).append(" ")); descriptor.getAddress().ifPresent(address -> sb.append(PREFIX_ADDRESS).append(address.value).append(" ")); descriptor.getRole().ifPresent(role -> sb.append(PREFIX_ROLE).append(role.role).append(" ")); - descriptor.getSalary().ifPresent(salary -> sb.append(PREFIX_SALARY).append(salary.toString()).append(" ")); + descriptor.getSalary().ifPresent(salary -> sb.append(PREFIX_SALARY).append(salary).append(" ")); descriptor.getDateJoined().ifPresent(dateJoined -> sb.append(PREFIX_DATEJOINED) - .append(dateJoined.toString()).append(" ")); + .append(dateJoined).append(" ")); descriptor.getGithubId().ifPresent(githubId -> sb.append(PREFIX_GITHUBID) .append(githubId.username).append(" ")); - descriptor.getRating().ifPresent(rating -> sb.append(PREFIX_RATING).append(rating.toString()).append(" ")); + descriptor.getRating().ifPresent(rating -> sb.append(PREFIX_RATING).append(rating).append(" ")); if (descriptor.getProjects().isPresent()) { Set projects = descriptor.getProjects().get(); diff --git a/src/test/java/seedu/address/testutil/EditDeveloperDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditDeveloperDescriptorBuilder.java index 505fe628566..cb8115de52c 100644 --- a/src/test/java/seedu/address/testutil/EditDeveloperDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditDeveloperDescriptorBuilder.java @@ -7,12 +7,12 @@ import seedu.address.logic.commands.edit.EditDeveloperCommand; import seedu.address.model.commons.Date; import seedu.address.model.commons.Name; +import seedu.address.model.developer.Developer; import seedu.address.model.developer.DeveloperRoles; import seedu.address.model.developer.GithubId; import seedu.address.model.developer.Rating; import seedu.address.model.developer.Salary; import seedu.address.model.person.Address; -import seedu.address.model.developer.Developer; import seedu.address.model.person.Email; import seedu.address.model.person.Phone; @@ -21,7 +21,7 @@ */ public class EditDeveloperDescriptorBuilder { - private EditDeveloperCommand.EditDeveloperDescriptor descriptor; + private final EditDeveloperCommand.EditDeveloperDescriptor descriptor; public EditDeveloperDescriptorBuilder() { descriptor = new EditDeveloperCommand.EditDeveloperDescriptor(); @@ -80,10 +80,7 @@ public EditDeveloperDescriptorBuilder withAddress(String address) { return this; } - /** - * Parses the {@code tags} into a {@code Set} and set it to the {@code EditPersonDescriptor} - * that we are building. - */ + /* public EditDeveloperDescriptorBuilder withTags(String... tags) { Set tagSet = Stream.of(tags).map(Tag::new).collect(Collectors.toSet()); @@ -91,44 +88,70 @@ public EditDeveloperDescriptorBuilder withTags(String... tags) { return this; } */ - + /** + * Sets the {@code Projects} of the {@code EditPersonDescriptor} that we are building. + */ public EditDeveloperDescriptorBuilder withProjects(String... projects) { Set projectNames = Stream.of(projects).collect(Collectors.toSet()); descriptor.setProjects(projectNames); return this; } + /** + * Sets the {@code GithubId} of the {@code EditPersonDescriptor} that we are building. + */ public EditDeveloperDescriptorBuilder withGithubId(String githubId) { descriptor.setGithubId(new GithubId(githubId)); return this; } + /** + * Sets the {@code Rating} of the {@code EditPersonDescriptor} that we are building. + */ public EditDeveloperDescriptorBuilder withRating(String rating) { descriptor.setRating(new Rating(rating)); return this; } + /** + * Sets the {@code Date} of the {@code EditPersonDescriptor} that we are building. + * @param dateJoined + * @return + */ public EditDeveloperDescriptorBuilder withDateJoined(String dateJoined) { descriptor.setDateJoined(new Date(dateJoined)); return this; } + /** + * Sets the {@code Role} of the {@code EditPersonDescriptor} that we are building. + * @param role + * @return + */ public EditDeveloperDescriptorBuilder withRole(String role) { descriptor.setRole(new DeveloperRoles(role)); return this; } + /** + * Sets the {@code Salary} of the {@code EditPersonDescriptor} that we are building. + * @param salary + * @return + */ public EditDeveloperDescriptorBuilder withSalary(String salary) { descriptor.setSalary(new Salary(salary)); return this; } + /** + * Sets the {@code Rating} of the {@code EditPersonDescriptor} that we are building. + */ public EditDeveloperCommand.EditDeveloperDescriptor build() { - /* public EditDeveloperDescriptorBuilder withTags(String... tags) { - Set projects = Stream.of(tags).map(Tag::new).collect(Collectors.toSet()); - descriptor.setProjects(tagSet); - return this; - }*/ + /* public EditDeveloperDescriptorBuilder withTags(String... tags) { + Set projects = Stream.of(tags).map(Tag::new).collect(Collectors.toSet()); + descriptor.setProjects(tagSet); + return this; + }*/ return descriptor; } } diff --git a/src/test/java/seedu/address/testutil/TypicalDevelopers.java b/src/test/java/seedu/address/testutil/TypicalDevelopers.java index 88c460a425b..f15b475eeaa 100644 --- a/src/test/java/seedu/address/testutil/TypicalDevelopers.java +++ b/src/test/java/seedu/address/testutil/TypicalDevelopers.java @@ -1,13 +1,23 @@ package seedu.address.testutil; -import seedu.address.model.AddressBook; -import seedu.address.model.developer.Developer; +import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_1_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_2_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_2_BOB; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static seedu.address.logic.commands.CommandTestUtil.*; +import seedu.address.model.AddressBook; +import seedu.address.model.developer.Developer; /** * A utility class containing a list of {@code Developer} objects to be used in tests. @@ -59,7 +69,7 @@ public class TypicalDevelopers { public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER - private TypicalDevelopers () { + private TypicalDevelopers() { } // prevents instantiation /** diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index ed0c63b6072..20e105a8c6a 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -8,8 +8,9 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_1_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_1_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PROJECT_2_BOB; import java.util.ArrayList; import java.util.Arrays; @@ -121,11 +122,11 @@ public class TypicalPersons { // Manually added - Developer's details found in {@code CommandTestUtil} public static final Developer AMY = new DeveloperBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withProjects(VALID_TAG_FRIEND).build(); + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withProjects(VALID_PROJECT_1_AMY).build(); public static final Developer BOB = new DeveloperBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withProjects(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withProjects(VALID_PROJECT_1_BOB, + VALID_PROJECT_2_BOB) .build(); - public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER private TypicalPersons() {