diff --git a/LICENSE b/LICENSE index 39b3478982c3..a427d75de00b 100644 --- a/LICENSE +++ b/LICENSE @@ -2,11 +2,11 @@ MIT License Copyright (c) 2016 Software Engineering Education - FOSS Resources -Permission is hereby granted, free of charge, to any person obtaining a copy +Permission is hereby granted, free of charge, to any employee obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is +copies of the Software, and to permit employees to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index a25fda43c07f..3ebbc04ceb48 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -185,7 +185,7 @@ link:{repoURL}/src/main/java/seedu/address/logic/Logic.java[`Logic.java`] . `Logic` uses the `AddressBookParser` class to parse the user command. . This results in a `Command` object which is executed by the `LogicManager`. -. The command execution can affect the `Model` (e.g. adding a person) and/or raise events. +. The command execution can affect the `Model` (e.g. adding a employee) and/or raise events. . The result of the command execution is encapsulated as a `CommandResult` object which is passed back to the `Ui`. Given below is the Sequence Diagram for interactions within the `Logic` component for the `execute("delete 1")` API call. @@ -284,18 +284,18 @@ public class DeleteCommand extends UndoableCommand { Suppose that the user has just launched the application. The `UndoRedoStack` will be empty at the beginning. -The user executes a new `UndoableCommand`, `delete 5`, to delete the 5th person in the address book. The current state of the address book is saved before the `delete 5` command executes. The `delete 5` command will then be pushed onto the `undoStack` (the current state is saved together with the command). +The user executes a new `UndoableCommand`, `delete 5`, to delete the 5th employee in the address book. The current state of the address book is saved before the `delete 5` command executes. The `delete 5` command will then be pushed onto the `undoStack` (the current state is saved together with the command). image::UndoRedoStartingStackDiagram.png[width="800"] -As the user continues to use the program, more commands are added into the `undoStack`. For example, the user may execute `add n/David ...` to add a new person. +As the user continues to use the program, more commands are added into the `undoStack`. For example, the user may execute `add n/David ...` to add a new employee. image::UndoRedoNewCommand1StackDiagram.png[width="800"] [NOTE] If a command fails its execution, it will not be pushed to the `UndoRedoStack` at all. -The user now decides that adding the person was a mistake, and decides to undo that action using `undo`. +The user now decides that adding the employee was a mistake, and decides to undo that action using `undo`. We will pop the most recent command out of the `undoStack` and push it back to the `redoStack`. We will restore the address book to the state before the `add` command executed. @@ -342,7 +342,7 @@ image::UndoRedoActivityDiagram.png[width="650"] ** Pros: Easy to implement. ** Cons: May have performance issues in terms of memory usage. * **Alternative 2:** Individual command knows how to undo/redo by itself. -** Pros: Will use less memory (e.g. for `delete`, just save the person being deleted). +** Pros: Will use less memory (e.g. for `delete`, just save the employee being deleted). ** Cons: We must ensure that the implementation of each individual command are correct. @@ -529,7 +529,7 @@ Each individual exercise in this section is component-based (i.e. you would not [TIP] Do take a look at <> before attempting to modify the `Logic` component. -. Add a shorthand equivalent alias for each of the individual commands. For example, besides typing `clear`, the user can also type `c` to remove all persons in the list. +. Add a shorthand equivalent alias for each of the individual commands. For example, besides typing `clear`, the user can also type `c` to remove all employees in the list. + **** * Hints @@ -556,9 +556,9 @@ Do take a look at <> before attempting to modify the `Model` compo * Hints ** The link:{repoURL}/src/main/java/seedu/address/model/Model.java[`Model`] and the link:{repoURL}/src/main/java/seedu/address/model/AddressBook.java[`AddressBook`] API need to be updated. ** Think about how you can use SLAP to design the method. Where should we place the main logic of deleting tags? -** Find out which of the existing API methods in link:{repoURL}/src/main/java/seedu/address/model/AddressBook.java[`AddressBook`] and link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`] classes can be used to implement the tag removal logic. link:{repoURL}/src/main/java/seedu/address/model/AddressBook.java[`AddressBook`] allows you to update a person, and link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`] allows you to update the tags. +** Find out which of the existing API methods in link:{repoURL}/src/main/java/seedu/address/model/AddressBook.java[`AddressBook`] and link:{repoURL}/src/main/java/seedu/address/model/employee/Person.java[`Person`] classes can be used to implement the tag removal logic. link:{repoURL}/src/main/java/seedu/address/model/AddressBook.java[`AddressBook`] allows you to update a employee, and link:{repoURL}/src/main/java/seedu/address/model/employee/Person.java[`Person`] allows you to update the tags. * Solution -** Implement a `removeTag(Tag)` method in link:{repoURL}/src/main/java/seedu/address/model/AddressBook.java[`AddressBook`]. Loop through each person, and remove the `tag` from each person. +** Implement a `removeTag(Tag)` method in link:{repoURL}/src/main/java/seedu/address/model/AddressBook.java[`AddressBook`]. Loop through each employee, and remove the `tag` from each employee. ** Add a new API method `deleteTag(Tag)` in link:{repoURL}/src/main/java/seedu/address/model/ModelManager.java[`ModelManager`]. Your link:{repoURL}/src/main/java/seedu/address/model/ModelManager.java[`ModelManager`] should call `AddressBook#removeTag(Tag)`. ** Add new tests for each of the new public methods that you have added. ** See this https://github.com/se-edu/addressbook-level4/pull/790[PR] for the full solution. @@ -569,12 +569,12 @@ Do take a look at <> before attempting to modify the `Model` compo [discrete] ==== `Ui` component -*Scenario:* You are in charge of `ui`. During a beta testing session, your team is observing how the users use your address book application. You realize that one of the users occasionally tries to delete non-existent tags from a contact, because the tags all look the same visually, and the user got confused. Another user made a typing mistake in his command, but did not realize he had done so because the error message wasn't prominent enough. A third user keeps scrolling down the list, because he keeps forgetting the index of the last person in the list. Your job is to implement improvements to the UI to solve all these problems. +*Scenario:* You are in charge of `ui`. During a beta testing session, your team is observing how the users use your address book application. You realize that one of the users occasionally tries to delete non-existent tags from a contact, because the tags all look the same visually, and the user got confused. Another user made a typing mistake in his command, but did not realize he had done so because the error message wasn't prominent enough. A third user keeps scrolling down the list, because he keeps forgetting the index of the last employee in the list. Your job is to implement improvements to the UI to solve all these problems. [TIP] Do take a look at <> before attempting to modify the `UI` component. -. Use different colors for different tags inside person cards. For example, `friends` tags can be all in brown, and `colleagues` tags can be all in yellow. +. Use different colors for different tags inside employee cards. For example, `friends` tags can be all in brown, and `colleagues` tags can be all in yellow. + **Before** + @@ -634,10 +634,10 @@ image::getting-started-ui-status-after.png[width="500"] ** link:{repoURL}/src/main/resources/view/StatusBarFooter.fxml[`StatusBarFooter.fxml`] will need a new `StatusBar`. Be sure to set the `GridPane.columnIndex` properly for each `StatusBar` to avoid misalignment! ** link:{repoURL}/src/main/java/seedu/address/ui/StatusBarFooter.java[`StatusBarFooter`] needs to initialize the status bar on application start, and to update it accordingly whenever the address book is updated. * Solution -** Modify the constructor of link:{repoURL}/src/main/java/seedu/address/ui/StatusBarFooter.java[`StatusBarFooter`] to take in the number of persons when the application just started. -** Use link:{repoURL}/src/main/java/seedu/address/ui/StatusBarFooter.java[`StatusBarFooter#handleAddressBookChangedEvent(AddressBookChangedEvent)`] to update the number of persons whenever there are new changes to the addressbook. +** Modify the constructor of link:{repoURL}/src/main/java/seedu/address/ui/StatusBarFooter.java[`StatusBarFooter`] to take in the number of employees when the application just started. +** Use link:{repoURL}/src/main/java/seedu/address/ui/StatusBarFooter.java[`StatusBarFooter#handleAddressBookChangedEvent(AddressBookChangedEvent)`] to update the number of employees whenever there are new changes to the addressbook. ** For tests, modify link:{repoURL}/src/test/java/guitests/guihandles/StatusBarFooterHandle.java[`StatusBarFooterHandle`] by adding a state-saving functionality for the total number of people status, just like what we did for save location and sync status. -** For system tests, modify link:{repoURL}/src/test/java/systemtests/AddressBookSystemTest.java[`AddressBookSystemTest`] to also verify the new total number of persons status bar. +** For system tests, modify link:{repoURL}/src/test/java/systemtests/AddressBookSystemTest.java[`AddressBookSystemTest`] to also verify the new total number of employees status bar. ** See this https://github.com/se-edu/addressbook-level4/pull/803[PR] for the full solution. **** @@ -667,15 +667,15 @@ By creating this command, you will get a chance to learn how to implement a feat *Scenario:* You are a software maintainer for `addressbook`, as the former developer team has moved on to new projects. The current users of your application have a list of new feature requests that they hope the software will eventually have. The most popular request is to allow adding additional comments/notes about a particular contact, by providing a flexible `remark` field for each contact, rather than relying on tags alone. After designing the specification for the `remark` command, you are convinced that this feature is worth implementing. Your job is to implement the `remark` command. ==== Description -Edits the remark for a person specified in the `INDEX`. + +Edits the remark for a employee specified in the `INDEX`. + Format: `remark INDEX r/[REMARK]` Examples: * `remark 1 r/Likes to drink coffee.` + -Edits the remark for the first person to `Likes to drink coffee.` +Edits the remark for the first employee to `Likes to drink coffee.` * `remark 1 r/` + -Removes the remark for the first person. +Removes the remark for the first employee. ==== Step-by-step Instructions @@ -709,7 +709,7 @@ for `RemarkCommandParser`. . Modify link:{repoURL}/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java[`AddressBookParserTest`] to test that the correct command is generated according to the user input. ===== [Step 3] Ui: Add a placeholder for remark in `PersonCard` -Let's add a placeholder on all our link:{repoURL}/src/main/java/seedu/address/ui/PersonCard.java[`PersonCard`] s to display a remark for each person later. +Let's add a placeholder on all our link:{repoURL}/src/main/java/seedu/address/ui/PersonCard.java[`PersonCard`] s to display a remark for each employee later. **Main:** @@ -721,11 +721,11 @@ Let's add a placeholder on all our link:{repoURL}/src/main/java/seedu/address/ui . Modify link:{repoURL}/src/test/java/guitests/guihandles/PersonCardHandle.java[`PersonCardHandle`] so that future tests can read the contents of the remark label. ===== [Step 4] Model: Add `Remark` class -We have to properly encapsulate the remark in our link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`] class. Instead of just using a `String`, let's follow the conventional class structure that the codebase already uses by adding a `Remark` class. +We have to properly encapsulate the remark in our link:{repoURL}/src/main/java/seedu/address/model/employee/Person.java[`Person`] class. Instead of just using a `String`, let's follow the conventional class structure that the codebase already uses by adding a `Remark` class. **Main:** -. Add `Remark` to model component (you can copy from link:{repoURL}/src/main/java/seedu/address/model/person/Address.java[`Address`], remove the regex and change the names accordingly). +. Add `Remark` to model component (you can copy from link:{repoURL}/src/main/java/seedu/address/model/employee/Address.java[`Address`], remove the regex and change the names accordingly). . Modify `RemarkCommand` to now take in a `Remark` instead of a `String`. **Tests:** @@ -733,12 +733,12 @@ We have to properly encapsulate the remark in our link:{repoURL}/src/main/java/s . Add test for `Remark`, to test the `Remark#equals()` method. ===== [Step 5] Model: Modify `Person` to support a `Remark` field -Now we have the `Remark` class, we need to actually use it inside link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`]. +Now we have the `Remark` class, we need to actually use it inside link:{repoURL}/src/main/java/seedu/address/model/employee/Person.java[`Person`]. **Main:** -. Add `getRemark()` in link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`]. -. You may assume that the user will not be able to use the `add` and `edit` commands to modify the remarks field (i.e. the person will be created without a remark). +. Add `getRemark()` in link:{repoURL}/src/main/java/seedu/address/model/employee/Person.java[`Person`]. +. You may assume that the user will not be able to use the `add` and `edit` commands to modify the remarks field (i.e. the employee will be created without a remark). . Modify link:{repoURL}/src/main/java/seedu/address/model/util/SampleDataUtil.java/[`SampleDataUtil`] to add remarks for the sample data (delete your `addressBook.xml` so that the application will load the sample data when you launch it.) ===== [Step 6] Storage: Add `Remark` field to `XmlAdaptedPerson` class @@ -753,11 +753,11 @@ We now have `Remark` s for `Person` s, but they will be gone when we exit the ap . Fix `invalidAndValidPersonAddressBook.xml`, `typicalPersonsAddressBook.xml`, `validAddressBook.xml` etc., such that the XML tests will not fail due to a missing `` element. ===== [Step 6b] Test: Add withRemark() for `PersonBuilder` -Since `Person` can now have a `Remark`, we should add a helper method to link:{repoURL}/src/test/java/seedu/address/testutil/PersonBuilder.java[`PersonBuilder`], so that users are able to create remarks when building a link:{repoURL}/src/main/java/seedu/address/model/person/Person.java[`Person`]. +Since `Person` can now have a `Remark`, we should add a helper method to link:{repoURL}/src/test/java/seedu/address/testutil/PersonBuilder.java[`PersonBuilder`], so that users are able to create remarks when building a link:{repoURL}/src/main/java/seedu/address/model/employee/Person.java[`Person`]. **Tests:** -. Add a new method `withRemark()` for link:{repoURL}/src/test/java/seedu/address/testutil/PersonBuilder.java[`PersonBuilder`]. This method will create a new `Remark` for the person that it is currently building. +. Add a new method `withRemark()` for link:{repoURL}/src/test/java/seedu/address/testutil/PersonBuilder.java[`PersonBuilder`]. This method will create a new `Remark` for the employee that it is currently building. . Try and use the method on any sample `Person` in link:{repoURL}/src/test/java/seedu/address/testutil/TypicalPersons.java[`TypicalPersons`]. ===== [Step 7] Ui: Connect `Remark` field to `PersonCard` @@ -776,7 +776,7 @@ We now have everything set up... but we still can't modify the remarks. Let's fi **Main:** -. Replace the logic in `RemarkCommand#execute()` (that currently just throws an `Exception`), with the actual logic to modify the remarks of a person. +. Replace the logic in `RemarkCommand#execute()` (that currently just throws an `Exception`), with the actual logic to modify the remarks of a employee. **Tests:** @@ -1270,15 +1270,15 @@ These instructions only provide a starting point for testers to work on; testers _{ more test cases ... }_ -=== Deleting a person +=== Deleting a employee -. Deleting a person while all persons are listed +. Deleting a employee while all employees are listed -.. Prerequisites: List all persons using the `list` command. Multiple persons in the list. +.. Prerequisites: List all employees using the `list` command. Multiple employees in the list. .. Test case: `delete 1` + Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message. Timestamp in the status bar is updated. .. Test case: `delete 0` + - Expected: No person is deleted. Error details shown in the status message. Status bar remains the same. + Expected: No employee is deleted. Error details shown in the status message. Status bar remains the same. .. Other incorrect delete commands to try: `delete`, `delete x` (where x is larger than the list size) _{give more}_ + Expected: Similar to previous. diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index b044e4ebfd37..5accb5fbf2db 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -153,7 +153,7 @@ Deletes the 1st employee in the results of the `findE` command. === Changing a command word : `set` -Selects the person identified by the index number used in the last person listing. + +Selects the employee identified by the index number used in the last employee listing. + Format: `set OLD_COMMAND_WORD NEW_COMMAND_WORD` **** diff --git a/src/main/java/seedu/address/commons/core/Messages.java b/src/main/java/seedu/address/commons/core/Messages.java index da8e67a8bb1e..51a27d43be5e 100644 --- a/src/main/java/seedu/address/commons/core/Messages.java +++ b/src/main/java/seedu/address/commons/core/Messages.java @@ -7,7 +7,7 @@ public class Messages { public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command"; public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s"; - public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid"; + public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The employee index provided is invalid"; public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; public static final String MESSAGE_INVALID_THEME_INDEX = "The theme index provided is invalid"; public static final String MESSAGE_INVALID_FILE_PATH = "The file path is invalid"; diff --git a/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java b/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java index 7db9b5c48ed6..0ad1acb2ba18 100644 --- a/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java +++ b/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java @@ -14,6 +14,6 @@ public AddressBookChangedEvent(ReadOnlyAddressBook data) { @Override public String toString() { - return "number of persons " + data.getPersonList().size() + ", number of tags " + data.getTagList().size(); + return "number of persons " + data.getEmployeeList().size() + ", number of tags " + data.getTagList().size(); } } diff --git a/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java b/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java index 56c1c9d987f1..b1df56790ea6 100644 --- a/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java +++ b/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java @@ -4,7 +4,7 @@ import seedu.address.ui.PersonCard; /** - * Represents a selection change in the Person List Panel + * Represents a selection change in the Employee List Panel */ public class PersonPanelSelectionChangedEvent extends BaseEvent { diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index a1113c11b291..c2ccc644c06e 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -4,7 +4,7 @@ import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** * API of the Logic component @@ -23,7 +23,7 @@ public interface Logic { String appendCommandKeyToMessage(String message); /** Returns an unmodifiable view of the filtered list of persons */ - ObservableList getFilteredPersonList(); + ObservableList getFilteredPersonList(); /** Returns the list of input entered by the user, encapsulated in a {@code ListElementPointer} object */ ListElementPointer getHistorySnapshot(); diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 3a6be1bec0a9..63c14999a8c2 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -11,7 +11,7 @@ import seedu.address.logic.parser.AddressBookParser; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** * The main LogicManager of the app. @@ -50,7 +50,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { return model.getFilteredPersonList(); } diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index c334710c0ea3..b353805d197f 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -8,17 +8,17 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.DuplicatePersonException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; /** - * Adds a person to the address book. + * Adds a employee to the address book. */ public class AddCommand extends UndoableCommand { public static final String COMMAND_WORD = "add"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a employee to the address book. " + "Parameters: " + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " @@ -33,17 +33,17 @@ public class AddCommand extends UndoableCommand { + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; - public static final String MESSAGE_SUCCESS = "New person added: %1$s"; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; + public static final String MESSAGE_SUCCESS = "New employee added: %1$s"; + public static final String MESSAGE_DUPLICATE_PERSON = "This employee already exists in the address book"; - private final Person toAdd; + private final Employee toAdd; /** - * Creates an AddCommand to add the specified {@code Person} + * Creates an AddCommand to add the specified {@code Employee} */ - public AddCommand(Person person) { - requireNonNull(person); - toAdd = person; + public AddCommand(Employee employee) { + requireNonNull(employee); + toAdd = employee; } @Override @@ -52,7 +52,7 @@ public CommandResult executeUndoableCommand() throws CommandException { try { model.addPerson(toAdd); return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); - } catch (DuplicatePersonException e) { + } catch (DuplicateEmployeeException e) { throw new CommandException(MESSAGE_DUPLICATE_PERSON); } diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index b539d240001a..b8e853c4f2d1 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -8,26 +8,26 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; /** - * Deletes a person identified using it's last displayed index from the address book. + * Deletes a employee identified using it's last displayed index from the address book. */ public class DeleteCommand extends UndoableCommand { public static final String COMMAND_WORD = "delete"; public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Deletes the person identified by the index number used in the last person listing.\n" + + ": Deletes the employee identified by the index number used in the last employee listing.\n" + "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1"; - public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s"; + public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Employee: %1$s"; private final Index targetIndex; - private Person personToDelete; + private Employee employeeToDelete; public DeleteCommand(Index targetIndex) { this.targetIndex = targetIndex; @@ -36,25 +36,25 @@ public DeleteCommand(Index targetIndex) { @Override public CommandResult executeUndoableCommand() { - requireNonNull(personToDelete); + requireNonNull(employeeToDelete); try { - model.deletePerson(personToDelete); - } catch (PersonNotFoundException pnfe) { - throw new AssertionError("The target person cannot be missing"); + model.deletePerson(employeeToDelete); + } catch (EmployeeNotFoundException pnfe) { + throw new AssertionError("The target employee cannot be missing"); } - return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete)); + return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, employeeToDelete)); } @Override protected void preprocessUndoableCommand() throws CommandException { - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - personToDelete = lastShownList.get(targetIndex.getZeroBased()); + employeeToDelete = lastShownList.get(targetIndex.getZeroBased()); } @Override @@ -62,6 +62,6 @@ public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof DeleteCommand // instanceof handles nulls && this.targetIndex.equals(((DeleteCommand) other).targetIndex) // state check - && Objects.equals(this.personToDelete, ((DeleteCommand) other).personToDelete)); + && Objects.equals(this.employeeToDelete, ((DeleteCommand) other).employeeToDelete)); } } diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index e6c3a3e034bc..6ba0ae6db8f6 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -21,22 +21,22 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; import seedu.address.model.tag.Tag; /** - * Edits the details of an existing person in the address book. + * Edits the details of an existing employee in the address book. */ public class EditCommand extends UndoableCommand { public static final String COMMAND_WORD = "edit"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " - + "by the index number used in the last person listing. " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the employee identified " + + "by the index number used in the last employee listing. " + "Existing values will be overwritten by the input values.\n" + "Parameters: INDEX (must be a positive integer) " + "[" + PREFIX_NAME + "NAME] " @@ -48,19 +48,19 @@ public class EditCommand extends UndoableCommand { + PREFIX_PHONE + "91234567 " + PREFIX_EMAIL + "johndoe@example.com"; - public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; + public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Employee: %1$s"; public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; + public static final String MESSAGE_DUPLICATE_PERSON = "This employee already exists in the address book."; private final Index index; private final EditPersonDescriptor editPersonDescriptor; - private Person personToEdit; - private Person editedPerson; + private Employee employeeToEdit; + private Employee editedEmployee; /** - * @param index of the person in the filtered person list to edit - * @param editPersonDescriptor details to edit the person with + * @param index of the employee in the filtered employee list to edit + * @param editPersonDescriptor details to edit the employee with */ public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { requireNonNull(index); @@ -73,42 +73,42 @@ public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { @Override public CommandResult executeUndoableCommand() throws CommandException { try { - model.updatePerson(personToEdit, editedPerson); - } catch (DuplicatePersonException dpe) { + model.updatePerson(employeeToEdit, editedEmployee); + } catch (DuplicateEmployeeException dpe) { throw new CommandException(MESSAGE_DUPLICATE_PERSON); - } catch (PersonNotFoundException pnfe) { - throw new AssertionError("The target person cannot be missing"); + } catch (EmployeeNotFoundException pnfe) { + throw new AssertionError("The target employee cannot be missing"); } model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPerson)); + return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedEmployee)); } @Override protected void preprocessUndoableCommand() throws CommandException { - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (index.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - personToEdit = lastShownList.get(index.getZeroBased()); - editedPerson = createEditedPerson(personToEdit, editPersonDescriptor); + employeeToEdit = lastShownList.get(index.getZeroBased()); + editedEmployee = createEditedPerson(employeeToEdit, editPersonDescriptor); } /** - * Creates and returns a {@code Person} with the details of {@code personToEdit} + * Creates and returns a {@code Employee} with the details of {@code employeeToEdit} * edited with {@code editPersonDescriptor}. */ - private static Person createEditedPerson(Person personToEdit, EditPersonDescriptor editPersonDescriptor) { - assert personToEdit != null; + private static Employee createEditedPerson(Employee employeeToEdit, EditPersonDescriptor editPersonDescriptor) { + assert employeeToEdit != null; - Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); - Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); - Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); - Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); - Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); + Name updatedName = editPersonDescriptor.getName().orElse(employeeToEdit.getName()); + Phone updatedPhone = editPersonDescriptor.getPhone().orElse(employeeToEdit.getPhone()); + Email updatedEmail = editPersonDescriptor.getEmail().orElse(employeeToEdit.getEmail()); + Address updatedAddress = editPersonDescriptor.getAddress().orElse(employeeToEdit.getAddress()); + Set updatedTags = editPersonDescriptor.getTags().orElse(employeeToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Employee(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); } @Override @@ -127,12 +127,12 @@ public boolean equals(Object other) { EditCommand e = (EditCommand) other; return index.equals(e.index) && editPersonDescriptor.equals(e.editPersonDescriptor) - && Objects.equals(personToEdit, e.personToEdit); + && Objects.equals(employeeToEdit, e.employeeToEdit); } /** - * Stores the details to edit the person with. Each non-empty field value will replace the - * corresponding field value of the person. + * Stores the details to edit the employee with. Each non-empty field value will replace the + * corresponding field value of the employee. */ public static class EditPersonDescriptor { private Name name; diff --git a/src/main/java/seedu/address/logic/commands/SelectCommand.java b/src/main/java/seedu/address/logic/commands/SelectCommand.java index 9e3840a9dde6..4a9b4e3e68e9 100644 --- a/src/main/java/seedu/address/logic/commands/SelectCommand.java +++ b/src/main/java/seedu/address/logic/commands/SelectCommand.java @@ -7,21 +7,21 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.events.ui.JumpToListRequestEvent; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** - * Selects a person identified using it's last displayed index from the address book. + * Selects a employee identified using it's last displayed index from the address book. */ public class SelectCommand extends Command { public static final String COMMAND_WORD = "select"; public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Selects the person identified by the index number used in the last person listing.\n" + + ": Selects the employee identified by the index number used in the last employee listing.\n" + "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1"; - public static final String MESSAGE_SELECT_PERSON_SUCCESS = "Selected Person: %1$s"; + public static final String MESSAGE_SELECT_PERSON_SUCCESS = "Selected Employee: %1$s"; private final Index targetIndex; @@ -32,7 +32,7 @@ public SelectCommand(Index targetIndex) { @Override public CommandResult execute() throws CommandException { - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); diff --git a/src/main/java/seedu/address/logic/commands/UndoableCommand.java b/src/main/java/seedu/address/logic/commands/UndoableCommand.java index 4765ed0eece0..fb96635bd2eb 100644 --- a/src/main/java/seedu/address/logic/commands/UndoableCommand.java +++ b/src/main/java/seedu/address/logic/commands/UndoableCommand.java @@ -34,7 +34,7 @@ protected void preprocessUndoableCommand() throws CommandException {} /** * Reverts the AddressBook to the state before this command - * was executed and updates the filtered person list to + * was executed and updates the filtered employee list to * show all persons. */ protected final void undo() { @@ -44,7 +44,7 @@ protected final void undo() { } /** - * Executes the command and updates the filtered person + * Executes the command and updates the filtered employee * list to show all persons. */ protected final void redo() { diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3c729b388554..ce204cf898e9 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -15,8 +15,8 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; @@ -46,9 +46,9 @@ public AddCommand parse(String args) throws ParseException { Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).get(); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, tagList); + Employee employee = new Employee(name, phone, email, address, tagList); - return new AddCommand(person); + return new AddCommand(employee); } catch (IllegalValueException ive) { throw new ParseException(ive.getMessage(), ive); } diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 4058e1d4ee26..c2928f5a4318 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -12,10 +12,10 @@ import java.util.stream.Collectors; import javafx.collections.ObservableList; -import seedu.address.model.person.Person; -import seedu.address.model.person.UniquePersonList; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.UniqueEmployeeList; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; import seedu.address.model.tag.Tag; import seedu.address.model.tag.UniqueTagList; @@ -25,7 +25,7 @@ */ public class AddressBook implements ReadOnlyAddressBook { - private final UniquePersonList persons; + private final UniqueEmployeeList employees; private final UniqueTagList tags; /* @@ -36,7 +36,7 @@ public class AddressBook implements ReadOnlyAddressBook { * among constructors. */ { - persons = new UniquePersonList(); + employees = new UniqueEmployeeList(); tags = new UniqueTagList(); } @@ -52,8 +52,8 @@ public AddressBook(ReadOnlyAddressBook toBeCopied) { //// list overwrite operations - public void setPersons(List persons) throws DuplicatePersonException { - this.persons.setPersons(persons); + public void setEmployees(List employees) throws DuplicateEmployeeException { + this.employees.setEmployees(employees); } public void setTags(Set tags) { @@ -66,85 +66,85 @@ public void setTags(Set tags) { public void resetData(ReadOnlyAddressBook newData) { requireNonNull(newData); setTags(new HashSet<>(newData.getTagList())); - List syncedPersonList = newData.getPersonList().stream() + List syncedEmployeeList = newData.getEmployeeList().stream() .map(this::syncWithMasterTagList) .collect(Collectors.toList()); try { - setPersons(syncedPersonList); - } catch (DuplicatePersonException e) { - throw new AssertionError("AddressBooks should not have duplicate persons"); + setEmployees(syncedEmployeeList); + } catch (DuplicateEmployeeException e) { + throw new AssertionError("AddressBooks should not have duplicate employees"); } } - //// person-level operations + //// employee-level operations /** - * Adds a person to the address book. - * Also checks the new person's tags and updates {@link #tags} with any new tags found, - * and updates the Tag objects in the person to point to those in {@link #tags}. + * Adds a employee to the address book. + * Also checks the new employee's tags and updates {@link #tags} with any new tags found, + * and updates the Tag objects in the employee to point to those in {@link #tags}. * - * @throws DuplicatePersonException if an equivalent person already exists. + * @throws DuplicateEmployeeException if an equivalent employee already exists. */ - public void addPerson(Person p) throws DuplicatePersonException { - Person person = syncWithMasterTagList(p); + public void addEmployee(Employee p) throws DuplicateEmployeeException { + Employee employee = syncWithMasterTagList(p); // TODO: the tags master list will be updated even though the below line fails. - // This can cause the tags master list to have additional tags that are not tagged to any person - // in the person list. - persons.add(person); + // This can cause the tags master list to have additional tags that are not tagged to any employee + // in the employee list. + employees.add(employee); } /** * Replaces the given person {@code target} in the list with {@code editedPerson}. * {@code AddressBook}'s tag list will be updated with the tags of {@code editedPerson}. * - * @throws DuplicatePersonException if updating the person's details causes the person to be equivalent to + * @throws DuplicateEmployeeException if updating the employee's details causes the employee to be equivalent to * another existing person in the list. - * @throws PersonNotFoundException if {@code target} could not be found in the list. + * @throws EmployeeNotFoundException if {@code target} could not be found in the list. * - * @see #syncWithMasterTagList(Person) + * @see #syncWithMasterTagList(Employee) */ - public void updatePerson(Person target, Person editedPerson) - throws DuplicatePersonException, PersonNotFoundException { - requireNonNull(editedPerson); + public void updateEmployee(Employee target, Employee editedEmployee) + throws DuplicateEmployeeException, EmployeeNotFoundException { + requireNonNull(editedEmployee); - Person syncedEditedPerson = syncWithMasterTagList(editedPerson); + Employee syncedEditedEmployee = syncWithMasterTagList(editedEmployee); // TODO: the tags master list will be updated even though the below line fails. - // This can cause the tags master list to have additional tags that are not tagged to any person - // in the person list. - persons.setPerson(target, syncedEditedPerson); + // This can cause the tags master list to have additional tags that are not tagged to any employee + // in the employee list. + employees.setEmployee(target, syncedEditedEmployee); } /** - * Updates the master tag list to include tags in {@code person} that are not in the list. - * @return a copy of this {@code person} such that every tag in this person points to a Tag object in the master - * list. + * Updates the master tag list to include tags in {@code employee} that are not in the list. + * @return a copy of this {@code employee} such that every tag in this employee points + * to a Tag object in the master list. */ - private Person syncWithMasterTagList(Person person) { - final UniqueTagList personTags = new UniqueTagList(person.getTags()); - tags.mergeFrom(personTags); + private Employee syncWithMasterTagList(Employee employee) { + final UniqueTagList employeeTags = new UniqueTagList(employee.getTags()); + tags.mergeFrom(employeeTags); // Create map with values = tag object references in the master list - // used for checking person tag references + // used for checking employee tag references final Map masterTagObjects = new HashMap<>(); tags.forEach(tag -> masterTagObjects.put(tag, tag)); - // Rebuild the list of person tags to point to the relevant tags in the master tag list. + // Rebuild the list of employee tags to point to the relevant tags in the master tag list. final Set correctTagReferences = new HashSet<>(); - personTags.forEach(tag -> correctTagReferences.add(masterTagObjects.get(tag))); - return new Person( - person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), correctTagReferences); + employeeTags.forEach(tag -> correctTagReferences.add(masterTagObjects.get(tag))); + return new Employee(employee.getName(), employee.getPhone(), employee.getEmail(), + employee.getAddress(), correctTagReferences); } /** * Removes {@code key} from this {@code AddressBook}. - * @throws PersonNotFoundException if the {@code key} is not in this {@code AddressBook}. + * @throws EmployeeNotFoundException if the {@code key} is not in this {@code AddressBook}. */ - public boolean removePerson(Person key) throws PersonNotFoundException { - if (persons.remove(key)) { + public boolean removeEmployee(Employee key) throws EmployeeNotFoundException { + if (employees.remove(key)) { return true; } else { - throw new PersonNotFoundException(); + throw new EmployeeNotFoundException(); } } @@ -155,29 +155,29 @@ public void addTag(Tag t) throws UniqueTagList.DuplicateTagException { } /** - * Sort all persons' name in list alphabetically. + * Sort all employees' name in list alphabetically. */ - public UniquePersonList sortList() { - persons.sortName(new Comparator() { + public UniqueEmployeeList sortList() { + employees.sortName(new Comparator() { @Override - public int compare(Person person1, Person person2) { - return person1.getName().toString().compareToIgnoreCase(person2.getName().toString()); + public int compare(Employee employee1, Employee employee2) { + return employee1.getName().toString().compareToIgnoreCase(employee2.getName().toString()); } }); - return persons; + return employees; } //// util methods @Override public String toString() { - return persons.asObservableList().size() + " persons, " + tags.asObservableList().size() + " tags"; + return employees.asObservableList().size() + " employees, " + tags.asObservableList().size() + " tags"; // TODO: refine later } @Override - public ObservableList getPersonList() { - return persons.asObservableList(); + public ObservableList getEmployeeList() { + return employees.asObservableList(); } @Override @@ -189,13 +189,13 @@ public ObservableList getTagList() { public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof AddressBook // instanceof handles nulls - && this.persons.equals(((AddressBook) other).persons) + && this.employees.equals(((AddressBook) other).employees) && this.tags.equalsOrderInsensitive(((AddressBook) other).tags)); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(persons, tags); + return Objects.hash(employees, tags); } } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 1bea605d59db..4be9ee16beb2 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -4,16 +4,16 @@ import javafx.collections.ObservableList; import seedu.address.logic.commands.CommandWords; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; /** * The API of the Model component. */ public interface Model { /** {@code Predicate} that always evaluate to true */ - Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; + Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; /** Clears existing backing model and replaces with the provided new data. */ void resetData(ReadOnlyAddressBook newData, CommandWords newCommandWords); @@ -28,31 +28,31 @@ public interface Model { /** Returns the AddressBook */ ReadOnlyAddressBook getAddressBook(); - /** Deletes the given person. */ - void deletePerson(Person target) throws PersonNotFoundException; + /** Deletes the given employee. */ + void deletePerson(Employee target) throws EmployeeNotFoundException; - /** Adds the given person */ - void addPerson(Person person) throws DuplicatePersonException; + /** Adds the given employee */ + void addPerson(Employee employee) throws DuplicateEmployeeException; /** Sort all persons' name in list alphabetically. */ void sortPersonList(); /** - * Replaces the given person {@code target} with {@code editedPerson}. + * Replaces the given employee {@code target} with {@code editedEmployee}. * - * @throws DuplicatePersonException if updating the person's details causes the person to be equivalent to - * another existing person in the list. - * @throws PersonNotFoundException if {@code target} could not be found in the list. + * @throws DuplicateEmployeeException if updating the employee's details causes the employee to be equivalent to + * another existing employee in the list. + * @throws EmployeeNotFoundException if {@code target} could not be found in the list. */ - void updatePerson(Person target, Person editedPerson) - throws DuplicatePersonException, PersonNotFoundException; + void updatePerson(Employee target, Employee editedEmployee) + throws DuplicateEmployeeException, EmployeeNotFoundException; - /** Returns an unmodifiable view of the filtered person list */ - ObservableList getFilteredPersonList(); + /** Returns an unmodifiable view of the filtered employee list */ + ObservableList getFilteredPersonList(); /** - * Updates the filter of the filtered person list to filter by the given {@code predicate}. + * Updates the filter of the filtered employee list to filter by the given {@code predicate}. * @throws NullPointerException if {@code predicate} is null. */ - void updateFilteredPersonList(Predicate predicate); + void updateFilteredPersonList(Predicate predicate); } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index b5ae5dfcc509..51c256b90197 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -13,9 +13,9 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.model.AddressBookChangedEvent; import seedu.address.logic.commands.CommandWords; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; /** * Represents the in-memory model of the address book data. @@ -25,7 +25,7 @@ public class ModelManager extends ComponentManager implements Model { private static final Logger logger = LogsCenter.getLogger(ModelManager.class); private final AddressBook addressBook; - private final FilteredList filteredPersons; + private final FilteredList filteredEmployees; private final CommandWords commandWords; /** @@ -38,7 +38,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, UserPrefs userPrefs) { logger.fine("Initializing with address book: " + addressBook + " and user prefs " + userPrefs); this.addressBook = new AddressBook(addressBook); - filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); + filteredEmployees = new FilteredList<>(this.addressBook.getEmployeeList()); this.commandWords = userPrefs.getCommandWords(); } @@ -77,24 +77,24 @@ private void indicateAddressBookChanged() { } @Override - public synchronized void deletePerson(Person target) throws PersonNotFoundException { - addressBook.removePerson(target); + public synchronized void deletePerson(Employee target) throws EmployeeNotFoundException { + addressBook.removeEmployee(target); indicateAddressBookChanged(); } @Override - public synchronized void addPerson(Person person) throws DuplicatePersonException { - addressBook.addPerson(person); + public synchronized void addPerson(Employee employee) throws DuplicateEmployeeException { + addressBook.addEmployee(employee); updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); indicateAddressBookChanged(); } @Override - public void updatePerson(Person target, Person editedPerson) - throws DuplicatePersonException, PersonNotFoundException { - requireAllNonNull(target, editedPerson); + public void updatePerson(Employee target, Employee editedEmployee) + throws DuplicateEmployeeException, EmployeeNotFoundException { + requireAllNonNull(target, editedEmployee); - addressBook.updatePerson(target, editedPerson); + addressBook.updateEmployee(target, editedEmployee); indicateAddressBookChanged(); } @@ -104,21 +104,21 @@ public void sortPersonList() { indicateAddressBookChanged(); } - //=========== Filtered Person List Accessors ============================================================= + //=========== Filtered Employee List Accessors ============================================================= /** - * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of + * Returns an unmodifiable view of the list of {@code Employee} backed by the internal list of * {@code addressBook} */ @Override - public ObservableList getFilteredPersonList() { - return FXCollections.unmodifiableObservableList(filteredPersons); + public ObservableList getFilteredPersonList() { + return FXCollections.unmodifiableObservableList(filteredEmployees); } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredPersonList(Predicate predicate) { requireNonNull(predicate); - filteredPersons.setPredicate(predicate); + filteredEmployees.setPredicate(predicate); } @Override @@ -136,7 +136,7 @@ public boolean equals(Object obj) { // state check ModelManager other = (ModelManager) obj; return addressBook.equals(other.addressBook) - && filteredPersons.equals(other.filteredPersons) + && filteredEmployees.equals(other.filteredEmployees) && commandWords.equals(other.getCommandWords()); } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index 1f4e49a37d67..48de775b5b9e 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -1,7 +1,7 @@ package seedu.address.model; import javafx.collections.ObservableList; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; import seedu.address.model.tag.Tag; /** @@ -13,7 +13,7 @@ public interface ReadOnlyAddressBook { * Returns an unmodifiable view of the persons list. * This list will not contain any duplicate persons. */ - ObservableList getPersonList(); + ObservableList getEmployeeList(); /** * Returns an unmodifiable view of the tags list. diff --git a/src/main/java/seedu/address/model/job/Date.java b/src/main/java/seedu/address/model/job/Date.java new file mode 100644 index 000000000000..811928e0ba56 --- /dev/null +++ b/src/main/java/seedu/address/model/job/Date.java @@ -0,0 +1,43 @@ +package seedu.address.model.job; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +/** + * Represent the date of job creation in the servicing manager + */ +public class Date { + private static final String DATE_FORMATTER_PATTERN = "MMM d yyy"; + + public final String date; + + public Date() { + date = generateDate(); + } + + /** + * Generates the string representation of the current date on the system + */ + private String generateDate() { + LocalDate localDate = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMATTER_PATTERN); + return localDate.format(formatter); + } + + @Override + public String toString() { + return date; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Date // instanceof handles nulls + && this.date.equals(((Date) other).date)); // state check + } + + @Override + public int hashCode() { + return date.hashCode(); + } +} diff --git a/src/main/java/seedu/address/model/job/Job.java b/src/main/java/seedu/address/model/job/Job.java index a23d95b8af11..3b409d6dee93 100644 --- a/src/main/java/seedu/address/model/job/Job.java +++ b/src/main/java/seedu/address/model/job/Job.java @@ -2,9 +2,15 @@ import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; +import java.util.Collections; import java.util.Objects; +import java.util.Set; +import seedu.address.model.person.Employee; import seedu.address.model.person.Person; +import seedu.address.model.person.UniqueEmployeeList; +import seedu.address.model.remark.Remark; +import seedu.address.model.remark.RemarkList; //@author owzhenwei /** @@ -14,12 +20,23 @@ public class Job { private final Person customer; private final VehicleNumber vehicleNumber; private final JobNumber jobNumber; + private final Date date; + private final Status status; - public Job(Person customer, VehicleNumber vehicleNumber, JobNumber jobNumber) { - requireAllNonNull(customer, vehicleNumber); + private final UniqueEmployeeList assignedEmployees; + private final RemarkList remarks; + + public Job(Person customer, VehicleNumber vehicleNumber, JobNumber jobNumber, + Date date, UniqueEmployeeList assignedEmployees, Status status, RemarkList remarks) { + + requireAllNonNull(customer, vehicleNumber, jobNumber, date, assignedEmployees, status); this.customer = customer; this.vehicleNumber = vehicleNumber; this.jobNumber = jobNumber; + this.date = date; + this.assignedEmployees = assignedEmployees; + this.status = status; + this.remarks = remarks; } public JobNumber getJobNumber() { @@ -34,6 +51,32 @@ public Person getCustomer() { return customer; } + public Date getDate() { + return date; + } + + public Status getStatus() { + return status; + } + + /** + * Returns an immutable tag set, which throws {@code UnsupportedOperationException} + * if modification is attempted. + */ + public Set getAssignedEmployees() { + return Collections.unmodifiableSet(assignedEmployees.toSet()); + } + + + /** + * Returns an immutable tag set, which throws {@code UnsupportedOperationException} + * if modification is attempted. + */ + public Set getRemarks() { + //Stub + return null; + } + @Override public boolean equals(Object other) { if (other == this) { @@ -47,13 +90,17 @@ public boolean equals(Object other) { Job otherJob = (Job) other; return otherJob.getCustomer().equals(this.getCustomer()) && otherJob.getVehicleNumber().equals(this.getVehicleNumber()) - && otherJob.getJobNumber() == this.getJobNumber(); - + && otherJob.getJobNumber().equals(this.getJobNumber()) + && otherJob.getDate().equals(this.getDate()) + && otherJob.getAssignedEmployees().equals(this.getAssignedEmployees()) + && otherJob.getStatus().equals(this.getStatus()) + && otherJob.getRemarks().equals(this.getRemarks()); } @Override public int hashCode() { - return Objects.hash(customer, vehicleNumber, jobNumber); + return Objects.hash(customer, vehicleNumber, jobNumber, date, + assignedEmployees, status, remarks); } @Override @@ -61,12 +108,18 @@ public String toString() { final StringBuilder builder = new StringBuilder(); builder.append("Job Number: ") .append(getJobNumber()) + .append(" Status: ") + .append(getStatus()) + .append(" Start Date: ") + .append(getDate()) .append(" Vehicle ID: ") .append(getVehicleNumber()) - .append(" Name: ") - .append(customer.getName()) - .append(" Email: ") - .append(customer.getEmail()); + .append(" Customer: ") + .append(getCustomer()) + .append(" Remarks: "); + getRemarks().forEach(builder::append); + builder.append(" Assigned Employees: "); + getAssignedEmployees().forEach(builder::append); return builder.toString(); } } diff --git a/src/main/java/seedu/address/model/job/JobList.java b/src/main/java/seedu/address/model/job/JobList.java index 9f9f61b56f74..24d035e02965 100644 --- a/src/main/java/seedu/address/model/job/JobList.java +++ b/src/main/java/seedu/address/model/job/JobList.java @@ -16,7 +16,7 @@ public class JobList implements Iterable { private final ObservableList internalList = FXCollections.observableArrayList(); /** - * Returns true if the list contains an equivalent person as the given argument + * Returns true if the list contains an equivalent employee as the given argument */ public boolean contains(Job toCheck) { requireNonNull(toCheck); diff --git a/src/main/java/seedu/address/model/job/JobNumber.java b/src/main/java/seedu/address/model/job/JobNumber.java index e49b2191976d..e89df8b5920b 100644 --- a/src/main/java/seedu/address/model/job/JobNumber.java +++ b/src/main/java/seedu/address/model/job/JobNumber.java @@ -17,7 +17,7 @@ public JobNumber() { /** * Initialize the next job number of the car servicing manager */ - public static void initNextJobNumber(String args) { + public static void initialize(String args) { nextJobNumber = Integer.parseInt(args); } @@ -25,6 +25,11 @@ public static void incrementNextJobNumber() { nextJobNumber++; } + @Override + public String toString() { + return jobNumber; + } + @Override public boolean equals(Object other) { return other == this // short circuit if same object diff --git a/src/main/java/seedu/address/model/job/Status.java b/src/main/java/seedu/address/model/job/Status.java new file mode 100644 index 000000000000..2b991c1630e5 --- /dev/null +++ b/src/main/java/seedu/address/model/job/Status.java @@ -0,0 +1,32 @@ +package seedu.address.model.job; + +/** + * Represents the status of a car servicing job + */ +public class Status { + public static final String STATUS_ONGOING = "ongoing"; + public static final String STATUS_CLOSED = "closed"; + + public final String status; + + public Status(String status) { + this.status = status; + } + + @Override + public String toString() { + return status; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Status // instanceof handles nulls + && this.status.equals(((Status) other).status)); // state check + } + + @Override + public int hashCode() { + return status.hashCode(); + } +} diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index 5e981f07790a..9c228fe30ed2 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -4,13 +4,13 @@ import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's address in the address book. + * Represents a Employee's address in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} */ public class Address { public static final String MESSAGE_ADDRESS_CONSTRAINTS = - "Person addresses can take any values, and it should not be blank"; + "Employee addresses can take any values, and it should not be blank"; /* * The first character of the address must not be a whitespace, @@ -32,7 +32,7 @@ public Address(String address) { } /** - * Returns true if a given string is a valid person email. + * Returns true if a given string is a valid employee email. */ public static boolean isValidAddress(String test) { return test.matches(ADDRESS_VALIDATION_REGEX); diff --git a/src/main/java/seedu/address/model/person/Email.java b/src/main/java/seedu/address/model/person/Email.java index 9a7ba9e6e22b..de6218734fd1 100644 --- a/src/main/java/seedu/address/model/person/Email.java +++ b/src/main/java/seedu/address/model/person/Email.java @@ -4,14 +4,14 @@ import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's email in the address book. + * Represents a Employee's email in the address book. * * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} */ public class Email { private static final String SPECIAL_CHARACTERS = "!#$%&'*+/=?`{|}~^.-"; - public static final String MESSAGE_EMAIL_CONSTRAINTS = "Person emails should be of the format local-part@domain " + public static final String MESSAGE_EMAIL_CONSTRAINTS = "Employee emails should be of the format local-part@domain " + "and adhere to the following constraints:\n" + "1. The local-part should only contain alphanumeric characters and these special characters, excluding " + "the parentheses, (" + SPECIAL_CHARACTERS + ") .\n" @@ -42,7 +42,7 @@ public Email(String email) { } /** - * Returns if a given string is a valid person email. + * Returns if a given string is a valid employee email. */ public static boolean isValidEmail(String test) { return test.matches(EMAIL_VALIDATION_REGEX); diff --git a/src/main/java/seedu/address/model/person/Employee.java b/src/main/java/seedu/address/model/person/Employee.java new file mode 100644 index 000000000000..65cf63de0b22 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Employee.java @@ -0,0 +1,76 @@ +package seedu.address.model.person; + +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import java.util.Collections; +import java.util.Objects; +import java.util.Set; + +import seedu.address.model.tag.Tag; +import seedu.address.model.tag.UniqueTagList; + +/** + * Represents a Employee in the address book. + * + * Guarantees: details are present and not null, field values are validated, immutable. + */ +public class Employee extends Person { + private final UniqueTagList tags; + + /** + * Every field must be present and not null. + */ + public Employee(Name name, Phone phone, Email email, Address address, Set tags) { + super(name, phone, email, address); + requireAllNonNull(name, phone, email, address, tags); + // protect internal tags from changes in the arg list + this.tags = new UniqueTagList(tags); + } + + /** + * Returns an immutable tag set, which throws {@code UnsupportedOperationException} + * if modification is attempted. + */ + public Set getTags() { + return Collections.unmodifiableSet(tags.toSet()); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + if (!(other instanceof Employee)) { + return false; + } + + Employee otherEmployee = (Employee) other; + return otherEmployee.getName().equals(this.getName()) + && otherEmployee.getPhone().equals(this.getPhone()) + && otherEmployee.getEmail().equals(this.getEmail()) + && otherEmployee.getAddress().equals(this.getAddress()); + } + + @Override + public int hashCode() { + // use this method for custom fields hashing instead of implementing your own + return Objects.hash(name, phone, email, address, tags); + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append(getName()) + .append(" Phone: ") + .append(getPhone()) + .append(" Email: ") + .append(getEmail()) + .append(" Address: ") + .append(getAddress()) + .append(" Tags: "); + getTags().forEach(builder::append); + return builder.toString(); + } + +} diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/person/Name.java index 1a7743844861..3c8942357432 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/person/Name.java @@ -4,14 +4,14 @@ import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's name in the address book. + * Represents a Employee's name in the address book. * * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} */ public class Name { public static final String MESSAGE_NAME_CONSTRAINTS = - "Person names should only contain alphanumeric characters and spaces, and it should not be blank"; + "Employee names should only contain alphanumeric characters and spaces, and it should not be blank"; /* * The first character of the address must not be a whitespace, @@ -33,7 +33,7 @@ public Name(String name) { } /** - * Returns true if a given string is a valid person name. + * Returns true if a given string is a valid employee name. */ public static boolean isValidName(String test) { return test.matches(NAME_VALIDATION_REGEX); diff --git a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java index 827e2cc106bd..b361d6c6c48e 100644 --- a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java @@ -6,9 +6,9 @@ import seedu.address.commons.util.StringUtil; /** - * Tests that a {@code Person}'s {@code Name} matches any of the keywords given. + * Tests that a {@code Employee}'s {@code Name} matches any of the keywords given. */ -public class NameContainsKeywordsPredicate implements Predicate { +public class NameContainsKeywordsPredicate implements Predicate { private final List keywords; public NameContainsKeywordsPredicate(List keywords) { @@ -16,9 +16,9 @@ public NameContainsKeywordsPredicate(List keywords) { } @Override - public boolean test(Person person) { + public boolean test(Employee employee) { return keywords.stream() - .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword)); + .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(employee.getName().fullName, keyword)); } @Override diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 4954de1cf896..85872fab3150 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -2,38 +2,26 @@ import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; -import java.util.Collections; import java.util.Objects; -import java.util.Set; - -import seedu.address.model.tag.Tag; -import seedu.address.model.tag.UniqueTagList; /** - * Represents a Person in the address book. - * - * Guarantees: details are present and not null, field values are validated, immutable. + * Represents a person in the car servicing manager */ public class Person { - - private final Name name; - private final Phone phone; - private final Email email; - private final Address address; - - private final UniqueTagList tags; + protected final Name name; + protected final Phone phone; + protected final Email email; + protected final Address address; /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, Set tags) { - requireAllNonNull(name, phone, email, address, tags); + public Person(Name name, Phone phone, Email email, Address address) { + requireAllNonNull(name, phone, email, address); this.name = name; this.phone = phone; this.email = email; this.address = address; - // protect internal tags from changes in the arg list - this.tags = new UniqueTagList(tags); } public Name getName() { @@ -52,14 +40,6 @@ public Address getAddress() { return address; } - /** - * Returns an immutable tag set, which throws {@code UnsupportedOperationException} - * if modification is attempted. - */ - public Set getTags() { - return Collections.unmodifiableSet(tags.toSet()); - } - @Override public boolean equals(Object other) { if (other == this) { @@ -80,7 +60,7 @@ public boolean equals(Object other) { @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, address, tags); + return Objects.hash(name, phone, email, address); } @Override @@ -92,10 +72,7 @@ public String toString() { .append(" Email: ") .append(getEmail()) .append(" Address: ") - .append(getAddress()) - .append(" Tags: "); - getTags().forEach(builder::append); + .append(getAddress()); return builder.toString(); } - } diff --git a/src/main/java/seedu/address/model/person/Phone.java b/src/main/java/seedu/address/model/person/Phone.java index 6895d92312f3..6fee4d7a1dfd 100644 --- a/src/main/java/seedu/address/model/person/Phone.java +++ b/src/main/java/seedu/address/model/person/Phone.java @@ -4,7 +4,7 @@ import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's phone number in the address book. + * Represents a Employee's phone number in the address book. * * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} */ @@ -28,7 +28,7 @@ public Phone(String phone) { } /** - * Returns true if a given string is a valid person phone number. + * Returns true if a given string is a valid employee phone number. */ public static boolean isValidPhone(String test) { return test.matches(PHONE_VALIDATION_REGEX); diff --git a/src/main/java/seedu/address/model/person/UniqueEmployeeList.java b/src/main/java/seedu/address/model/person/UniqueEmployeeList.java new file mode 100644 index 000000000000..f7d0b12987f8 --- /dev/null +++ b/src/main/java/seedu/address/model/person/UniqueEmployeeList.java @@ -0,0 +1,140 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import seedu.address.commons.util.CollectionUtil; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; + +/** + * A list of persons that enforces uniqueness between its elements and does not allow nulls. + * + * Supports a minimal set of list operations. + * + * @see Employee#equals(Object) + * @see CollectionUtil#elementsAreUnique(Collection) + */ +public class UniqueEmployeeList implements Iterable { + + private final ObservableList internalList = FXCollections.observableArrayList(); + + /** + * Returns true if the list contains an equivalent employee as the given argument. + */ + public boolean contains(Employee toCheck) { + requireNonNull(toCheck); + return internalList.contains(toCheck); + } + + /** + * Adds a employee to the list. + * + * @throws DuplicateEmployeeException if the employee to add is a duplicate of an existing employee in the list. + */ + public void add(Employee toAdd) throws DuplicateEmployeeException { + requireNonNull(toAdd); + if (contains(toAdd)) { + throw new DuplicateEmployeeException(); + } + internalList.add(toAdd); + } + + /** + * Replaces the employee {@code target} in the list with {@code editedEmployee}. + * + * @throws DuplicateEmployeeException if the replacement is equivalent to another existing employee in the list. + * @throws EmployeeNotFoundException if {@code target} could not be found in the list. + */ + public void setEmployee(Employee target, Employee editedEmployee) + throws DuplicateEmployeeException, EmployeeNotFoundException { + requireNonNull(editedEmployee); + + int index = internalList.indexOf(target); + if (index == -1) { + throw new EmployeeNotFoundException(); + } + + if (!target.equals(editedEmployee) && internalList.contains(editedEmployee)) { + throw new DuplicateEmployeeException(); + } + + internalList.set(index, editedEmployee); + } + + /** + * Removes the equivalent employee from the list. + * + * @throws EmployeeNotFoundException if no such employee could be found in the list. + */ + public boolean remove(Employee toRemove) throws EmployeeNotFoundException { + requireNonNull(toRemove); + final boolean employeeFoundAndDeleted = internalList.remove(toRemove); + if (!employeeFoundAndDeleted) { + throw new EmployeeNotFoundException(); + } + return employeeFoundAndDeleted; + } + + public void setEmployees(UniqueEmployeeList replacement) { + this.internalList.setAll(replacement.internalList); + } + + public void setEmployees(List employees) throws DuplicateEmployeeException { + requireAllNonNull(employees); + final UniqueEmployeeList replacement = new UniqueEmployeeList(); + for (final Employee employee : employees) { + replacement.add(employee); + } + setEmployees(replacement); + } + + /** + * Returns all tags in this list as a Set. + * This set is mutable and change-insulated against the internal list. + */ + public Set toSet() { + assert CollectionUtil.elementsAreUnique(internalList); + return new HashSet<>(internalList); + } + + /** + * Returns the backing list as an unmodifiable {@code ObservableList}. + */ + public ObservableList asObservableList() { + return FXCollections.unmodifiableObservableList(internalList); + } + + /** + * Sort all persons' name in list alphabetically. + */ + public void sortName(Comparator comparator) { + Collections.sort(internalList, comparator); + } + + @Override + public Iterator iterator() { + return internalList.iterator(); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof UniqueEmployeeList // instanceof handles nulls + && this.internalList.equals(((UniqueEmployeeList) other).internalList)); + } + + @Override + public int hashCode() { + return internalList.hashCode(); + } +} diff --git a/src/main/java/seedu/address/model/person/UniquePersonList.java b/src/main/java/seedu/address/model/person/UniquePersonList.java deleted file mode 100644 index 30a2f80b1cea..000000000000 --- a/src/main/java/seedu/address/model/person/UniquePersonList.java +++ /dev/null @@ -1,129 +0,0 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; - -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import seedu.address.commons.util.CollectionUtil; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; - -/** - * A list of persons that enforces uniqueness between its elements and does not allow nulls. - * - * Supports a minimal set of list operations. - * - * @see Person#equals(Object) - * @see CollectionUtil#elementsAreUnique(Collection) - */ -public class UniquePersonList implements Iterable { - - private final ObservableList internalList = FXCollections.observableArrayList(); - - /** - * Returns true if the list contains an equivalent person as the given argument. - */ - public boolean contains(Person toCheck) { - requireNonNull(toCheck); - return internalList.contains(toCheck); - } - - /** - * Adds a person to the list. - * - * @throws DuplicatePersonException if the person to add is a duplicate of an existing person in the list. - */ - public void add(Person toAdd) throws DuplicatePersonException { - requireNonNull(toAdd); - if (contains(toAdd)) { - throw new DuplicatePersonException(); - } - internalList.add(toAdd); - } - - /** - * Replaces the person {@code target} in the list with {@code editedPerson}. - * - * @throws DuplicatePersonException if the replacement is equivalent to another existing person in the list. - * @throws PersonNotFoundException if {@code target} could not be found in the list. - */ - public void setPerson(Person target, Person editedPerson) - throws DuplicatePersonException, PersonNotFoundException { - requireNonNull(editedPerson); - - int index = internalList.indexOf(target); - if (index == -1) { - throw new PersonNotFoundException(); - } - - if (!target.equals(editedPerson) && internalList.contains(editedPerson)) { - throw new DuplicatePersonException(); - } - - internalList.set(index, editedPerson); - } - - /** - * Removes the equivalent person from the list. - * - * @throws PersonNotFoundException if no such person could be found in the list. - */ - public boolean remove(Person toRemove) throws PersonNotFoundException { - requireNonNull(toRemove); - final boolean personFoundAndDeleted = internalList.remove(toRemove); - if (!personFoundAndDeleted) { - throw new PersonNotFoundException(); - } - return personFoundAndDeleted; - } - - public void setPersons(UniquePersonList replacement) { - this.internalList.setAll(replacement.internalList); - } - - public void setPersons(List persons) throws DuplicatePersonException { - requireAllNonNull(persons); - final UniquePersonList replacement = new UniquePersonList(); - for (final Person person : persons) { - replacement.add(person); - } - setPersons(replacement); - } - - /** - * Returns the backing list as an unmodifiable {@code ObservableList}. - */ - public ObservableList asObservableList() { - return FXCollections.unmodifiableObservableList(internalList); - } - - /** - * Sort all persons' name in list alphabetically. - */ - public void sortName(Comparator comparator) { - Collections.sort(internalList, comparator); - } - - @Override - public Iterator iterator() { - return internalList.iterator(); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof UniquePersonList // instanceof handles nulls - && this.internalList.equals(((UniquePersonList) other).internalList)); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } -} diff --git a/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java b/src/main/java/seedu/address/model/person/exceptions/DuplicateEmployeeException.java similarity index 50% rename from src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java rename to src/main/java/seedu/address/model/person/exceptions/DuplicateEmployeeException.java index fce401885dc8..4e334044da10 100644 --- a/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java +++ b/src/main/java/seedu/address/model/person/exceptions/DuplicateEmployeeException.java @@ -3,10 +3,10 @@ import seedu.address.commons.exceptions.DuplicateDataException; /** - * Signals that the operation will result in duplicate Person objects. + * Signals that the operation will result in duplicate Employee objects. */ -public class DuplicatePersonException extends DuplicateDataException { - public DuplicatePersonException() { +public class DuplicateEmployeeException extends DuplicateDataException { + public DuplicateEmployeeException() { super("Operation would result in duplicate persons"); } } diff --git a/src/main/java/seedu/address/model/person/exceptions/EmployeeNotFoundException.java b/src/main/java/seedu/address/model/person/exceptions/EmployeeNotFoundException.java new file mode 100644 index 000000000000..03bbe01db49a --- /dev/null +++ b/src/main/java/seedu/address/model/person/exceptions/EmployeeNotFoundException.java @@ -0,0 +1,6 @@ +package seedu.address.model.person.exceptions; + +/** + * Signals that the operation is unable to find the specified employee. + */ +public class EmployeeNotFoundException extends Exception {} diff --git a/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java b/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java deleted file mode 100644 index f757e25f5566..000000000000 --- a/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java +++ /dev/null @@ -1,6 +0,0 @@ -package seedu.address.model.person.exceptions; - -/** - * Signals that the operation is unable to find the specified person. - */ -public class PersonNotFoundException extends Exception {} diff --git a/src/main/java/seedu/address/model/remark/Remark.java b/src/main/java/seedu/address/model/remark/Remark.java new file mode 100644 index 000000000000..ce700500333e --- /dev/null +++ b/src/main/java/seedu/address/model/remark/Remark.java @@ -0,0 +1,7 @@ +package seedu.address.model.remark; + +/** + * Represents a remark for a job in the car servicing manager + */ +public class Remark { +} diff --git a/src/main/java/seedu/address/model/remark/RemarkList.java b/src/main/java/seedu/address/model/remark/RemarkList.java new file mode 100644 index 000000000000..3f13a2ce1c51 --- /dev/null +++ b/src/main/java/seedu/address/model/remark/RemarkList.java @@ -0,0 +1,7 @@ +package seedu.address.model.remark; + +/** + * Represents a list of remarks for a particular job in the car servicing manager + */ +public class RemarkList { +} diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index aea96bfb31f3..63c10efaffac 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -7,34 +7,34 @@ import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.exceptions.DuplicatePersonException; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; import seedu.address.model.tag.Tag; /** * Contains utility methods for populating {@code AddressBook} with sample data. */ public class SampleDataUtil { - public static Person[] getSamplePersons() { - return new Person[] { - new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), + public static Employee[] getSamplePersons() { + return new Employee[] { + new Employee(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), new Address("Blk 30 Geylang Street 29, #06-40"), getTagSet("friends")), - new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), + new Employee(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), getTagSet("colleagues", "friends")), - new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), + new Employee(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), getTagSet("neighbours")), - new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), + new Employee(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), getTagSet("family")), - new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), + new Employee(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), new Address("Blk 47 Tampines Street 20, #17-35"), getTagSet("classmates")), - new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), + new Employee(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), new Address("Blk 45 Aljunied Street 85, #11-31"), getTagSet("colleagues")) }; @@ -43,11 +43,11 @@ public static Person[] getSamplePersons() { public static ReadOnlyAddressBook getSampleAddressBook() { try { AddressBook sampleAb = new AddressBook(); - for (Person samplePerson : getSamplePersons()) { - sampleAb.addPerson(samplePerson); + for (Employee sampleEmployee : getSamplePersons()) { + sampleAb.addEmployee(sampleEmployee); } return sampleAb; - } catch (DuplicatePersonException e) { + } catch (DuplicateEmployeeException e) { throw new AssertionError("sample data cannot contain duplicate persons", e); } } diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedEmployee.java similarity index 78% rename from src/main/java/seedu/address/storage/XmlAdaptedPerson.java rename to src/main/java/seedu/address/storage/XmlAdaptedEmployee.java index 2cd92dc4fd20..e5c63fbcb8cd 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedEmployee.java @@ -11,17 +11,17 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; /** - * JAXB-friendly version of the Person. + * JAXB-friendly version of the Employee. */ -public class XmlAdaptedPerson { +public class XmlAdaptedEmployee { - public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!"; + public static final String MISSING_FIELD_MESSAGE_FORMAT = "Employee's %s field is missing!"; @XmlElement(required = true) private String name; @@ -36,15 +36,15 @@ public class XmlAdaptedPerson { private List tagged = new ArrayList<>(); /** - * Constructs an XmlAdaptedPerson. + * Constructs an XmlAdaptedEmployee. * This is the no-arg constructor that is required by JAXB. */ - public XmlAdaptedPerson() {} + public XmlAdaptedEmployee() {} /** - * Constructs an {@code XmlAdaptedPerson} with the given person details. + * Constructs an {@code XmlAdaptedEmployee} with the given employee details. */ - public XmlAdaptedPerson(String name, String phone, String email, String address, List tagged) { + public XmlAdaptedEmployee(String name, String phone, String email, String address, List tagged) { this.name = name; this.phone = phone; this.email = email; @@ -55,11 +55,11 @@ public XmlAdaptedPerson(String name, String phone, String email, String address, } /** - * Converts a given Person into this class for JAXB use. + * Converts a given Employee into this class for JAXB use. * - * @param source future changes to this will not affect the created XmlAdaptedPerson + * @param source future changes to this will not affect the created XmlAdaptedEmployee */ - public XmlAdaptedPerson(Person source) { + public XmlAdaptedEmployee(Employee source) { name = source.getName().fullName; phone = source.getPhone().value; email = source.getEmail().value; @@ -71,11 +71,11 @@ public XmlAdaptedPerson(Person source) { } /** - * Converts this jaxb-friendly adapted person object into the model's Person object. + * Converts this jaxb-friendly adapted employee object into the model's Employee object. * - * @throws IllegalValueException if there were any data constraints violated in the adapted person + * @throws IllegalValueException if there were any data constraints violated in the adapted employee */ - public Person toModelType() throws IllegalValueException { + public Employee toModelType() throws IllegalValueException { final List personTags = new ArrayList<>(); for (XmlAdaptedTag tag : tagged) { personTags.add(tag.toModelType()); @@ -114,7 +114,7 @@ public Person toModelType() throws IllegalValueException { final Address address = new Address(this.address); final Set tags = new HashSet<>(personTags); - return new Person(name, phone, email, address, tags); + return new Employee(name, phone, email, address, tags); } @Override @@ -123,11 +123,11 @@ public boolean equals(Object other) { return true; } - if (!(other instanceof XmlAdaptedPerson)) { + if (!(other instanceof XmlAdaptedEmployee)) { return false; } - XmlAdaptedPerson otherPerson = (XmlAdaptedPerson) other; + XmlAdaptedEmployee otherPerson = (XmlAdaptedEmployee) other; return Objects.equals(name, otherPerson.name) && Objects.equals(phone, otherPerson.phone) && Objects.equals(email, otherPerson.email) diff --git a/src/main/java/seedu/address/storage/XmlAdaptedTag.java b/src/main/java/seedu/address/storage/XmlAdaptedTag.java index d3e2d8be9c4f..c90ef0e5637d 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedTag.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedTag.java @@ -38,7 +38,7 @@ public XmlAdaptedTag(Tag source) { /** * Converts this jaxb-friendly adapted tag object into the model's Tag object. * - * @throws IllegalValueException if there were any data constraints violated in the adapted person + * @throws IllegalValueException if there were any data constraints violated in the adapted employee */ public Tag toModelType() throws IllegalValueException { if (!Tag.isValidTagName(tagName)) { diff --git a/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java b/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java index dc820896c312..6ff719d66341 100644 --- a/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java @@ -18,7 +18,7 @@ public class XmlSerializableAddressBook { @XmlElement - private List persons; + private List employees; @XmlElement private List tags; @@ -27,7 +27,7 @@ public class XmlSerializableAddressBook { * This empty constructor is required for marshalling. */ public XmlSerializableAddressBook() { - persons = new ArrayList<>(); + employees = new ArrayList<>(); tags = new ArrayList<>(); } @@ -36,7 +36,7 @@ public XmlSerializableAddressBook() { */ public XmlSerializableAddressBook(ReadOnlyAddressBook src) { this(); - persons.addAll(src.getPersonList().stream().map(XmlAdaptedPerson::new).collect(Collectors.toList())); + employees.addAll(src.getEmployeeList().stream().map(XmlAdaptedEmployee::new).collect(Collectors.toList())); tags.addAll(src.getTagList().stream().map(XmlAdaptedTag::new).collect(Collectors.toList())); } @@ -44,15 +44,15 @@ public XmlSerializableAddressBook(ReadOnlyAddressBook src) { * Converts this addressbook into the model's {@code AddressBook} object. * * @throws IllegalValueException if there were any data constraints violated or duplicates in the - * {@code XmlAdaptedPerson} or {@code XmlAdaptedTag}. + * {@code XmlAdaptedEmployee} or {@code XmlAdaptedTag}. */ public AddressBook toModelType() throws IllegalValueException { AddressBook addressBook = new AddressBook(); for (XmlAdaptedTag t : tags) { addressBook.addTag(t.toModelType()); } - for (XmlAdaptedPerson p : persons) { - addressBook.addPerson(p.toModelType()); + for (XmlAdaptedEmployee p : employees) { + addressBook.addEmployee(p.toModelType()); } return addressBook; } @@ -68,6 +68,6 @@ public boolean equals(Object other) { } XmlSerializableAddressBook otherAb = (XmlSerializableAddressBook) other; - return persons.equals(otherAb.persons) && tags.equals(otherAb.tags); + return employees.equals(otherAb.employees) && tags.equals(otherAb.tags); } } diff --git a/src/main/java/seedu/address/ui/BrowserPanel.java b/src/main/java/seedu/address/ui/BrowserPanel.java index bb0d61380d5a..65067450563d 100644 --- a/src/main/java/seedu/address/ui/BrowserPanel.java +++ b/src/main/java/seedu/address/ui/BrowserPanel.java @@ -13,7 +13,7 @@ import seedu.address.MainApp; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** * The Browser Panel of the App. @@ -41,8 +41,8 @@ public BrowserPanel() { registerAsAnEventHandler(this); } - private void loadPersonPage(Person person) { - loadPage(SEARCH_PAGE_URL + person.getName().fullName); + private void loadPersonPage(Employee employee) { + loadPage(SEARCH_PAGE_URL + employee.getName().fullName); } public void loadPage(String url) { @@ -67,6 +67,6 @@ public void freeResources() { @Subscribe private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedEvent event) { logger.info(LogsCenter.getEventHandlingLogMessage(event)); - loadPersonPage(event.getNewSelection().person); + loadPersonPage(event.getNewSelection().employee); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index f6727ea83abd..39af57073444 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -5,10 +5,10 @@ import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** - * An UI component that displays information of a {@code Person}. + * An UI component that displays information of a {@code Employee}. */ public class PersonCard extends UiPart { @@ -22,7 +22,7 @@ public class PersonCard extends UiPart { * @see The issue on AddressBook level 4 */ - public final Person person; + public final Employee employee; @FXML private HBox cardPane; @@ -39,15 +39,15 @@ public class PersonCard extends UiPart { @FXML private FlowPane tags; - public PersonCard(Person person, int displayedIndex) { + public PersonCard(Employee employee, int displayedIndex) { super(FXML); - this.person = person; + this.employee = employee; id.setText(displayedIndex + ". "); - name.setText(person.getName().fullName); - phone.setText(person.getPhone().value); - address.setText(person.getAddress().value); - email.setText(person.getEmail().value); - person.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + name.setText(employee.getName().fullName); + phone.setText(employee.getPhone().value); + address.setText(employee.getAddress().value); + email.setText(employee.getEmail().value); + employee.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); } @Override @@ -65,6 +65,6 @@ public boolean equals(Object other) { // state check PersonCard card = (PersonCard) other; return id.getText().equals(card.id.getText()) - && person.equals(card.person); + && employee.equals(card.employee); } } diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java index 60a4f70f4e71..b5577ab3f2cc 100644 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ b/src/main/java/seedu/address/ui/PersonListPanel.java @@ -15,7 +15,7 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.ui.JumpToListRequestEvent; import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** * Panel containing the list of persons. @@ -27,15 +27,15 @@ public class PersonListPanel extends UiPart { @FXML private ListView personListView; - public PersonListPanel(ObservableList personList) { + public PersonListPanel(ObservableList employeeList) { super(FXML); - setConnections(personList); + setConnections(employeeList); registerAsAnEventHandler(this); } - private void setConnections(ObservableList personList) { + private void setConnections(ObservableList employeeList) { ObservableList mappedList = EasyBind.map( - personList, (person) -> new PersonCard(person, personList.indexOf(person) + 1)); + employeeList, (person) -> new PersonCard(person, employeeList.indexOf(person) + 1)); personListView.setItems(mappedList); personListView.setCellFactory(listView -> new PersonListViewCell()); setEventHandlerForSelectionChangeEvent(); @@ -45,7 +45,7 @@ private void setEventHandlerForSelectionChangeEvent() { personListView.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> { if (newValue != null) { - logger.fine("Selection in person list panel changed to : '" + newValue + "'"); + logger.fine("Selection in employee list panel changed to : '" + newValue + "'"); raise(new PersonPanelSelectionChangedEvent(newValue)); } }); diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index f444cfbae808..15cfd1509936 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -47,7 +47,7 @@ - + diff --git a/src/test/data/XmlAddressBookStorageTest/invalidAndValidPersonAddressBook.xml b/src/test/data/XmlAddressBookStorageTest/invalidAndValidPersonAddressBook.xml index 41e411568a5f..d06a2c32a10e 100644 --- a/src/test/data/XmlAddressBookStorageTest/invalidAndValidPersonAddressBook.xml +++ b/src/test/data/XmlAddressBookStorageTest/invalidAndValidPersonAddressBook.xml @@ -1,17 +1,17 @@ - - + + Hans Muster 9482424 hans@example.com
4th street
-
- - + + + Hans Muster 948asdf2424 hans@example.com
4th street
-
+
diff --git a/src/test/data/XmlAddressBookStorageTest/invalidPersonAddressBook.xml b/src/test/data/XmlAddressBookStorageTest/invalidPersonAddressBook.xml index cfa128e72828..ecc531793bd9 100644 --- a/src/test/data/XmlAddressBookStorageTest/invalidPersonAddressBook.xml +++ b/src/test/data/XmlAddressBookStorageTest/invalidPersonAddressBook.xml @@ -1,10 +1,10 @@ - - + + Ha!ns Mu@ster 9482424 hans@example.com
4th street
-
+
diff --git a/src/test/data/XmlSerializableAddressBookTest/invalidPersonAddressBook.xml b/src/test/data/XmlSerializableAddressBookTest/invalidPersonAddressBook.xml index 13d5b1cb1c8a..8048c56facb4 100644 --- a/src/test/data/XmlSerializableAddressBookTest/invalidPersonAddressBook.xml +++ b/src/test/data/XmlSerializableAddressBookTest/invalidPersonAddressBook.xml @@ -1,10 +1,10 @@ - - + + Hans Muster 9482424 hans@exam!32ple
4th street
-
+
diff --git a/src/test/data/XmlSerializableAddressBookTest/typicalPersonsAddressBook.xml b/src/test/data/XmlSerializableAddressBookTest/typicalPersonsAddressBook.xml index c778cccc4c89..36613a86d2a7 100644 --- a/src/test/data/XmlSerializableAddressBookTest/typicalPersonsAddressBook.xml +++ b/src/test/data/XmlSerializableAddressBookTest/typicalPersonsAddressBook.xml @@ -1,52 +1,52 @@ - - + Alice Pauline 85355255 alice@example.com
123, Jurong West Ave 6, #08-111
friends -
- + + Benson Meier 98765432 johnd@example.com
311, Clementi Ave 2, #02-25
owesMoney friends -
- + + Carl Kurz 95352563 heinz@example.com
wall street
-
- + + Daniel Meier 87652533 cornelia@example.com
10th street
-
- + + Elle Meyer 9482224 werner@example.com
michegan ave
-
- + + Fiona Kunz 9482427 lydia@example.com
little tokyo
-
- + + George Best 9482442 anna@example.com
4th street
-
+ friends owesMoney
diff --git a/src/test/data/XmlUtilTest/invalidPersonField.xml b/src/test/data/XmlUtilTest/invalidPersonField.xml index ba49c971e884..d670d7ec7aa4 100644 --- a/src/test/data/XmlUtilTest/invalidPersonField.xml +++ b/src/test/data/XmlUtilTest/invalidPersonField.xml @@ -1,9 +1,9 @@ - - + + Hans Muster 9482asf424 hans@example
4th street
friends -
+
diff --git a/src/test/data/XmlUtilTest/missingPersonField.xml b/src/test/data/XmlUtilTest/missingPersonField.xml index c0da5c86d080..d56e7d8c96d4 100644 --- a/src/test/data/XmlUtilTest/missingPersonField.xml +++ b/src/test/data/XmlUtilTest/missingPersonField.xml @@ -1,8 +1,8 @@ - - + + 9482424 hans@example
4th street
friends -
+
diff --git a/src/test/data/XmlUtilTest/tempAddressBook.xml b/src/test/data/XmlUtilTest/tempAddressBook.xml index 41eeb8eb391a..a7e11836fea9 100644 --- a/src/test/data/XmlUtilTest/tempAddressBook.xml +++ b/src/test/data/XmlUtilTest/tempAddressBook.xml @@ -1,6 +1,6 @@ - + 1 John Doe @@ -8,7 +8,7 @@ - + Friends diff --git a/src/test/data/XmlUtilTest/validAddressBook.xml b/src/test/data/XmlUtilTest/validAddressBook.xml index 6265778674d3..d6ff840ed34a 100644 --- a/src/test/data/XmlUtilTest/validAddressBook.xml +++ b/src/test/data/XmlUtilTest/validAddressBook.xml @@ -1,57 +1,57 @@ - + Hans Muster 9482424 hans@example.com
4th street
-
- + + Ruth Mueller 87249245 ruth@example.com
81th street
-
- + + Heinz Kurz 95352563 heinz@example.com
wall street
-
- + + Cornelia Meier 87652533 cornelia@example.com
10th street
-
- + + Werner Meyer 9482224 werner@example.com
michegan ave
-
- + + Lydia Kunz 9482427 lydia@example.com
little tokyo
-
- + + Anna Best 9482442 anna@example.com
4th street
-
- + + Stefan Meier 8482424 stefan@example.com
little india
-
- + + Martin Mueller 8482131 hans@example.com
chicago ave
-
+
diff --git a/src/test/data/XmlUtilTest/validPerson.xml b/src/test/data/XmlUtilTest/validPerson.xml index c029008d54f4..793c9874b568 100644 --- a/src/test/data/XmlUtilTest/validPerson.xml +++ b/src/test/data/XmlUtilTest/validPerson.xml @@ -1,8 +1,8 @@ - + Hans Muster 9482424 hans@example
4th street
friends -
+
diff --git a/src/test/java/guitests/guihandles/PersonCardHandle.java b/src/test/java/guitests/guihandles/PersonCardHandle.java index d337d3a4cee9..490bc6a004f9 100644 --- a/src/test/java/guitests/guihandles/PersonCardHandle.java +++ b/src/test/java/guitests/guihandles/PersonCardHandle.java @@ -8,7 +8,7 @@ import javafx.scene.layout.Region; /** - * Provides a handle to a person card in the person list panel. + * Provides a handle to a employee card in the employee list panel. */ public class PersonCardHandle extends NodeHandle { private static final String ID_FIELD_ID = "#id"; diff --git a/src/test/java/guitests/guihandles/PersonListPanelHandle.java b/src/test/java/guitests/guihandles/PersonListPanelHandle.java index 40564bb2d960..b9536ead199e 100644 --- a/src/test/java/guitests/guihandles/PersonListPanelHandle.java +++ b/src/test/java/guitests/guihandles/PersonListPanelHandle.java @@ -4,7 +4,7 @@ import java.util.Optional; import javafx.scene.control.ListView; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; import seedu.address.ui.PersonCard; /** @@ -28,7 +28,7 @@ public PersonCardHandle getHandleToSelectedCard() { List personList = getRootNode().getSelectionModel().getSelectedItems(); if (personList.size() != 1) { - throw new AssertionError("Person list size expected 1."); + throw new AssertionError("Employee list size expected 1."); } return new PersonCardHandle(personList.get(0).getRoot()); @@ -55,14 +55,14 @@ public boolean isAnyCardSelected() { } /** - * Navigates the listview to display and select the person. + * Navigates the listview to display and select the employee. */ - public void navigateToCard(Person person) { + public void navigateToCard(Employee employee) { List cards = getRootNode().getItems(); - Optional matchingCard = cards.stream().filter(card -> card.person.equals(person)).findFirst(); + Optional matchingCard = cards.stream().filter(card -> card.employee.equals(employee)).findFirst(); if (!matchingCard.isPresent()) { - throw new IllegalArgumentException("Person does not exist."); + throw new IllegalArgumentException("Employee does not exist."); } guiRobot.interact(() -> { @@ -73,21 +73,21 @@ public void navigateToCard(Person person) { } /** - * Returns the person card handle of a person associated with the {@code index} in the list. + * Returns the employee card handle of a employee associated with the {@code index} in the list. */ public PersonCardHandle getPersonCardHandle(int index) { - return getPersonCardHandle(getRootNode().getItems().get(index).person); + return getPersonCardHandle(getRootNode().getItems().get(index).employee); } /** - * Returns the {@code PersonCardHandle} of the specified {@code person} in the list. + * Returns the {@code PersonCardHandle} of the specified {@code employee} in the list. */ - public PersonCardHandle getPersonCardHandle(Person person) { + public PersonCardHandle getPersonCardHandle(Employee employee) { Optional handle = getRootNode().getItems().stream() - .filter(card -> card.person.equals(person)) + .filter(card -> card.employee.equals(employee)) .map(card -> new PersonCardHandle(card.getRoot())) .findFirst(); - return handle.orElseThrow(() -> new IllegalArgumentException("Person does not exist.")); + return handle.orElseThrow(() -> new IllegalArgumentException("Employee does not exist.")); } /** diff --git a/src/test/java/seedu/address/commons/util/XmlUtilTest.java b/src/test/java/seedu/address/commons/util/XmlUtilTest.java index 56b6ef8f40d3..c85380629df4 100644 --- a/src/test/java/seedu/address/commons/util/XmlUtilTest.java +++ b/src/test/java/seedu/address/commons/util/XmlUtilTest.java @@ -15,11 +15,11 @@ import org.junit.rules.ExpectedException; import seedu.address.model.AddressBook; -import seedu.address.storage.XmlAdaptedPerson; +import seedu.address.storage.XmlAdaptedEmployee; import seedu.address.storage.XmlAdaptedTag; import seedu.address.storage.XmlSerializableAddressBook; import seedu.address.testutil.AddressBookBuilder; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.EmployeeBuilder; import seedu.address.testutil.TestUtil; public class XmlUtilTest { @@ -28,9 +28,11 @@ public class XmlUtilTest { private static final File EMPTY_FILE = new File(TEST_DATA_FOLDER + "empty.xml"); private static final File MISSING_FILE = new File(TEST_DATA_FOLDER + "missing.xml"); private static final File VALID_FILE = new File(TEST_DATA_FOLDER + "validAddressBook.xml"); - private static final File MISSING_PERSON_FIELD_FILE = new File(TEST_DATA_FOLDER + "missingPersonField.xml"); - private static final File INVALID_PERSON_FIELD_FILE = new File(TEST_DATA_FOLDER + "invalidPersonField.xml"); - private static final File VALID_PERSON_FILE = new File(TEST_DATA_FOLDER + "validPerson.xml"); + private static final File MISSING_EMPLOYEE_FIELD_FILE = + new File(TEST_DATA_FOLDER + "missingPersonField.xml"); + private static final File INVALID_EMPLOYEE_FIELD_FILE = + new File(TEST_DATA_FOLDER + "invalidPersonField.xml"); + private static final File VALID_EMPLOYEE_FILE = new File(TEST_DATA_FOLDER + "validPerson.xml"); private static final File TEMP_FILE = new File(TestUtil.getFilePathInSandboxFolder("tempAddressBook.xml")); private static final String INVALID_PHONE = "9482asf424"; @@ -39,7 +41,8 @@ public class XmlUtilTest { private static final String VALID_PHONE = "9482424"; private static final String VALID_EMAIL = "hans@example"; private static final String VALID_ADDRESS = "4th street"; - private static final List VALID_TAGS = Collections.singletonList(new XmlAdaptedTag("friends")); + private static final List VALID_TAGS = + Collections.singletonList(new XmlAdaptedTag("friends")); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -71,35 +74,35 @@ public void getDataFromFile_emptyFile_dataFormatMismatchException() throws Excep @Test public void getDataFromFile_validFile_validResult() throws Exception { AddressBook dataFromFile = XmlUtil.getDataFromFile(VALID_FILE, XmlSerializableAddressBook.class).toModelType(); - assertEquals(9, dataFromFile.getPersonList().size()); + assertEquals(9, dataFromFile.getEmployeeList().size()); assertEquals(0, dataFromFile.getTagList().size()); } @Test - public void xmlAdaptedPersonFromFile_fileWithMissingPersonField_validResult() throws Exception { - XmlAdaptedPerson actualPerson = XmlUtil.getDataFromFile( - MISSING_PERSON_FIELD_FILE, XmlAdaptedPersonWithRootElement.class); - XmlAdaptedPerson expectedPerson = new XmlAdaptedPerson( + public void xmlAdaptedEmployeeFromFile_fileWithMissingEmployeeField_validResult() throws Exception { + XmlAdaptedEmployee actualEmployee = XmlUtil.getDataFromFile( + MISSING_EMPLOYEE_FIELD_FILE, XmlAdaptedEmployeeWithRootElement.class); + XmlAdaptedEmployee expectedEmployee = new XmlAdaptedEmployee( null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); - assertEquals(expectedPerson, actualPerson); + assertEquals(expectedEmployee, actualEmployee); } @Test - public void xmlAdaptedPersonFromFile_fileWithInvalidPersonField_validResult() throws Exception { - XmlAdaptedPerson actualPerson = XmlUtil.getDataFromFile( - INVALID_PERSON_FIELD_FILE, XmlAdaptedPersonWithRootElement.class); - XmlAdaptedPerson expectedPerson = new XmlAdaptedPerson( + public void xmlAdaptedEmployeeFromFile_fileWithInvalidEmployeeField_validResult() throws Exception { + XmlAdaptedEmployee actualEmployee = XmlUtil.getDataFromFile( + INVALID_EMPLOYEE_FIELD_FILE, XmlAdaptedEmployeeWithRootElement.class); + XmlAdaptedEmployee expectedEmployee = new XmlAdaptedEmployee( VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); - assertEquals(expectedPerson, actualPerson); + assertEquals(expectedEmployee, actualEmployee); } @Test - public void xmlAdaptedPersonFromFile_fileWithValidPerson_validResult() throws Exception { - XmlAdaptedPerson actualPerson = XmlUtil.getDataFromFile( - VALID_PERSON_FILE, XmlAdaptedPersonWithRootElement.class); - XmlAdaptedPerson expectedPerson = new XmlAdaptedPerson( + public void xmlAdaptedEmployeeFromFile_fileWithValidEmployee_validResult() throws Exception { + XmlAdaptedEmployee actualEmployee = XmlUtil.getDataFromFile( + VALID_EMPLOYEE_FILE, XmlAdaptedEmployeeWithRootElement.class); + XmlAdaptedEmployee expectedEmployee = new XmlAdaptedEmployee( VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); - assertEquals(expectedPerson, actualPerson); + assertEquals(expectedEmployee, actualEmployee); } @Test @@ -130,7 +133,7 @@ public void saveDataToFile_validFile_dataSaved() throws Exception { AddressBookBuilder builder = new AddressBookBuilder(new AddressBook()); dataToWrite = new XmlSerializableAddressBook( - builder.withPerson(new PersonBuilder().build()).withTag("Friends").build()); + builder.withEmployee(new EmployeeBuilder().build()).withTag("Friends").build()); XmlUtil.saveDataToFile(TEMP_FILE, dataToWrite); dataFromFile = XmlUtil.getDataFromFile(TEMP_FILE, XmlSerializableAddressBook.class); @@ -138,9 +141,10 @@ public void saveDataToFile_validFile_dataSaved() throws Exception { } /** - * Test class annotated with {@code XmlRootElement} to allow unmarshalling of .xml data to {@code XmlAdaptedPerson} + * Test class annotated with {@code XmlRootElement} to allow unmarshalling of .xml data + * to {@code XmlAdaptedEmployee} * objects. */ - @XmlRootElement(name = "person") - private static class XmlAdaptedPersonWithRootElement extends XmlAdaptedPerson {} + @XmlRootElement(name = "employee") + private static class XmlAdaptedEmployeeWithRootElement extends XmlAdaptedEmployee {} } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java index d3ff5043e126..9880b332a83d 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java @@ -12,8 +12,8 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; -import seedu.address.testutil.PersonBuilder; +import seedu.address.model.person.Employee; +import seedu.address.testutil.EmployeeBuilder; /** * Contains integration tests (interaction with the Model) for {@code AddCommand}. @@ -29,26 +29,26 @@ public void setUp() { @Test public void execute_newPerson_success() throws Exception { - Person validPerson = new PersonBuilder().build(); + Employee validEmployee = new EmployeeBuilder().build(); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.addPerson(validPerson); + expectedModel.addPerson(validEmployee); - assertCommandSuccess(prepareCommand(validPerson, model), model, - String.format(AddCommand.MESSAGE_SUCCESS, validPerson), expectedModel); + assertCommandSuccess(prepareCommand(validEmployee, model), model, + String.format(AddCommand.MESSAGE_SUCCESS, validEmployee), expectedModel); } @Test public void execute_duplicatePerson_throwsCommandException() { - Person personInList = model.getAddressBook().getPersonList().get(0); - assertCommandFailure(prepareCommand(personInList, model), model, AddCommand.MESSAGE_DUPLICATE_PERSON); + Employee employeeInList = model.getAddressBook().getEmployeeList().get(0); + assertCommandFailure(prepareCommand(employeeInList, model), model, AddCommand.MESSAGE_DUPLICATE_PERSON); } /** - * Generates a new {@code AddCommand} which upon execution, adds {@code person} into the {@code model}. + * Generates a new {@code AddCommand} which upon execution, adds {@code employee} into the {@code model}. */ - private AddCommand prepareCommand(Person person, Model model) { - AddCommand command = new AddCommand(person); + private AddCommand prepareCommand(Employee employee, Model model) { + AddCommand command = new AddCommand(employee); command.setData(model, new CommandHistory(), new UndoRedoStack()); return command; } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 19ff377bd9f9..df79eb45ae89 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -21,10 +21,10 @@ import seedu.address.model.AddressBook; import seedu.address.model.Model; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; -import seedu.address.testutil.PersonBuilder; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; +import seedu.address.testutil.EmployeeBuilder; public class AddCommandTest { @@ -45,12 +45,12 @@ public CommandWords getCommandWords() { return new CommandWords(); } }; - Person validPerson = new PersonBuilder().build(); + Employee validEmployee = new EmployeeBuilder().build(); - CommandResult commandResult = getAddCommandForPerson(validPerson, modelStub).execute(); + CommandResult commandResult = getAddCommandForPerson(validEmployee, modelStub).execute(); - assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, validPerson), commandResult.feedbackToUser); - assertEquals(Arrays.asList(validPerson), modelStub.personsAdded); + assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, validEmployee), commandResult.feedbackToUser); + assertEquals(Arrays.asList(validEmployee), modelStub.personsAdded); } @Test @@ -61,18 +61,18 @@ public CommandWords getCommandWords() { return new CommandWords(); } }; - Person validPerson = new PersonBuilder().build(); + Employee validEmployee = new EmployeeBuilder().build(); thrown.expect(CommandException.class); thrown.expectMessage(AddCommand.MESSAGE_DUPLICATE_PERSON); - getAddCommandForPerson(validPerson, modelStub).execute(); + getAddCommandForPerson(validEmployee, modelStub).execute(); } @Test public void equals() { - Person alice = new PersonBuilder().withName("Alice").build(); - Person bob = new PersonBuilder().withName("Bob").build(); + Employee alice = new EmployeeBuilder().withName("Alice").build(); + Employee bob = new EmployeeBuilder().withName("Bob").build(); AddCommand addAliceCommand = new AddCommand(alice); AddCommand addBobCommand = new AddCommand(bob); @@ -89,15 +89,15 @@ public void equals() { // null -> returns false assertFalse(addAliceCommand.equals(null)); - // different person -> returns false + // different employee -> returns false assertFalse(addAliceCommand.equals(addBobCommand)); } /** - * Generates a new AddCommand with the details of the given person. + * Generates a new AddCommand with the details of the given employee. */ - private AddCommand getAddCommandForPerson(Person person, Model model) { - AddCommand command = new AddCommand(person); + private AddCommand getAddCommandForPerson(Employee employee, Model model) { + AddCommand command = new AddCommand(employee); command.setData(model, new CommandHistory(), new UndoRedoStack()); return command; } @@ -107,7 +107,7 @@ private AddCommand getAddCommandForPerson(Person person, Model model) { */ private class ModelStub implements Model { @Override - public void addPerson(Person person) throws DuplicatePersonException { + public void addPerson(Employee employee) throws DuplicateEmployeeException { fail("This method should not be called."); } @@ -134,7 +134,7 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public void deletePerson(Person target) throws PersonNotFoundException { + public void deletePerson(Employee target) throws EmployeeNotFoundException { fail("This method should not be called."); } @@ -144,30 +144,30 @@ public void sortPersonList() { } @Override - public void updatePerson(Person target, Person editedPerson) - throws DuplicatePersonException { + public void updatePerson(Employee target, Employee editedEmployee) + throws DuplicateEmployeeException { fail("This method should not be called."); } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { fail("This method should not be called."); return null; } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredPersonList(Predicate predicate) { fail("This method should not be called."); } } /** - * A Model stub that always throw a DuplicatePersonException when trying to add a person. + * A Model stub that always throw a DuplicateEmployeeException when trying to add a employee. */ private class ModelStubThrowingDuplicatePersonException extends ModelStub { @Override - public void addPerson(Person person) throws DuplicatePersonException { - throw new DuplicatePersonException(); + public void addPerson(Employee employee) throws DuplicateEmployeeException { + throw new DuplicateEmployeeException(); } @Override @@ -177,15 +177,15 @@ public ReadOnlyAddressBook getAddressBook() { } /** - * A Model stub that always accept the person being added. + * A Model stub that always accept the employee being added. */ private class ModelStubAcceptingPersonAdded extends ModelStub { - final ArrayList personsAdded = new ArrayList<>(); + final ArrayList personsAdded = new ArrayList<>(); @Override - public void addPerson(Person person) throws DuplicatePersonException { - requireNonNull(person); - personsAdded.add(person); + public void addPerson(Employee employee) throws DuplicateEmployeeException { + requireNonNull(employee); + personsAdded.add(employee); } @Override diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 7329cd26f2ef..39fa402d0d2b 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -19,9 +19,9 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; +import seedu.address.model.person.Employee; import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; import seedu.address.testutil.EditPersonDescriptorBuilder; /** @@ -92,13 +92,13 @@ public static void assertCommandSuccess(Command command, Model actualModel, Stri * Executes the given {@code command}, confirms that
* - a {@code CommandException} is thrown
* - the CommandException message matches {@code expectedMessage}
- * - the address book and the filtered person list in the {@code actualModel} remain unchanged + * - the address book and the filtered employee list in the {@code actualModel} remain unchanged */ public static void assertCommandFailure(Command command, Model actualModel, String expectedMessage) { // we are unable to defensively copy the model for comparison later, so we can // only do so by copying its components. AddressBook expectedAddressBook = new AddressBook(actualModel.getAddressBook()); - List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); + List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); try { command.execute(); @@ -111,28 +111,28 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri } /** - * Updates {@code model}'s filtered list to show only the person at the given {@code targetIndex} in the + * Updates {@code model}'s filtered list to show only the employee at the given {@code targetIndex} in the * {@code model}'s address book. */ public static void showPersonAtIndex(Model model, Index targetIndex) { assertTrue(targetIndex.getZeroBased() < model.getFilteredPersonList().size()); - Person person = model.getFilteredPersonList().get(targetIndex.getZeroBased()); - final String[] splitName = person.getName().fullName.split("\\s+"); + Employee employee = model.getFilteredPersonList().get(targetIndex.getZeroBased()); + final String[] splitName = employee.getName().fullName.split("\\s+"); model.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); assertEquals(1, model.getFilteredPersonList().size()); } /** - * Deletes the first person in {@code model}'s filtered list from {@code model}'s address book. + * Deletes the first employee in {@code model}'s filtered list from {@code model}'s address book. */ public static void deleteFirstPerson(Model model) { - Person firstPerson = model.getFilteredPersonList().get(0); + Employee firstEmployee = model.getFilteredPersonList().get(0); try { - model.deletePerson(firstPerson); - } catch (PersonNotFoundException pnfe) { - throw new AssertionError("Person in filtered list must exist in model.", pnfe); + model.deletePerson(firstEmployee); + } catch (EmployeeNotFoundException pnfe) { + throw new AssertionError("Employee in filtered list must exist in model.", pnfe); } } diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 4aab9aff5d18..ffe87f3749c0 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -21,7 +21,7 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** * Contains integration tests (interaction with the Model, UndoCommand and RedoCommand) and unit tests for @@ -33,13 +33,13 @@ public class DeleteCommandTest { @Test public void execute_validIndexUnfilteredList_success() throws Exception { - Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Employee employeeToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = prepareCommand(INDEX_FIRST_PERSON); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, personToDelete); + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, employeeToDelete); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(personToDelete); + expectedModel.deletePerson(employeeToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @@ -56,13 +56,13 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() throws E public void execute_validIndexFilteredList_success() throws Exception { showPersonAtIndex(model, INDEX_FIRST_PERSON); - Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Employee employeeToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = prepareCommand(INDEX_FIRST_PERSON); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, personToDelete); + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, employeeToDelete); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(personToDelete); + expectedModel.deletePerson(employeeToDelete); showNoPerson(expectedModel); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); @@ -74,7 +74,7 @@ public void execute_invalidIndexFilteredList_throwsCommandException() { 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().getEmployeeList().size()); DeleteCommand deleteCommand = prepareCommand(outOfBoundIndex); @@ -86,19 +86,19 @@ public void executeUndoRedo_validIndexUnfilteredList_success() throws Exception UndoRedoStack undoRedoStack = new UndoRedoStack(); UndoCommand undoCommand = prepareUndoCommand(model, undoRedoStack); RedoCommand redoCommand = prepareRedoCommand(model, undoRedoStack); - Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Employee employeeToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = prepareCommand(INDEX_FIRST_PERSON); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - // delete -> first person deleted + // delete -> first employee deleted deleteCommand.execute(); undoRedoStack.push(deleteCommand); - // undo -> reverts addressbook back to previous state and filtered person list to show all persons + // undo -> reverts addressbook back to previous state and filtered employee list to show all persons assertCommandSuccess(undoCommand, model, UndoCommand.MESSAGE_SUCCESS, expectedModel); - // redo -> same first person deleted again - expectedModel.deletePerson(personToDelete); + // redo -> same first employee deleted again + expectedModel.deletePerson(employeeToDelete); assertCommandSuccess(redoCommand, model, RedoCommand.MESSAGE_SUCCESS, expectedModel); } @@ -119,11 +119,11 @@ public void executeUndoRedo_invalidIndexUnfilteredList_failure() { } /** - * 1. Deletes a {@code Person} from a filtered list. + * 1. Deletes a {@code Employee} from a filtered list. * 2. Undo the deletion. - * 3. The unfiltered list should be shown now. Verify that the index of the previously deleted person in the + * 3. The unfiltered list should be shown now. Verify that the index of the previously deleted employee in the * unfiltered list is different from the index at the filtered list. - * 4. Redo the deletion. This ensures {@code RedoCommand} deletes the person object regardless of indexing. + * 4. Redo the deletion. This ensures {@code RedoCommand} deletes the employee object regardless of indexing. */ @Test public void executeUndoRedo_validIndexFilteredList_samePersonDeleted() throws Exception { @@ -134,17 +134,17 @@ public void executeUndoRedo_validIndexFilteredList_samePersonDeleted() throws Ex Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); showPersonAtIndex(model, INDEX_SECOND_PERSON); - Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - // delete -> deletes second person in unfiltered person list / first person in filtered person list + Employee employeeToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + // delete -> deletes second employee in unfiltered employee list / first employee in filtered employee list deleteCommand.execute(); undoRedoStack.push(deleteCommand); - // undo -> reverts addressbook back to previous state and filtered person list to show all persons + // undo -> reverts addressbook back to previous state and filtered employee list to show all persons assertCommandSuccess(undoCommand, model, UndoCommand.MESSAGE_SUCCESS, expectedModel); - expectedModel.deletePerson(personToDelete); - assertNotEquals(personToDelete, model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased())); - // redo -> deletes same second person in unfiltered person list + expectedModel.deletePerson(employeeToDelete); + assertNotEquals(employeeToDelete, model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased())); + // redo -> deletes same second employee in unfiltered employee list assertCommandSuccess(redoCommand, model, RedoCommand.MESSAGE_SUCCESS, expectedModel); } @@ -170,7 +170,7 @@ public void equals() throws Exception { // null -> returns false assertFalse(deleteFirstCommand.equals(null)); - // different person -> returns false + // different employee -> returns false assertFalse(deleteFirstCommand.equals(deleteSecondCommand)); } diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index fde75ae6ddf7..bfa76a95b877 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -28,9 +28,9 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; import seedu.address.testutil.EditPersonDescriptorBuilder; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.EmployeeBuilder; /** * Contains integration tests (interaction with the Model, UndoCommand and RedoCommand) and unit tests for EditCommand. @@ -41,14 +41,14 @@ public class EditCommandTest { @Test public void execute_allFieldsSpecifiedUnfilteredList_success() throws Exception { - Person editedPerson = new PersonBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); + Employee editedEmployee = new EmployeeBuilder().build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedEmployee).build(); EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedEmployee); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.updatePerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.updatePerson(model.getFilteredPersonList().get(0), editedEmployee); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -56,20 +56,20 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() throws Exception @Test public void execute_someFieldsSpecifiedUnfilteredList_success() throws Exception { Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); - Person lastPerson = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); + Employee lastEmployee = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); - PersonBuilder personInList = new PersonBuilder(lastPerson); - Person editedPerson = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + EmployeeBuilder personInList = new EmployeeBuilder(lastEmployee); + Employee editedEmployee = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withTags(VALID_TAG_HUSBAND).build(); EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_HUSBAND).build(); EditCommand editCommand = prepareCommand(indexLastPerson, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedEmployee); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.updatePerson(lastPerson, editedPerson); + expectedModel.updatePerson(lastEmployee, editedEmployee); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -77,9 +77,9 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() throws Exception @Test public void execute_noFieldSpecifiedUnfilteredList_success() { EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, new EditPersonDescriptor()); - Person editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Employee editedEmployee = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedEmployee); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); @@ -90,23 +90,23 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { public void execute_filteredList_success() throws Exception { showPersonAtIndex(model, INDEX_FIRST_PERSON); - Person personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - Person editedPerson = new PersonBuilder(personInFilteredList).withName(VALID_NAME_BOB).build(); + Employee employeeInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Employee editedEmployee = new EmployeeBuilder(employeeInFilteredList).withName(VALID_NAME_BOB).build(); EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedEmployee); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.updatePerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.updatePerson(model.getFilteredPersonList().get(0), editedEmployee); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test public void execute_duplicatePersonUnfilteredList_failure() { - Person firstPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstPerson).build(); + Employee firstEmployee = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstEmployee).build(); EditCommand editCommand = prepareCommand(INDEX_SECOND_PERSON, descriptor); assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); @@ -116,10 +116,10 @@ public void execute_duplicatePersonUnfilteredList_failure() { public void execute_duplicatePersonFilteredList_failure() { showPersonAtIndex(model, INDEX_FIRST_PERSON); - // edit person in filtered list into a duplicate in address book - Person personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); + // edit employee in filtered list into a duplicate in address book + Employee employeeInList = model.getAddressBook().getEmployeeList().get(INDEX_SECOND_PERSON.getZeroBased()); EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, - new EditPersonDescriptorBuilder(personInList).build()); + new EditPersonDescriptorBuilder(employeeInList).build()); assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); } @@ -142,7 +142,7 @@ 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()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getEmployeeList().size()); EditCommand editCommand = prepareCommand(outOfBoundIndex, new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); @@ -155,21 +155,21 @@ public void executeUndoRedo_validIndexUnfilteredList_success() throws Exception UndoRedoStack undoRedoStack = new UndoRedoStack(); UndoCommand undoCommand = prepareUndoCommand(model, undoRedoStack); RedoCommand redoCommand = prepareRedoCommand(model, undoRedoStack); - Person editedPerson = new PersonBuilder().build(); - Person personToEdit = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); + Employee editedEmployee = new EmployeeBuilder().build(); + Employee employeeToEdit = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedEmployee).build(); EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, descriptor); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - // edit -> first person edited + // edit -> first employee edited editCommand.execute(); undoRedoStack.push(editCommand); - // undo -> reverts addressbook back to previous state and filtered person list to show all persons + // undo -> reverts addressbook back to previous state and filtered employee list to show all persons assertCommandSuccess(undoCommand, model, UndoCommand.MESSAGE_SUCCESS, expectedModel); - // redo -> same first person edited again - expectedModel.updatePerson(personToEdit, editedPerson); + // redo -> same first employee edited again + expectedModel.updatePerson(employeeToEdit, editedEmployee); assertCommandSuccess(redoCommand, model, RedoCommand.MESSAGE_SUCCESS, expectedModel); } @@ -191,34 +191,34 @@ public void executeUndoRedo_invalidIndexUnfilteredList_failure() { } /** - * 1. Edits a {@code Person} from a filtered list. + * 1. Edits a {@code Employee} from a filtered list. * 2. Undo the edit. - * 3. The unfiltered list should be shown now. Verify that the index of the previously edited person in the + * 3. The unfiltered list should be shown now. Verify that the index of the previously edited employee in the * unfiltered list is different from the index at the filtered list. - * 4. Redo the edit. This ensures {@code RedoCommand} edits the person object regardless of indexing. + * 4. Redo the edit. This ensures {@code RedoCommand} edits the employee object regardless of indexing. */ @Test public void executeUndoRedo_validIndexFilteredList_samePersonEdited() throws Exception { UndoRedoStack undoRedoStack = new UndoRedoStack(); UndoCommand undoCommand = prepareUndoCommand(model, undoRedoStack); RedoCommand redoCommand = prepareRedoCommand(model, undoRedoStack); - Person editedPerson = new PersonBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); + Employee editedEmployee = new EmployeeBuilder().build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedEmployee).build(); EditCommand editCommand = prepareCommand(INDEX_FIRST_PERSON, descriptor); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); showPersonAtIndex(model, INDEX_SECOND_PERSON); - Person personToEdit = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - // edit -> edits second person in unfiltered person list / first person in filtered person list + Employee employeeToEdit = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + // edit -> edits second employee in unfiltered employee list / first employee in filtered employee list editCommand.execute(); undoRedoStack.push(editCommand); - // undo -> reverts addressbook back to previous state and filtered person list to show all persons + // undo -> reverts addressbook back to previous state and filtered employee list to show all persons assertCommandSuccess(undoCommand, model, UndoCommand.MESSAGE_SUCCESS, expectedModel); - expectedModel.updatePerson(personToEdit, editedPerson); - assertNotEquals(model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()), personToEdit); - // redo -> edits same second person in unfiltered person list + expectedModel.updatePerson(employeeToEdit, editedEmployee); + assertNotEquals(model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()), employeeToEdit); + // redo -> edits same second employee in unfiltered employee list assertCommandSuccess(redoCommand, model, RedoCommand.MESSAGE_SUCCESS, expectedModel); } diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditEmployeeDescriptorTest.java similarity index 98% rename from src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java rename to src/test/java/seedu/address/logic/commands/EditEmployeeDescriptorTest.java index bfa7549c690f..3be728f93388 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditEmployeeDescriptorTest.java @@ -15,7 +15,7 @@ import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; import seedu.address.testutil.EditPersonDescriptorBuilder; -public class EditPersonDescriptorTest { +public class EditEmployeeDescriptorTest { @Test public void equals() { diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index dee1f007f751..d94d4a6724bb 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -21,8 +21,8 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; +import seedu.address.model.person.Employee; import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.Person; /** * Contains integration tests (interaction with the Model) for {@code FindCommand}. @@ -53,7 +53,7 @@ public void equals() { // null -> returns false assertFalse(findFirstCommand.equals(null)); - // different person -> returns false + // different employee -> returns false assertFalse(findFirstCommand.equals(findSecondCommand)); } @@ -84,10 +84,10 @@ private FindCommand prepareCommand(String userInput) { /** * Asserts that {@code command} is successfully executed, and
* - the command feedback is equal to {@code expectedMessage}
- * - the {@code FilteredList} is equal to {@code expectedList}
+ * - the {@code FilteredList} is equal to {@code expectedList}
* - the {@code AddressBook} in model remains the same after executing the {@code command} */ - private void assertCommandSuccess(FindCommand command, String expectedMessage, List expectedList) { + private void assertCommandSuccess(FindCommand command, String expectedMessage, List expectedList) { AddressBook expectedAddressBook = new AddressBook(model.getAddressBook()); CommandResult commandResult = command.execute(); diff --git a/src/test/java/seedu/address/logic/commands/SelectCommandTest.java b/src/test/java/seedu/address/logic/commands/SelectCommandTest.java index 4840900602ac..a3fb7bcc7f26 100644 --- a/src/test/java/seedu/address/logic/commands/SelectCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/SelectCommandTest.java @@ -68,7 +68,7 @@ public void execute_invalidIndexFilteredList_failure() { Index outOfBoundsIndex = INDEX_SECOND_PERSON; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundsIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundsIndex.getZeroBased() < model.getAddressBook().getEmployeeList().size()); assertExecutionFailure(outOfBoundsIndex, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } @@ -91,7 +91,7 @@ public void equals() { // null -> returns false assertFalse(selectFirstCommand.equals(null)); - // different person -> returns false + // different employee -> returns false assertFalse(selectFirstCommand.equals(selectSecondCommand)); } diff --git a/src/test/java/seedu/address/logic/commands/UndoableCommandTest.java b/src/test/java/seedu/address/logic/commands/UndoableCommandTest.java index 7d00a7471b86..84ec8234e4ff 100644 --- a/src/test/java/seedu/address/logic/commands/UndoableCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/UndoableCommandTest.java @@ -13,8 +13,8 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; public class UndoableCommandTest { private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); @@ -47,7 +47,7 @@ public void redo() { } /** - * Deletes the first person in the model's filtered list. + * Deletes the first employee in the model's filtered list. */ class DummyCommand extends UndoableCommand { DummyCommand(Model model) { @@ -56,11 +56,11 @@ class DummyCommand extends UndoableCommand { @Override public CommandResult executeUndoableCommand() throws CommandException { - Person personToDelete = model.getFilteredPersonList().get(0); + Employee employeeToDelete = model.getFilteredPersonList().get(0); try { - model.deletePerson(personToDelete); - } catch (PersonNotFoundException pnfe) { - fail("Impossible: personToDelete was retrieved from model."); + model.deletePerson(employeeToDelete); + } catch (EmployeeNotFoundException pnfe) { + fail("Impossible: employeeToDelete was retrieved from model."); } return new CommandResult(""); } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index c9a350c09657..3bbf51a95a7f 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -36,55 +36,55 @@ import seedu.address.logic.commands.AddCommand; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.EmployeeBuilder; public class AddCommandParserTest { private AddCommandParser parser = new AddCommandParser(); @Test public void parse_allFieldsPresent_success() { - Person expectedPerson = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + Employee expectedEmployee = new EmployeeBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_FRIEND).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedEmployee)); // multiple names - last name accepted assertParseSuccess(parser, NAME_DESC_AMY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedEmployee)); // multiple phones - last phone accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedEmployee)); // multiple emails - last email accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_AMY + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedEmployee)); // multiple addresses - last address accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_AMY - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedEmployee)); // multiple tags - all accepted - Person expectedPersonMultipleTags = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) + Employee expectedEmployeeMultipleTags = new EmployeeBuilder().withName(VALID_NAME_BOB) + .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) .withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND).build(); assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPersonMultipleTags)); + + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedEmployeeMultipleTags)); } @Test public void parse_optionalFieldsMissing_success() { // zero tags - Person expectedPerson = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) + Employee expectedEmployee = new EmployeeBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags().build(); assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY, - new AddCommand(expectedPerson)); + new AddCommand(expectedEmployee)); } @Test diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 7466da232666..01ffdfce38ea 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -29,10 +29,10 @@ import seedu.address.logic.commands.SelectCommand; import seedu.address.logic.commands.UndoCommand; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.Employee; import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.Person; import seedu.address.testutil.EditPersonDescriptorBuilder; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.EmployeeBuilder; import seedu.address.testutil.PersonUtil; public class AddressBookParserTest { @@ -43,9 +43,9 @@ public class AddressBookParserTest { @Test public void parseCommand_add() throws Exception { - Person person = new PersonBuilder().build(); - AddCommand command = (AddCommand) parser.parseCommand(PersonUtil.getAddCommand(person)); - assertEquals(new AddCommand(person), command); + Employee employee = new EmployeeBuilder().build(); + AddCommand command = (AddCommand) parser.parseCommand(PersonUtil.getAddCommand(employee)); + assertEquals(new AddCommand(employee), command); } @Test @@ -63,10 +63,10 @@ public void parseCommand_delete() throws Exception { @Test public void parseCommand_edit() throws Exception { - Person person = new PersonBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build(); + Employee employee = new EmployeeBuilder().build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(employee).build(); EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " - + INDEX_FIRST_PERSON.getOneBased() + " " + PersonUtil.getPersonDetails(person)); + + INDEX_FIRST_PERSON.getOneBased() + " " + PersonUtil.getPersonDetails(employee)); assertEquals(new EditCommand(INDEX_FIRST_PERSON, descriptor), command); } diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 24c138b41a7f..3e0ff34070a2 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -94,7 +94,7 @@ public void parse_invalidValue_failure() { // is tested at {@code parse_invalidValueFollowedByValidValue_success()} assertParseFailure(parser, "1" + PHONE_DESC_BOB + INVALID_PHONE_DESC, Phone.MESSAGE_PHONE_CONSTRAINTS); - // while parsing {@code PREFIX_TAG} alone will reset the tags of the {@code Person} being edited, + // while parsing {@code PREFIX_TAG} alone will reset the tags of the {@code Employee} being edited, // parsing it together with a valid tag results in error assertParseFailure(parser, "1" + TAG_DESC_FRIEND + TAG_DESC_HUSBAND + TAG_EMPTY, Tag.MESSAGE_TAG_CONSTRAINTS); assertParseFailure(parser, "1" + TAG_DESC_FRIEND + TAG_EMPTY + TAG_DESC_HUSBAND, Tag.MESSAGE_TAG_CONSTRAINTS); diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index bf26f68896b8..6acee9a63322 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -16,7 +16,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; import seedu.address.model.tag.Tag; public class AddressBookTest { @@ -28,7 +28,7 @@ public class AddressBookTest { @Test public void constructor() { - assertEquals(Collections.emptyList(), addressBook.getPersonList()); + assertEquals(Collections.emptyList(), addressBook.getEmployeeList()); assertEquals(Collections.emptyList(), addressBook.getTagList()); } @@ -48,9 +48,9 @@ public void resetData_withValidReadOnlyAddressBook_replacesData() { @Test public void resetData_withDuplicatePersons_throwsAssertionError() { // Repeat ALICE twice - List newPersons = Arrays.asList(ALICE, ALICE); + List newEmployees = Arrays.asList(ALICE, ALICE); List newTags = new ArrayList<>(ALICE.getTags()); - AddressBookStub newData = new AddressBookStub(newPersons, newTags); + AddressBookStub newData = new AddressBookStub(newEmployees, newTags); thrown.expect(AssertionError.class); addressBook.resetData(newData); @@ -59,7 +59,7 @@ public void resetData_withDuplicatePersons_throwsAssertionError() { @Test public void getPersonList_modifyList_throwsUnsupportedOperationException() { thrown.expect(UnsupportedOperationException.class); - addressBook.getPersonList().remove(0); + addressBook.getEmployeeList().remove(0); } @Test @@ -69,20 +69,20 @@ public void getTagList_modifyList_throwsUnsupportedOperationException() { } /** - * A stub ReadOnlyAddressBook whose persons and tags lists can violate interface constraints. + * A stub ReadOnlyAddressBook whose employees and tags lists can violate interface constraints. */ private static class AddressBookStub implements ReadOnlyAddressBook { - private final ObservableList persons = FXCollections.observableArrayList(); + private final ObservableList employees = FXCollections.observableArrayList(); private final ObservableList tags = FXCollections.observableArrayList(); - AddressBookStub(Collection persons, Collection tags) { - this.persons.setAll(persons); + AddressBookStub(Collection employees, Collection tags) { + this.employees.setAll(employees); this.tags.setAll(tags); } @Override - public ObservableList getPersonList() { - return persons; + public ObservableList getEmployeeList() { + return employees; } @Override diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 59ce1b83693a..e4f73f4d4efd 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -28,7 +28,7 @@ public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException @Test public void equals() { - AddressBook addressBook = new AddressBookBuilder().withPerson(ALICE).withPerson(BENSON).build(); + AddressBook addressBook = new AddressBookBuilder().withEmployee(ALICE).withEmployee(BENSON).build(); AddressBook differentAddressBook = new AddressBook(); UserPrefs userPrefs = new UserPrefs(); diff --git a/src/test/java/seedu/address/model/UniquePersonListTest.java b/src/test/java/seedu/address/model/UniqueEmployeeListTest.java similarity index 61% rename from src/test/java/seedu/address/model/UniquePersonListTest.java rename to src/test/java/seedu/address/model/UniqueEmployeeListTest.java index ae39646daab2..afd426d93d55 100644 --- a/src/test/java/seedu/address/model/UniquePersonListTest.java +++ b/src/test/java/seedu/address/model/UniqueEmployeeListTest.java @@ -4,16 +4,16 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import seedu.address.model.person.UniquePersonList; +import seedu.address.model.person.UniqueEmployeeList; -public class UniquePersonListTest { +public class UniqueEmployeeListTest { @Rule public ExpectedException thrown = ExpectedException.none(); @Test public void asObservableList_modifyList_throwsUnsupportedOperationException() { - UniquePersonList uniquePersonList = new UniquePersonList(); + UniqueEmployeeList uniqueEmployeeList = new UniqueEmployeeList(); thrown.expect(UnsupportedOperationException.class); - uniquePersonList.asObservableList().remove(0); + uniqueEmployeeList.asObservableList().remove(0); } } diff --git a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java index 76841215e3a0..7f1e2ecf00be 100644 --- a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java +++ b/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java @@ -9,7 +9,7 @@ import org.junit.Test; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.EmployeeBuilder; public class NameContainsKeywordsPredicateTest { @@ -34,7 +34,7 @@ public void equals() { // null -> returns false assertFalse(firstPredicate.equals(null)); - // different person -> returns false + // different employee -> returns false assertFalse(firstPredicate.equals(secondPredicate)); } @@ -42,34 +42,34 @@ public void equals() { public void test_nameContainsKeywords_returnsTrue() { // One keyword NameContainsKeywordsPredicate predicate = new NameContainsKeywordsPredicate(Collections.singletonList("Alice")); - assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build())); + assertTrue(predicate.test(new EmployeeBuilder().withName("Alice Bob").build())); // Multiple keywords predicate = new NameContainsKeywordsPredicate(Arrays.asList("Alice", "Bob")); - assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build())); + assertTrue(predicate.test(new EmployeeBuilder().withName("Alice Bob").build())); // Only one matching keyword predicate = new NameContainsKeywordsPredicate(Arrays.asList("Bob", "Carol")); - assertTrue(predicate.test(new PersonBuilder().withName("Alice Carol").build())); + assertTrue(predicate.test(new EmployeeBuilder().withName("Alice Carol").build())); // Mixed-case keywords predicate = new NameContainsKeywordsPredicate(Arrays.asList("aLIce", "bOB")); - assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build())); + assertTrue(predicate.test(new EmployeeBuilder().withName("Alice Bob").build())); } @Test public void test_nameDoesNotContainKeywords_returnsFalse() { // Zero keywords NameContainsKeywordsPredicate predicate = new NameContainsKeywordsPredicate(Collections.emptyList()); - assertFalse(predicate.test(new PersonBuilder().withName("Alice").build())); + assertFalse(predicate.test(new EmployeeBuilder().withName("Alice").build())); // Non-matching keyword predicate = new NameContainsKeywordsPredicate(Arrays.asList("Carol")); - assertFalse(predicate.test(new PersonBuilder().withName("Alice Bob").build())); + assertFalse(predicate.test(new EmployeeBuilder().withName("Alice Bob").build())); // Keywords match phone, email and address, but does not match name predicate = new NameContainsKeywordsPredicate(Arrays.asList("12345", "alice@email.com", "Main", "Street")); - assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("12345") + assertFalse(predicate.test(new EmployeeBuilder().withName("Alice").withPhone("12345") .withEmail("alice@email.com").withAddress("Main Street").build())); } } diff --git a/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java b/src/test/java/seedu/address/storage/XmlAdaptedEmployeeTest.java similarity index 73% rename from src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java rename to src/test/java/seedu/address/storage/XmlAdaptedEmployeeTest.java index c3c91a5c27a7..47e7feddd1bf 100644 --- a/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/XmlAdaptedEmployeeTest.java @@ -1,7 +1,7 @@ package seedu.address.storage; import static org.junit.Assert.assertEquals; -import static seedu.address.storage.XmlAdaptedPerson.MISSING_FIELD_MESSAGE_FORMAT; +import static seedu.address.storage.XmlAdaptedEmployee.MISSING_FIELD_MESSAGE_FORMAT; import static seedu.address.testutil.TypicalPersons.BENSON; import java.util.ArrayList; @@ -17,7 +17,7 @@ import seedu.address.model.person.Phone; import seedu.address.testutil.Assert; -public class XmlAdaptedPersonTest { +public class XmlAdaptedEmployeeTest { private static final String INVALID_NAME = "R@chel"; private static final String INVALID_PHONE = "+651234"; private static final String INVALID_ADDRESS = " "; @@ -34,66 +34,66 @@ public class XmlAdaptedPersonTest { @Test public void toModelType_validPersonDetails_returnsPerson() throws Exception { - XmlAdaptedPerson person = new XmlAdaptedPerson(BENSON); + XmlAdaptedEmployee person = new XmlAdaptedEmployee(BENSON); assertEquals(BENSON, person.toModelType()); } @Test public void toModelType_invalidName_throwsIllegalValueException() { - XmlAdaptedPerson person = - new XmlAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedEmployee person = + new XmlAdaptedEmployee(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); String expectedMessage = Name.MESSAGE_NAME_CONSTRAINTS; Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullName_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedEmployee person = new XmlAdaptedEmployee(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_invalidPhone_throwsIllegalValueException() { - XmlAdaptedPerson person = - new XmlAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedEmployee person = + new XmlAdaptedEmployee(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); String expectedMessage = Phone.MESSAGE_PHONE_CONSTRAINTS; Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullPhone_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedEmployee person = new XmlAdaptedEmployee(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_invalidEmail_throwsIllegalValueException() { - XmlAdaptedPerson person = - new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedEmployee person = + new XmlAdaptedEmployee(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_TAGS); String expectedMessage = Email.MESSAGE_EMAIL_CONSTRAINTS; Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullEmail_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedEmployee person = new XmlAdaptedEmployee(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_invalidAddress_throwsIllegalValueException() { - XmlAdaptedPerson person = - new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_TAGS); + XmlAdaptedEmployee person = + new XmlAdaptedEmployee(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_TAGS); String expectedMessage = Address.MESSAGE_ADDRESS_CONSTRAINTS; Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullAddress_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_TAGS); + XmlAdaptedEmployee person = new XmlAdaptedEmployee(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -102,8 +102,8 @@ public void toModelType_nullAddress_throwsIllegalValueException() { public void toModelType_invalidTags_throwsIllegalValueException() { List invalidTags = new ArrayList<>(VALID_TAGS); invalidTags.add(new XmlAdaptedTag(INVALID_TAG)); - XmlAdaptedPerson person = - new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); + XmlAdaptedEmployee person = + new XmlAdaptedEmployee(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); Assert.assertThrows(IllegalValueException.class, person::toModelType); } diff --git a/src/test/java/seedu/address/storage/XmlAddressBookStorageTest.java b/src/test/java/seedu/address/storage/XmlAddressBookStorageTest.java index 1bf3765cfba9..c9d9d9f38237 100644 --- a/src/test/java/seedu/address/storage/XmlAddressBookStorageTest.java +++ b/src/test/java/seedu/address/storage/XmlAddressBookStorageTest.java @@ -84,14 +84,14 @@ public void readAndSaveAddressBook_allInOrder_success() throws Exception { assertEquals(original, new AddressBook(readBack)); //Modify data, overwrite exiting file, and read back - original.addPerson(HOON); - original.removePerson(ALICE); + original.addEmployee(HOON); + original.removeEmployee(ALICE); xmlAddressBookStorage.saveAddressBook(original, filePath); readBack = xmlAddressBookStorage.readAddressBook(filePath).get(); assertEquals(original, new AddressBook(readBack)); //Save and read without specifying file path - original.addPerson(IDA); + original.addEmployee(IDA); xmlAddressBookStorage.saveAddressBook(original); //file path not specified readBack = xmlAddressBookStorage.readAddressBook().get(); //file path not specified assertEquals(original, new AddressBook(readBack)); diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index 6e73a762b0c1..abc37c363dce 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -2,14 +2,14 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.DuplicatePersonException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; import seedu.address.model.tag.Tag; /** * A utility class to help with building Addressbook objects. * Example usage:
- * {@code AddressBook ab = new AddressBookBuilder().withPerson("John", "Doe").withTag("Friend").build();} + * {@code AddressBook ab = new AddressBookBuilder().withEmployee("John", "Doe").withTag("Friend").build();} */ public class AddressBookBuilder { @@ -24,13 +24,13 @@ public AddressBookBuilder(AddressBook addressBook) { } /** - * Adds a new {@code Person} to the {@code AddressBook} that we are building. + * Adds a new {@code Employee} to the {@code AddressBook} that we are building. */ - public AddressBookBuilder withPerson(Person person) { + public AddressBookBuilder withEmployee(Employee employee) { try { - addressBook.addPerson(person); - } catch (DuplicatePersonException dpe) { - throw new IllegalArgumentException("person is expected to be unique."); + addressBook.addEmployee(employee); + } catch (DuplicateEmployeeException dpe) { + throw new IllegalArgumentException("employee is expected to be unique."); } return this; } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 4584bd5044e1..82e5ec563727 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -7,8 +7,8 @@ import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; @@ -28,15 +28,15 @@ public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) { } /** - * Returns an {@code EditPersonDescriptor} with fields containing {@code person}'s details + * Returns an {@code EditPersonDescriptor} with fields containing {@code employee}'s details */ - public EditPersonDescriptorBuilder(Person person) { + public EditPersonDescriptorBuilder(Employee employee) { descriptor = new EditPersonDescriptor(); - descriptor.setName(person.getName()); - descriptor.setPhone(person.getPhone()); - descriptor.setEmail(person.getEmail()); - descriptor.setAddress(person.getAddress()); - descriptor.setTags(person.getTags()); + descriptor.setName(employee.getName()); + descriptor.setPhone(employee.getPhone()); + descriptor.setEmail(employee.getEmail()); + descriptor.setAddress(employee.getAddress()); + descriptor.setTags(employee.getTags()); } /** diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/EmployeeBuilder.java similarity index 56% rename from src/test/java/seedu/address/testutil/PersonBuilder.java rename to src/test/java/seedu/address/testutil/EmployeeBuilder.java index b124fc1d73b1..eccc1ecc082f 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/EmployeeBuilder.java @@ -5,16 +5,16 @@ import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; import seedu.address.model.util.SampleDataUtil; /** - * A utility class to help with building Person objects. + * A utility class to help with building Employee objects. */ -public class PersonBuilder { +public class EmployeeBuilder { public static final String DEFAULT_NAME = "Alice Pauline"; public static final String DEFAULT_PHONE = "85355255"; @@ -28,7 +28,7 @@ public class PersonBuilder { private Address address; private Set tags; - public PersonBuilder() { + public EmployeeBuilder() { name = new Name(DEFAULT_NAME); phone = new Phone(DEFAULT_PHONE); email = new Email(DEFAULT_EMAIL); @@ -37,58 +37,58 @@ public PersonBuilder() { } /** - * Initializes the PersonBuilder with the data of {@code personToCopy}. + * Initializes the EmployeeBuilder with the data of {@code employeeToCopy}. */ - public PersonBuilder(Person personToCopy) { - name = personToCopy.getName(); - phone = personToCopy.getPhone(); - email = personToCopy.getEmail(); - address = personToCopy.getAddress(); - tags = new HashSet<>(personToCopy.getTags()); + public EmployeeBuilder(Employee employeeToCopy) { + name = employeeToCopy.getName(); + phone = employeeToCopy.getPhone(); + email = employeeToCopy.getEmail(); + address = employeeToCopy.getAddress(); + tags = new HashSet<>(employeeToCopy.getTags()); } /** - * Sets the {@code Name} of the {@code Person} that we are building. + * Sets the {@code Name} of the {@code Employee} that we are building. */ - public PersonBuilder withName(String name) { + public EmployeeBuilder withName(String name) { this.name = new Name(name); return this; } /** - * Parses the {@code tags} into a {@code Set} and set it to the {@code Person} that we are building. + * Parses the {@code tags} into a {@code Set} and set it to the {@code Employee} that we are building. */ - public PersonBuilder withTags(String ... tags) { + public EmployeeBuilder withTags(String ... tags) { this.tags = SampleDataUtil.getTagSet(tags); return this; } /** - * Sets the {@code Address} of the {@code Person} that we are building. + * Sets the {@code Address} of the {@code Employee} that we are building. */ - public PersonBuilder withAddress(String address) { + public EmployeeBuilder withAddress(String address) { this.address = new Address(address); return this; } /** - * Sets the {@code Phone} of the {@code Person} that we are building. + * Sets the {@code Phone} of the {@code Employee} that we are building. */ - public PersonBuilder withPhone(String phone) { + public EmployeeBuilder withPhone(String phone) { this.phone = new Phone(phone); return this; } /** - * Sets the {@code Email} of the {@code Person} that we are building. + * Sets the {@code Email} of the {@code Employee} that we are building. */ - public PersonBuilder withEmail(String email) { + public EmployeeBuilder withEmail(String email) { this.email = new Email(email); return this; } - public Person build() { - return new Person(name, phone, email, address, tags); + public Employee build() { + return new Employee(name, phone, email, address, tags); } } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index 642d4f174514..1b5cb8e58e8b 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -7,30 +7,30 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import seedu.address.logic.commands.AddCommand; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** - * A utility class for Person. + * A utility class for Employee. */ public class PersonUtil { /** - * Returns an add command string for adding the {@code person}. + * Returns an add command string for adding the {@code employee}. */ - public static String getAddCommand(Person person) { - return AddCommand.COMMAND_WORD + " " + getPersonDetails(person); + public static String getAddCommand(Employee employee) { + return AddCommand.COMMAND_WORD + " " + getPersonDetails(employee); } /** - * Returns the part of command string for the given {@code person}'s details. + * Returns the part of command string for the given {@code employee}'s details. */ - public static String getPersonDetails(Person person) { + public static String getPersonDetails(Employee employee) { StringBuilder sb = new StringBuilder(); - sb.append(PREFIX_NAME + person.getName().fullName + " "); - sb.append(PREFIX_PHONE + person.getPhone().value + " "); - sb.append(PREFIX_EMAIL + person.getEmail().value + " "); - sb.append(PREFIX_ADDRESS + person.getAddress().value + " "); - person.getTags().stream().forEach( + sb.append(PREFIX_NAME + employee.getName().fullName + " "); + sb.append(PREFIX_PHONE + employee.getPhone().value + " "); + sb.append(PREFIX_EMAIL + employee.getEmail().value + " "); + sb.append(PREFIX_ADDRESS + employee.getAddress().value + " "); + employee.getTags().stream().forEach( s -> sb.append(PREFIX_TAG + s.tagName + " ") ); return sb.toString(); diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/seedu/address/testutil/TestUtil.java index c1458738c054..06053d2b1a77 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/seedu/address/testutil/TestUtil.java @@ -6,7 +6,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.FileUtil; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** * A utility class for test cases. @@ -32,23 +32,23 @@ public static String getFilePathInSandboxFolder(String fileName) { } /** - * Returns the middle index of the person in the {@code model}'s person list. + * Returns the middle index of the employee in the {@code model}'s employee list. */ public static Index getMidIndex(Model model) { - return Index.fromOneBased(model.getAddressBook().getPersonList().size() / 2); + return Index.fromOneBased(model.getAddressBook().getEmployeeList().size() / 2); } /** - * Returns the last index of the person in the {@code model}'s person list. + * Returns the last index of the employee in the {@code model}'s employee list. */ public static Index getLastIndex(Model model) { - return Index.fromOneBased(model.getAddressBook().getPersonList().size()); + return Index.fromOneBased(model.getAddressBook().getEmployeeList().size()); } /** - * Returns the person in the {@code model}'s person list at {@code index}. + * Returns the employee in the {@code model}'s employee list at {@code index}. */ - public static Person getPerson(Model model, Index index) { - return model.getAddressBook().getPersonList().get(index.getZeroBased()); + public static Employee getPerson(Model model, Index index) { + return model.getAddressBook().getEmployeeList().get(index.getZeroBased()); } } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index 3086e384afb2..8e334632c33e 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -16,43 +16,43 @@ import java.util.List; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.DuplicatePersonException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; /** - * A utility class containing a list of {@code Person} objects to be used in tests. + * A utility class containing a list of {@code Employee} objects to be used in tests. */ public class TypicalPersons { - public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") + public static final Employee ALICE = new EmployeeBuilder().withName("Alice Pauline") .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") .withPhone("85355255") .withTags("friends").build(); - public static final Person BENSON = new PersonBuilder().withName("Benson Meier") + public static final Employee BENSON = new EmployeeBuilder().withName("Benson Meier") .withAddress("311, Clementi Ave 2, #02-25") .withEmail("johnd@example.com").withPhone("98765432") .withTags("owesMoney", "friends").build(); - public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") + public static final Employee CARL = new EmployeeBuilder().withName("Carl Kurz").withPhone("95352563") .withEmail("heinz@example.com").withAddress("wall street").build(); - public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") + public static final Employee DANIEL = new EmployeeBuilder().withName("Daniel Meier").withPhone("87652533") .withEmail("cornelia@example.com").withAddress("10th street").build(); - public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") + public static final Employee ELLE = new EmployeeBuilder().withName("Elle Meyer").withPhone("9482224") .withEmail("werner@example.com").withAddress("michegan ave").build(); - public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") + public static final Employee FIONA = new EmployeeBuilder().withName("Fiona Kunz").withPhone("9482427") .withEmail("lydia@example.com").withAddress("little tokyo").build(); - public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") + public static final Employee GEORGE = new EmployeeBuilder().withName("George Best").withPhone("9482442") .withEmail("anna@example.com").withAddress("4th street").build(); // Manually added - public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") + public static final Employee HOON = new EmployeeBuilder().withName("Hoon Meier").withPhone("8482424") .withEmail("stefan@example.com").withAddress("little india").build(); - public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") + public static final Employee IDA = new EmployeeBuilder().withName("Ida Mueller").withPhone("8482131") .withEmail("hans@example.com").withAddress("chicago ave").build(); - // Manually added - Person's details found in {@code CommandTestUtil} - public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) + // Manually added - Employee's details found in {@code CommandTestUtil} + public static final Employee AMY = new EmployeeBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); - public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + public static final Employee BOB = new EmployeeBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); @@ -65,10 +65,10 @@ private TypicalPersons() {} // prevents instantiation */ public static AddressBook getTypicalAddressBook() { AddressBook ab = new AddressBook(); - for (Person person : getTypicalPersons()) { + for (Employee employee : getTypicalPersons()) { try { - ab.addPerson(person); - } catch (DuplicatePersonException e) { + ab.addEmployee(employee); + } catch (DuplicateEmployeeException e) { throw new AssertionError("not possible"); } } @@ -80,21 +80,21 @@ public static AddressBook getTypicalAddressBook() { */ public static AddressBook getTypicalAddressBookNonAlphabetically() { AddressBook ab = new AddressBook(); - for (Person person : getTypicalPersonsNonAlphabetically()) { + for (Employee employee : getTypicalPersonsNonAlphabetically()) { try { - ab.addPerson(person); - } catch (DuplicatePersonException e) { + ab.addEmployee(employee); + } catch (DuplicateEmployeeException e) { throw new AssertionError("not possible"); } } return ab; } - public static List getTypicalPersons() { + public static List getTypicalPersons() { return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); } - public static List getTypicalPersonsNonAlphabetically() { + public static List getTypicalPersonsNonAlphabetically() { return new ArrayList<>(Arrays.asList(GEORGE, FIONA, ELLE, DANIEL, CARL, BENSON, ALICE)); } } diff --git a/src/test/java/seedu/address/ui/BrowserPanelTest.java b/src/test/java/seedu/address/ui/BrowserPanelTest.java index 48aab940f8a8..93c23206c84e 100644 --- a/src/test/java/seedu/address/ui/BrowserPanelTest.java +++ b/src/test/java/seedu/address/ui/BrowserPanelTest.java @@ -38,7 +38,7 @@ public void display() throws Exception { URL expectedDefaultPageUrl = MainApp.class.getResource(FXML_FILE_FOLDER + DEFAULT_PAGE); assertEquals(expectedDefaultPageUrl, browserPanelHandle.getLoadedUrl()); - // associated web page of a person + // associated web page of a employee postNow(selectionChangedEventStub); URL expectedPersonUrl = new URL(BrowserPanel.SEARCH_PAGE_URL + ALICE.getName().fullName.replaceAll(" ", "%20")); diff --git a/src/test/java/seedu/address/ui/EmployeeCardTest.java b/src/test/java/seedu/address/ui/EmployeeCardTest.java new file mode 100644 index 000000000000..6db333ccd424 --- /dev/null +++ b/src/test/java/seedu/address/ui/EmployeeCardTest.java @@ -0,0 +1,72 @@ +package seedu.address.ui; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static seedu.address.ui.testutil.GuiTestAssert.assertCardDisplaysPerson; + +import org.junit.Test; + +import guitests.guihandles.PersonCardHandle; +import seedu.address.model.person.Employee; +import seedu.address.testutil.EmployeeBuilder; + +public class EmployeeCardTest extends GuiUnitTest { + + @Test + public void display() { + // no tags + Employee employeeWithNoTags = new EmployeeBuilder().withTags(new String[0]).build(); + PersonCard personCard = new PersonCard(employeeWithNoTags, 1); + uiPartRule.setUiPart(personCard); + assertCardDisplay(personCard, employeeWithNoTags, 1); + + // with tags + Employee employeeWithTags = new EmployeeBuilder().build(); + personCard = new PersonCard(employeeWithTags, 2); + uiPartRule.setUiPart(personCard); + assertCardDisplay(personCard, employeeWithTags, 2); + } + + @Test + public void equals() { + Employee employee = new EmployeeBuilder().build(); + PersonCard personCard = new PersonCard(employee, 0); + + // same employee, same index -> returns true + PersonCard copy = new PersonCard(employee, 0); + assertTrue(personCard.equals(copy)); + + // same object -> returns true + assertTrue(personCard.equals(personCard)); + + // null -> returns false + assertFalse(personCard.equals(null)); + + // different types -> returns false + assertFalse(personCard.equals(0)); + + // different employee, same index -> returns false + Employee differentEmployee = new EmployeeBuilder().withName("differentName").build(); + assertFalse(personCard.equals(new PersonCard(differentEmployee, 0))); + + // same employee, different index -> returns false + assertFalse(personCard.equals(new PersonCard(employee, 1))); + } + + /** + * Asserts that {@code personCard} displays the details of {@code expectedEmployee} correctly and matches + * {@code expectedId}. + */ + private void assertCardDisplay(PersonCard personCard, Employee expectedEmployee, int expectedId) { + guiRobot.pauseForHuman(); + + PersonCardHandle personCardHandle = new PersonCardHandle(personCard.getRoot()); + + // verify id is displayed correctly + assertEquals(Integer.toString(expectedId) + ". ", personCardHandle.getId()); + + // verify employee details are displayed correctly + assertCardDisplaysPerson(expectedEmployee, personCardHandle); + } +} diff --git a/src/test/java/seedu/address/ui/PersonListPanelTest.java b/src/test/java/seedu/address/ui/EmployeeListPanelTest.java similarity index 80% rename from src/test/java/seedu/address/ui/PersonListPanelTest.java rename to src/test/java/seedu/address/ui/EmployeeListPanelTest.java index 906ec2bebc03..9d7f810d8c46 100644 --- a/src/test/java/seedu/address/ui/PersonListPanelTest.java +++ b/src/test/java/seedu/address/ui/EmployeeListPanelTest.java @@ -15,10 +15,10 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import seedu.address.commons.events.ui.JumpToListRequestEvent; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; -public class PersonListPanelTest extends GuiUnitTest { - private static final ObservableList TYPICAL_PERSONS = +public class EmployeeListPanelTest extends GuiUnitTest { + private static final ObservableList TYPICAL_EMPLOYEES = FXCollections.observableList(getTypicalPersons()); private static final JumpToListRequestEvent JUMP_TO_SECOND_EVENT = new JumpToListRequestEvent(INDEX_SECOND_PERSON); @@ -27,7 +27,7 @@ public class PersonListPanelTest extends GuiUnitTest { @Before public void setUp() { - PersonListPanel personListPanel = new PersonListPanel(TYPICAL_PERSONS); + PersonListPanel personListPanel = new PersonListPanel(TYPICAL_EMPLOYEES); uiPartRule.setUiPart(personListPanel); personListPanelHandle = new PersonListPanelHandle(getChildNode(personListPanel.getRoot(), @@ -36,12 +36,12 @@ public void setUp() { @Test public void display() { - for (int i = 0; i < TYPICAL_PERSONS.size(); i++) { - personListPanelHandle.navigateToCard(TYPICAL_PERSONS.get(i)); - Person expectedPerson = TYPICAL_PERSONS.get(i); + for (int i = 0; i < TYPICAL_EMPLOYEES.size(); i++) { + personListPanelHandle.navigateToCard(TYPICAL_EMPLOYEES.get(i)); + Employee expectedEmployee = TYPICAL_EMPLOYEES.get(i); PersonCardHandle actualCard = personListPanelHandle.getPersonCardHandle(i); - assertCardDisplaysPerson(expectedPerson, actualCard); + assertCardDisplaysPerson(expectedEmployee, actualCard); assertEquals(Integer.toString(i + 1) + ". ", actualCard.getId()); } } diff --git a/src/test/java/seedu/address/ui/PersonCardTest.java b/src/test/java/seedu/address/ui/PersonCardTest.java deleted file mode 100644 index 42f840faa3b4..000000000000 --- a/src/test/java/seedu/address/ui/PersonCardTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package seedu.address.ui; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static seedu.address.ui.testutil.GuiTestAssert.assertCardDisplaysPerson; - -import org.junit.Test; - -import guitests.guihandles.PersonCardHandle; -import seedu.address.model.person.Person; -import seedu.address.testutil.PersonBuilder; - -public class PersonCardTest extends GuiUnitTest { - - @Test - public void display() { - // no tags - Person personWithNoTags = new PersonBuilder().withTags(new String[0]).build(); - PersonCard personCard = new PersonCard(personWithNoTags, 1); - uiPartRule.setUiPart(personCard); - assertCardDisplay(personCard, personWithNoTags, 1); - - // with tags - Person personWithTags = new PersonBuilder().build(); - personCard = new PersonCard(personWithTags, 2); - uiPartRule.setUiPart(personCard); - assertCardDisplay(personCard, personWithTags, 2); - } - - @Test - public void equals() { - Person person = new PersonBuilder().build(); - PersonCard personCard = new PersonCard(person, 0); - - // same person, same index -> returns true - PersonCard copy = new PersonCard(person, 0); - assertTrue(personCard.equals(copy)); - - // same object -> returns true - assertTrue(personCard.equals(personCard)); - - // null -> returns false - assertFalse(personCard.equals(null)); - - // different types -> returns false - assertFalse(personCard.equals(0)); - - // different person, same index -> returns false - Person differentPerson = new PersonBuilder().withName("differentName").build(); - assertFalse(personCard.equals(new PersonCard(differentPerson, 0))); - - // same person, different index -> returns false - assertFalse(personCard.equals(new PersonCard(person, 1))); - } - - /** - * Asserts that {@code personCard} displays the details of {@code expectedPerson} correctly and matches - * {@code expectedId}. - */ - private void assertCardDisplay(PersonCard personCard, Person expectedPerson, int expectedId) { - guiRobot.pauseForHuman(); - - PersonCardHandle personCardHandle = new PersonCardHandle(personCard.getRoot()); - - // verify id is displayed correctly - assertEquals(Integer.toString(expectedId) + ". ", personCardHandle.getId()); - - // verify person details are displayed correctly - assertCardDisplaysPerson(expectedPerson, personCardHandle); - } -} diff --git a/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java b/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java index d21cc2fb3739..3ed4b26b008f 100644 --- a/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java +++ b/src/test/java/seedu/address/ui/testutil/GuiTestAssert.java @@ -8,7 +8,7 @@ import guitests.guihandles.PersonCardHandle; import guitests.guihandles.PersonListPanelHandle; import guitests.guihandles.ResultDisplayHandle; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** * A set of assertion methods useful for writing GUI tests. @@ -27,33 +27,33 @@ public static void assertCardEquals(PersonCardHandle expectedCard, PersonCardHan } /** - * Asserts that {@code actualCard} displays the details of {@code expectedPerson}. + * Asserts that {@code actualCard} displays the details of {@code expectedEmployee}. */ - public static void assertCardDisplaysPerson(Person expectedPerson, PersonCardHandle actualCard) { - assertEquals(expectedPerson.getName().fullName, actualCard.getName()); - assertEquals(expectedPerson.getPhone().value, actualCard.getPhone()); - assertEquals(expectedPerson.getEmail().value, actualCard.getEmail()); - assertEquals(expectedPerson.getAddress().value, actualCard.getAddress()); - assertEquals(expectedPerson.getTags().stream().map(tag -> tag.tagName).collect(Collectors.toList()), + public static void assertCardDisplaysPerson(Employee expectedEmployee, PersonCardHandle actualCard) { + assertEquals(expectedEmployee.getName().fullName, actualCard.getName()); + assertEquals(expectedEmployee.getPhone().value, actualCard.getPhone()); + assertEquals(expectedEmployee.getEmail().value, actualCard.getEmail()); + assertEquals(expectedEmployee.getAddress().value, actualCard.getAddress()); + assertEquals(expectedEmployee.getTags().stream().map(tag -> tag.tagName).collect(Collectors.toList()), actualCard.getTags()); } /** - * Asserts that the list in {@code personListPanelHandle} displays the details of {@code persons} correctly and + * Asserts that the list in {@code personListPanelHandle} displays the details of {@code employees} correctly and * in the correct order. */ - public static void assertListMatching(PersonListPanelHandle personListPanelHandle, Person... persons) { - for (int i = 0; i < persons.length; i++) { - assertCardDisplaysPerson(persons[i], personListPanelHandle.getPersonCardHandle(i)); + public static void assertListMatching(PersonListPanelHandle personListPanelHandle, Employee... employees) { + for (int i = 0; i < employees.length; i++) { + assertCardDisplaysPerson(employees[i], personListPanelHandle.getPersonCardHandle(i)); } } /** - * Asserts that the list in {@code personListPanelHandle} displays the details of {@code persons} correctly and + * Asserts that the list in {@code personListPanelHandle} displays the details of {@code employees} correctly and * in the correct order. */ - public static void assertListMatching(PersonListPanelHandle personListPanelHandle, List persons) { - assertListMatching(personListPanelHandle, persons.toArray(new Person[0])); + public static void assertListMatching(PersonListPanelHandle personListPanelHandle, List employees) { + assertListMatching(personListPanelHandle, employees.toArray(new Employee[0])); } /** diff --git a/src/test/java/systemtests/AddCommandSystemTest.java b/src/test/java/systemtests/AddCommandSystemTest.java index 35e8e7517440..a90b4b175210 100644 --- a/src/test/java/systemtests/AddCommandSystemTest.java +++ b/src/test/java/systemtests/AddCommandSystemTest.java @@ -44,12 +44,12 @@ import seedu.address.model.Model; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.exceptions.DuplicatePersonException; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; import seedu.address.model.tag.Tag; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.EmployeeBuilder; import seedu.address.testutil.PersonUtil; public class AddCommandSystemTest extends AddressBookSystemTest { @@ -60,10 +60,10 @@ public void add() throws Exception { /* ------------------------ Perform add operations on the shown unfiltered list ----------------------------- */ - /* Case: add a person without tags to a non-empty address book, command with leading spaces and trailing spaces - * -> added + /* Case: add a employee without tags to a non-empty address book, command with leading spaces and + * trailing spaces -> added */ - Person toAdd = AMY; + Employee toAdd = AMY; String command = " " + AddCommand.COMMAND_WORD + " " + NAME_DESC_AMY + " " + PHONE_DESC_AMY + " " + EMAIL_DESC_AMY + " " + ADDRESS_DESC_AMY + " " + TAG_DESC_FRIEND + " "; assertCommandSuccess(command, toAdd); @@ -79,29 +79,29 @@ public void add() throws Exception { expectedResultMessage = RedoCommand.MESSAGE_SUCCESS; assertCommandSuccess(command, model, expectedResultMessage); - /* Case: add a person with all fields same as another person in the address book except name -> added */ - toAdd = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) + /* Case: add a employee with all fields same as another employee in the address book except name -> added */ + toAdd = new EmployeeBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) .withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); command = AddCommand.COMMAND_WORD + NAME_DESC_BOB + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); - /* Case: add a person with all fields same as another person in the address book except phone -> added */ - toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY) + /* Case: add a employee with all fields same as another employee in the address book except phone -> added */ + toAdd = new EmployeeBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY) .withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); - /* Case: add a person with all fields same as another person in the address book except email -> added */ - toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_BOB) + /* Case: add a employee with all fields same as another employee in the address book except email -> added */ + toAdd = new EmployeeBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_BOB) .withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_BOB + ADDRESS_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); - /* Case: add a person with all fields same as another person in the address book except address -> added */ - toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) + /* Case: add a employee with all fields same as another employee in the address book except address -> added */ + toAdd = new EmployeeBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_FRIEND).build(); command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_BOB + TAG_DESC_FRIEND; @@ -111,37 +111,37 @@ public void add() throws Exception { deleteAllPersons(); assertCommandSuccess(ALICE); - /* Case: add a person with tags, command with parameters in random order -> added */ + /* Case: add a employee with tags, command with parameters in random order -> added */ toAdd = BOB; command = AddCommand.COMMAND_WORD + TAG_DESC_FRIEND + PHONE_DESC_BOB + ADDRESS_DESC_BOB + NAME_DESC_BOB + TAG_DESC_HUSBAND + EMAIL_DESC_BOB; assertCommandSuccess(command, toAdd); - /* Case: add a person, missing tags -> added */ + /* Case: add a employee, missing tags -> added */ assertCommandSuccess(HOON); - /* -------------------------- Perform add operation on the shown filtered list ------------------------------ */ + /* ------------------------ Perform add operation on the shown filtered list ---------------------------- */ - /* Case: filters the person list before adding -> added */ + /* Case: filters the employee list before adding -> added */ showPersonsWithName(KEYWORD_MATCHING_MEIER); assertCommandSuccess(IDA); - /* ------------------------ Perform add operation while a person card is selected --------------------------- */ + /* ----------------------- Perform add operation while a employee card is selected ------------------------- */ - /* Case: selects first card in the person list, add a person -> added, card selection remains unchanged */ + /* Case: selects first card in the employee list, add a employee -> added, card selection remains unchanged */ selectPerson(Index.fromOneBased(1)); assertCommandSuccess(CARL); - /* ----------------------------------- Perform invalid add operations --------------------------------------- */ + /* --------------------------------- Perform invalid add operations ------------------------------------- */ - /* Case: add a duplicate person -> rejected */ + /* Case: add a duplicate employee -> rejected */ command = PersonUtil.getAddCommand(HOON); assertCommandFailure(command, AddCommand.MESSAGE_DUPLICATE_PERSON); - /* Case: add a duplicate person except with different tags -> rejected */ + /* Case: add a duplicate employee except with different tags -> rejected */ // "friends" is an existing tag used in the default model, see TypicalPersons#ALICE // This test will fail if a new tag that is not in the model is used, see the bug documented in - // AddressBook#addPerson(Person) + // AddressBook#addEmployee(Employee) command = PersonUtil.getAddCommand(HOON) + " " + PREFIX_TAG.getPrefix() + "friends"; assertCommandFailure(command, AddCommand.MESSAGE_DUPLICATE_PERSON); @@ -201,20 +201,20 @@ public void add() throws Exception { * {@code AddressBookSystemTest#assertApplicationDisplaysExpected(String, String, Model)}.
* @see AddressBookSystemTest#assertApplicationDisplaysExpected(String, String, Model) */ - private void assertCommandSuccess(Person toAdd) { + private void assertCommandSuccess(Employee toAdd) { assertCommandSuccess(PersonUtil.getAddCommand(toAdd), toAdd); } /** - * Performs the same verification as {@code assertCommandSuccess(Person)}. Executes {@code command} + * Performs the same verification as {@code assertCommandSuccess(Employee)}. Executes {@code command} * instead. - * @see AddCommandSystemTest#assertCommandSuccess(Person) + * @see AddCommandSystemTest#assertCommandSuccess(Employee) */ - private void assertCommandSuccess(String command, Person toAdd) { + private void assertCommandSuccess(String command, Employee toAdd) { Model expectedModel = getModel(); try { expectedModel.addPerson(toAdd); - } catch (DuplicatePersonException dpe) { + } catch (DuplicateEmployeeException dpe) { throw new IllegalArgumentException("toAdd already exists in the model."); } String expectedResultMessage = String.format(AddCommand.MESSAGE_SUCCESS, toAdd); @@ -223,12 +223,12 @@ private void assertCommandSuccess(String command, Person toAdd) { } /** - * Performs the same verification as {@code assertCommandSuccess(String, Person)} except asserts that + * Performs the same verification as {@code assertCommandSuccess(String, Employee)} except asserts that * the,
* 1. Result display box displays {@code expectedResultMessage}.
* 2. {@code Model}, {@code Storage} and {@code PersonListPanel} equal to the corresponding components in * {@code expectedModel}.
- * @see AddCommandSystemTest#assertCommandSuccess(String, Person) + * @see AddCommandSystemTest#assertCommandSuccess(String, Employee) */ private void assertCommandSuccess(String command, Model expectedModel, String expectedResultMessage) { executeCommand(command); diff --git a/src/test/java/systemtests/AddressBookSystemTest.java b/src/test/java/systemtests/AddressBookSystemTest.java index 30ca988d6bb4..c8830cc27109 100644 --- a/src/test/java/systemtests/AddressBookSystemTest.java +++ b/src/test/java/systemtests/AddressBookSystemTest.java @@ -141,7 +141,7 @@ protected void executeCommand(String command) { */ protected void showAllPersons() { executeCommand(ListCommand.COMMAND_WORD); - assertEquals(getModel().getAddressBook().getPersonList().size(), getModel().getFilteredPersonList().size()); + assertEquals(getModel().getAddressBook().getEmployeeList().size(), getModel().getFilteredPersonList().size()); } /** @@ -149,11 +149,11 @@ protected void showAllPersons() { */ protected void showPersonsWithName(String keyword) { executeCommand(FindCommand.COMMAND_WORD + " " + keyword); - assertTrue(getModel().getFilteredPersonList().size() < getModel().getAddressBook().getPersonList().size()); + assertTrue(getModel().getFilteredPersonList().size() < getModel().getAddressBook().getEmployeeList().size()); } /** - * Selects the person at {@code index} of the displayed list. + * Selects the employee at {@code index} of the displayed list. */ protected void selectPerson(Index index) { executeCommand(SelectCommand.COMMAND_WORD + " " + index.getOneBased()); @@ -165,13 +165,13 @@ protected void selectPerson(Index index) { */ protected void deleteAllPersons() { executeCommand(ClearCommand.COMMAND_WORD); - assertEquals(0, getModel().getAddressBook().getPersonList().size()); + assertEquals(0, getModel().getAddressBook().getEmployeeList().size()); } /** * Asserts that the {@code CommandBox} displays {@code expectedCommandInput}, the {@code ResultDisplay} displays - * {@code expectedResultMessage}, the model and storage contains the same person objects as {@code expectedModel} - * and the person list panel displays the persons in the model correctly. + * {@code expectedResultMessage}, the model and storage contains the same employee objects as {@code expectedModel} + * and the employee list panel displays the persons in the model correctly. */ protected void assertApplicationDisplaysExpected(String expectedCommandInput, String expectedResultMessage, Model expectedModel) { @@ -185,8 +185,8 @@ protected void assertApplicationDisplaysExpected(String expectedCommandInput, St /** * Asserts that the {@code CommandBox} displays {@code expectedCommandInput}, the {@code ResultDisplay} displays * {@code expectedResultMessage} with command keys message appended, - * the model and storage contains the same person objects as {@code expectedModel} - * and the person list panel displays the persons in the model correctly. + * the model and storage contains the same employee objects as {@code expectedModel} + * and the employee list panel displays the persons in the model correctly. */ protected void assertApplicationDisplaysExpectedError(String expectedCommandInput, String expectedResultMessage, Model expectedModel) { @@ -212,7 +212,7 @@ private void rememberStates() { /** * Asserts that the previously selected card is now deselected and the browser's url remains displaying the details - * of the previously selected person. + * of the previously selected employee. * @see BrowserPanelHandle#isUrlChanged() */ protected void assertSelectedCardDeselected() { @@ -221,7 +221,7 @@ protected void assertSelectedCardDeselected() { } /** - * Asserts that the browser's url is changed to display the details of the person in the person list panel at + * Asserts that the browser's url is changed to display the details of the employee in the employee list panel at * {@code expectedSelectedCardIndex}, and only the card at {@code expectedSelectedCardIndex} is selected. * @see BrowserPanelHandle#isUrlChanged() * @see PersonListPanelHandle#isSelectedPersonCardChanged() @@ -240,7 +240,7 @@ protected void assertSelectedCardChanged(Index expectedSelectedCardIndex) { } /** - * Asserts that the browser's url and the selected card in the person list panel remain unchanged. + * Asserts that the browser's url and the selected card in the employee list panel remain unchanged. * @see BrowserPanelHandle#isUrlChanged() * @see PersonListPanelHandle#isSelectedPersonCardChanged() */ diff --git a/src/test/java/systemtests/ClearCommandSystemTest.java b/src/test/java/systemtests/ClearCommandSystemTest.java index de7e680095cf..820f700ba7e2 100644 --- a/src/test/java/systemtests/ClearCommandSystemTest.java +++ b/src/test/java/systemtests/ClearCommandSystemTest.java @@ -36,13 +36,13 @@ public void clear() { assertCommandSuccess(command, expectedResultMessage, new ModelManager()); assertSelectedCardUnchanged(); - /* Case: selects first card in person list and clears address book -> cleared and no card selected */ + /* Case: selects first card in employee list and clears address book -> cleared and no card selected */ executeCommand(UndoCommand.COMMAND_WORD); // restores the original address book selectPerson(Index.fromOneBased(1)); assertCommandSuccess(ClearCommand.COMMAND_WORD); assertSelectedCardDeselected(); - /* Case: filters the person list before clearing -> entire address book cleared */ + /* Case: filters the employee list before clearing -> entire address book cleared */ executeCommand(UndoCommand.COMMAND_WORD); // restores the original address book showPersonsWithName(KEYWORD_MATCHING_MEIER); assertCommandSuccess(ClearCommand.COMMAND_WORD); diff --git a/src/test/java/systemtests/DeleteCommandSystemTest.java b/src/test/java/systemtests/DeleteCommandSystemTest.java index 441be2d63259..2bd861b9d432 100644 --- a/src/test/java/systemtests/DeleteCommandSystemTest.java +++ b/src/test/java/systemtests/DeleteCommandSystemTest.java @@ -18,8 +18,8 @@ import seedu.address.logic.commands.RedoCommand; import seedu.address.logic.commands.UndoCommand; import seedu.address.model.Model; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.Employee; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; public class DeleteCommandSystemTest extends AddressBookSystemTest { @@ -28,65 +28,65 @@ public class DeleteCommandSystemTest extends AddressBookSystemTest { @Test public void delete() { - /* ----------------- Performing delete operation while an unfiltered list is being shown -------------------- */ + /* ---------------- Performing delete operation while an unfiltered list is being shown ------------------- */ - /* Case: delete the first person in the list, command with leading spaces and trailing spaces -> deleted */ + /* Case: delete the first employee in the list, command with leading spaces and trailing spaces -> deleted */ Model expectedModel = getModel(); String command = " " + DeleteCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + " "; - Person deletedPerson = removePerson(expectedModel, INDEX_FIRST_PERSON); - String expectedResultMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, deletedPerson); + Employee deletedEmployee = removePerson(expectedModel, INDEX_FIRST_PERSON); + String expectedResultMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, deletedEmployee); assertCommandSuccess(command, expectedModel, expectedResultMessage); - /* Case: delete the last person in the list -> deleted */ + /* Case: delete the last employee in the list -> deleted */ Model modelBeforeDeletingLast = getModel(); Index lastPersonIndex = getLastIndex(modelBeforeDeletingLast); assertCommandSuccess(lastPersonIndex); - /* Case: undo deleting the last person in the list -> last person restored */ + /* Case: undo deleting the last employee in the list -> last employee restored */ command = UndoCommand.COMMAND_WORD; expectedResultMessage = UndoCommand.MESSAGE_SUCCESS; assertCommandSuccess(command, modelBeforeDeletingLast, expectedResultMessage); - /* Case: redo deleting the last person in the list -> last person deleted again */ + /* Case: redo deleting the last employee in the list -> last employee deleted again */ command = RedoCommand.COMMAND_WORD; removePerson(modelBeforeDeletingLast, lastPersonIndex); expectedResultMessage = RedoCommand.MESSAGE_SUCCESS; assertCommandSuccess(command, modelBeforeDeletingLast, expectedResultMessage); - /* Case: delete the middle person in the list -> deleted */ + /* Case: delete the middle employee in the list -> deleted */ Index middlePersonIndex = getMidIndex(getModel()); assertCommandSuccess(middlePersonIndex); - /* ------------------ Performing delete operation while a filtered list is being shown ---------------------- */ + /* ---------------- Performing delete operation while a filtered list is being shown -------------------- */ - /* Case: filtered person list, delete index within bounds of address book and person list -> deleted */ + /* Case: filtered employee list, delete index within bounds of address book and employee list -> deleted */ showPersonsWithName(KEYWORD_MATCHING_MEIER); Index index = INDEX_FIRST_PERSON; assertTrue(index.getZeroBased() < getModel().getFilteredPersonList().size()); assertCommandSuccess(index); - /* Case: filtered person list, delete index within bounds of address book but out of bounds of person list + /* Case: filtered employee list, delete index within bounds of address book but out of bounds of employee list * -> rejected */ showPersonsWithName(KEYWORD_MATCHING_MEIER); - int invalidIndex = getModel().getAddressBook().getPersonList().size(); + int invalidIndex = getModel().getAddressBook().getEmployeeList().size(); command = DeleteCommand.COMMAND_WORD + " " + invalidIndex; assertCommandFailure(command, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); - /* --------------------- Performing delete operation while a person card is selected ------------------------ */ + /* ------------------- Performing delete operation while a employee card is selected ---------------------- */ - /* Case: delete the selected person -> person list panel selects the person before the deleted person */ + /* Case: delete the selected employee -> employee list panel selects the employee before the deleted employee */ showAllPersons(); expectedModel = getModel(); Index selectedIndex = getLastIndex(expectedModel); Index expectedIndex = Index.fromZeroBased(selectedIndex.getZeroBased() - 1); selectPerson(selectedIndex); command = DeleteCommand.COMMAND_WORD + " " + selectedIndex.getOneBased(); - deletedPerson = removePerson(expectedModel, selectedIndex); - expectedResultMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, deletedPerson); + deletedEmployee = removePerson(expectedModel, selectedIndex); + expectedResultMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, deletedEmployee); assertCommandSuccess(command, expectedModel, expectedResultMessage, expectedIndex); - /* --------------------------------- Performing invalid delete operation ------------------------------------ */ + /* ------------------------------- Performing invalid delete operation ---------------------------------- */ /* Case: invalid index (0) -> rejected */ command = DeleteCommand.COMMAND_WORD + " 0"; @@ -98,7 +98,7 @@ public void delete() { /* Case: invalid index (size + 1) -> rejected */ Index outOfBoundsIndex = Index.fromOneBased( - getModel().getAddressBook().getPersonList().size() + 1); + getModel().getAddressBook().getEmployeeList().size() + 1); command = DeleteCommand.COMMAND_WORD + " " + outOfBoundsIndex.getOneBased(); assertCommandFailure(command, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); @@ -113,31 +113,31 @@ public void delete() { } /** - * Removes the {@code Person} at the specified {@code index} in {@code model}'s address book. - * @return the removed person + * Removes the {@code Employee} at the specified {@code index} in {@code model}'s address book. + * @return the removed employee */ - private Person removePerson(Model model, Index index) { - Person targetPerson = getPerson(model, index); + private Employee removePerson(Model model, Index index) { + Employee targetEmployee = getPerson(model, index); try { - model.deletePerson(targetPerson); - } catch (PersonNotFoundException pnfe) { - throw new AssertionError("targetPerson is retrieved from model."); + model.deletePerson(targetEmployee); + } catch (EmployeeNotFoundException pnfe) { + throw new AssertionError("targetEmployee is retrieved from model."); } - return targetPerson; + return targetEmployee; } /** - * Deletes the person at {@code toDelete} by creating a default {@code DeleteCommand} using {@code toDelete} and + * Deletes the employee at {@code toDelete} by creating a default {@code DeleteCommand} using {@code toDelete} and * performs the same verification as {@code assertCommandSuccess(String, Model, String)}. * @see DeleteCommandSystemTest#assertCommandSuccess(String, Model, String) */ private void assertCommandSuccess(Index toDelete) { Model expectedModel = getModel(); - Person deletedPerson = removePerson(expectedModel, toDelete); - String expectedResultMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, deletedPerson); + Employee deletedEmployee = removePerson(expectedModel, toDelete); + String expectedResultMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, deletedEmployee); - assertCommandSuccess( - DeleteCommand.COMMAND_WORD + " " + toDelete.getOneBased(), expectedModel, expectedResultMessage); + assertCommandSuccess(DeleteCommand.COMMAND_WORD + " " + + toDelete.getOneBased(), expectedModel, expectedResultMessage); } /** diff --git a/src/test/java/systemtests/EditCommandSystemTest.java b/src/test/java/systemtests/EditCommandSystemTest.java index 9105923c6d0c..8b5a54b05c22 100644 --- a/src/test/java/systemtests/EditCommandSystemTest.java +++ b/src/test/java/systemtests/EditCommandSystemTest.java @@ -40,13 +40,13 @@ import seedu.address.model.Model; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Employee; import seedu.address.model.person.Name; -import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.person.exceptions.DuplicateEmployeeException; +import seedu.address.model.person.exceptions.EmployeeNotFoundException; import seedu.address.model.tag.Tag; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.EmployeeBuilder; import seedu.address.testutil.PersonUtil; public class EditCommandSystemTest extends AddressBookSystemTest { @@ -63,23 +63,23 @@ public void edit() throws Exception { Index index = INDEX_FIRST_PERSON; String command = " " + EditCommand.COMMAND_WORD + " " + index.getOneBased() + " " + NAME_DESC_BOB + " " + PHONE_DESC_BOB + " " + EMAIL_DESC_BOB + " " + ADDRESS_DESC_BOB + " " + TAG_DESC_HUSBAND + " "; - Person editedPerson = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + Employee editedEmployee = new EmployeeBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND).build(); - assertCommandSuccess(command, index, editedPerson); + assertCommandSuccess(command, index, editedEmployee); - /* Case: undo editing the last person in the list -> last person restored */ + /* Case: undo editing the last employee in the list -> last employee restored */ command = UndoCommand.COMMAND_WORD; String expectedResultMessage = UndoCommand.MESSAGE_SUCCESS; assertCommandSuccess(command, model, expectedResultMessage); - /* Case: redo editing the last person in the list -> last person edited again */ + /* Case: redo editing the last employee in the list -> last employee edited again */ command = RedoCommand.COMMAND_WORD; expectedResultMessage = RedoCommand.MESSAGE_SUCCESS; model.updatePerson( - getModel().getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()), editedPerson); + getModel().getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()), editedEmployee); assertCommandSuccess(command, model, expectedResultMessage); - /* Case: edit a person with new values same as existing values -> edited */ + /* Case: edit a employee with new values same as existing values -> edited */ command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_FRIEND + TAG_DESC_HUSBAND; assertCommandSuccess(command, index, BOB); @@ -87,39 +87,39 @@ public void edit() throws Exception { /* Case: edit some fields -> edited */ index = INDEX_FIRST_PERSON; command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + TAG_DESC_FRIEND; - Person personToEdit = getModel().getFilteredPersonList().get(index.getZeroBased()); - editedPerson = new PersonBuilder(personToEdit).withTags(VALID_TAG_FRIEND).build(); - assertCommandSuccess(command, index, editedPerson); + Employee employeeToEdit = getModel().getFilteredPersonList().get(index.getZeroBased()); + editedEmployee = new EmployeeBuilder(employeeToEdit).withTags(VALID_TAG_FRIEND).build(); + assertCommandSuccess(command, index, editedEmployee); /* Case: clear tags -> cleared */ index = INDEX_FIRST_PERSON; command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + " " + PREFIX_TAG.getPrefix(); - editedPerson = new PersonBuilder(personToEdit).withTags().build(); - assertCommandSuccess(command, index, editedPerson); + editedEmployee = new EmployeeBuilder(employeeToEdit).withTags().build(); + assertCommandSuccess(command, index, editedEmployee); /* ------------------ Performing edit operation while a filtered list is being shown ------------------------ */ - /* Case: filtered person list, edit index within bounds of address book and person list -> edited */ + /* Case: filtered employee list, edit index within bounds of address book and employee list -> edited */ showPersonsWithName(KEYWORD_MATCHING_MEIER); index = INDEX_FIRST_PERSON; assertTrue(index.getZeroBased() < getModel().getFilteredPersonList().size()); command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + " " + NAME_DESC_BOB; - personToEdit = getModel().getFilteredPersonList().get(index.getZeroBased()); - editedPerson = new PersonBuilder(personToEdit).withName(VALID_NAME_BOB).build(); - assertCommandSuccess(command, index, editedPerson); + employeeToEdit = getModel().getFilteredPersonList().get(index.getZeroBased()); + editedEmployee = new EmployeeBuilder(employeeToEdit).withName(VALID_NAME_BOB).build(); + assertCommandSuccess(command, index, editedEmployee); - /* Case: filtered person list, edit index within bounds of address book but out of bounds of person list + /* Case: filtered employee list, edit index within bounds of address book but out of bounds of employee list * -> rejected */ showPersonsWithName(KEYWORD_MATCHING_MEIER); - int invalidIndex = getModel().getAddressBook().getPersonList().size(); + int invalidIndex = getModel().getAddressBook().getEmployeeList().size(); assertCommandFailure(EditCommand.COMMAND_WORD + " " + invalidIndex + NAME_DESC_BOB, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); - /* --------------------- Performing edit operation while a person card is selected -------------------------- */ + /* ------------------- Performing edit operation while a employee card is selected ------------------------ */ - /* Case: selects first card in the person list, edit a person -> edited, card selection remains unchanged but - * browser url changes + /* Case: selects first card in the employee list, edit a employee -> edited, card selection + * remains unchanged but browser url changes */ showAllPersons(); index = INDEX_FIRST_PERSON; @@ -127,10 +127,10 @@ public void edit() throws Exception { command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + TAG_DESC_FRIEND; // this can be misleading: card selection actually remains unchanged but the - // browser's url is updated to reflect the new person's name + // browser's url is updated to reflect the new employee's name assertCommandSuccess(command, index, AMY, index); - /* --------------------------------- Performing invalid edit operation -------------------------------------- */ + /* -------------------------------- Performing invalid edit operation ------------------------------------- */ /* Case: invalid index (0) -> rejected */ assertCommandFailure(EditCommand.COMMAND_WORD + " 0" + NAME_DESC_BOB, @@ -154,72 +154,73 @@ public void edit() throws Exception { EditCommand.MESSAGE_NOT_EDITED); /* Case: invalid name -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_NAME_DESC, - Name.MESSAGE_NAME_CONSTRAINTS); + assertCommandFailure(EditCommand.COMMAND_WORD + " " + + INDEX_FIRST_PERSON.getOneBased() + INVALID_NAME_DESC, Name.MESSAGE_NAME_CONSTRAINTS); /* Case: invalid phone -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_PHONE_DESC, - Phone.MESSAGE_PHONE_CONSTRAINTS); + assertCommandFailure(EditCommand.COMMAND_WORD + " " + + INDEX_FIRST_PERSON.getOneBased() + INVALID_PHONE_DESC, Phone.MESSAGE_PHONE_CONSTRAINTS); /* Case: invalid email -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_EMAIL_DESC, - Email.MESSAGE_EMAIL_CONSTRAINTS); + assertCommandFailure(EditCommand.COMMAND_WORD + " " + + INDEX_FIRST_PERSON.getOneBased() + INVALID_EMAIL_DESC, Email.MESSAGE_EMAIL_CONSTRAINTS); /* Case: invalid address -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_ADDRESS_DESC, - Address.MESSAGE_ADDRESS_CONSTRAINTS); + assertCommandFailure(EditCommand.COMMAND_WORD + " " + + INDEX_FIRST_PERSON.getOneBased() + INVALID_ADDRESS_DESC, Address.MESSAGE_ADDRESS_CONSTRAINTS); /* Case: invalid tag -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_TAG_DESC, - Tag.MESSAGE_TAG_CONSTRAINTS); + assertCommandFailure(EditCommand.COMMAND_WORD + " " + + INDEX_FIRST_PERSON.getOneBased() + INVALID_TAG_DESC, Tag.MESSAGE_TAG_CONSTRAINTS); - /* Case: edit a person with new values same as another person's values -> rejected */ + /* Case: edit a employee with new values same as another employee's values -> rejected */ executeCommand(PersonUtil.getAddCommand(BOB)); - assertTrue(getModel().getAddressBook().getPersonList().contains(BOB)); + assertTrue(getModel().getAddressBook().getEmployeeList().contains(BOB)); index = INDEX_FIRST_PERSON; assertFalse(getModel().getFilteredPersonList().get(index.getZeroBased()).equals(BOB)); command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_FRIEND + TAG_DESC_HUSBAND; assertCommandFailure(command, EditCommand.MESSAGE_DUPLICATE_PERSON); - /* Case: edit a person with new values same as another person's values but with different tags -> rejected */ + /* Case: edit a employee with new values same as another employee's values + but with different tags -> rejected */ command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_HUSBAND; assertCommandFailure(command, EditCommand.MESSAGE_DUPLICATE_PERSON); } /** - * Performs the same verification as {@code assertCommandSuccess(String, Index, Person, Index)} except that + * Performs the same verification as {@code assertCommandSuccess(String, Index, Employee, Index)} except that * the browser url and selected card remain unchanged. * @param toEdit the index of the current model's filtered list - * @see EditCommandSystemTest#assertCommandSuccess(String, Index, Person, Index) + * @see EditCommandSystemTest#assertCommandSuccess(String, Index, Employee, Index) */ - private void assertCommandSuccess(String command, Index toEdit, Person editedPerson) { - assertCommandSuccess(command, toEdit, editedPerson, null); + private void assertCommandSuccess(String command, Index toEdit, Employee editedEmployee) { + assertCommandSuccess(command, toEdit, editedEmployee, null); } /** * Performs the same verification as {@code assertCommandSuccess(String, Model, String, Index)} and in addition,
* 1. Asserts that result display box displays the success message of executing {@code EditCommand}.
- * 2. Asserts that the model related components are updated to reflect the person at index {@code toEdit} being - * updated to values specified {@code editedPerson}.
+ * 2. Asserts that the model related components are updated to reflect the employee at index {@code toEdit} being + * updated to values specified {@code editedEmployee}.
* @param toEdit the index of the current model's filtered list. * @see EditCommandSystemTest#assertCommandSuccess(String, Model, String, Index) */ - private void assertCommandSuccess(String command, Index toEdit, Person editedPerson, + private void assertCommandSuccess(String command, Index toEdit, Employee editedEmployee, Index expectedSelectedCardIndex) { Model expectedModel = getModel(); try { expectedModel.updatePerson( - expectedModel.getFilteredPersonList().get(toEdit.getZeroBased()), editedPerson); + expectedModel.getFilteredPersonList().get(toEdit.getZeroBased()), editedEmployee); expectedModel.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - } catch (DuplicatePersonException | PersonNotFoundException e) { + } catch (DuplicateEmployeeException | EmployeeNotFoundException e) { throw new IllegalArgumentException( - "editedPerson is a duplicate in expectedModel, or it isn't found in the model."); + "editedEmployee is a duplicate in expectedModel, or it isn't found in the model."); } assertCommandSuccess(command, expectedModel, - String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson), expectedSelectedCardIndex); + String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedEmployee), expectedSelectedCardIndex); } /** diff --git a/src/test/java/systemtests/FindCommandSystemTest.java b/src/test/java/systemtests/FindCommandSystemTest.java index 975935929cca..9d2e85d682e7 100644 --- a/src/test/java/systemtests/FindCommandSystemTest.java +++ b/src/test/java/systemtests/FindCommandSystemTest.java @@ -34,14 +34,14 @@ public void find() { assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: repeat previous find command where person list is displaying the persons we are finding + /* Case: repeat previous find command where employee list is displaying the persons we are finding * -> 2 persons found */ command = FindCommand.COMMAND_WORD + " " + KEYWORD_MATCHING_MEIER; assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find person where person list is not displaying the person we are finding -> 1 person found */ + /* Case: find employee where employee list is not displaying the employee we are finding -> 1 employee found */ command = FindCommand.COMMAND_WORD + " Carl"; ModelHelper.setFilteredList(expectedModel, CARL); assertCommandSuccess(command, expectedModel); @@ -80,59 +80,59 @@ public void find() { expectedResultMessage = RedoCommand.MESSAGE_FAILURE; assertCommandFailure(command, expectedResultMessage); - /* Case: find same persons in address book after deleting 1 of them -> 1 person found */ + /* Case: find same persons in address book after deleting 1 of them -> 1 employee found */ executeCommand(DeleteCommand.COMMAND_WORD + " 1"); - assertFalse(getModel().getAddressBook().getPersonList().contains(BENSON)); + assertFalse(getModel().getAddressBook().getEmployeeList().contains(BENSON)); command = FindCommand.COMMAND_WORD + " " + KEYWORD_MATCHING_MEIER; expectedModel = getModel(); ModelHelper.setFilteredList(expectedModel, DANIEL); assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find person in address book, keyword is same as name but of different case -> 1 person found */ + /* Case: find employee in address book, keyword is same as name but of different case -> 1 employee found */ command = FindCommand.COMMAND_WORD + " MeIeR"; assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find person in address book, keyword is substring of name -> 0 persons found */ + /* Case: find employee in address book, keyword is substring of name -> 0 persons found */ command = FindCommand.COMMAND_WORD + " Mei"; ModelHelper.setFilteredList(expectedModel); assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find person in address book, name is substring of keyword -> 0 persons found */ + /* Case: find employee in address book, name is substring of keyword -> 0 persons found */ command = FindCommand.COMMAND_WORD + " Meiers"; ModelHelper.setFilteredList(expectedModel); assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find person not in address book -> 0 persons found */ + /* Case: find employee not in address book -> 0 persons found */ command = FindCommand.COMMAND_WORD + " Mark"; assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find phone number of person in address book -> 0 persons found */ + /* Case: find phone number of employee in address book -> 0 persons found */ command = FindCommand.COMMAND_WORD + " " + DANIEL.getPhone().value; assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find address of person in address book -> 0 persons found */ + /* Case: find address of employee in address book -> 0 persons found */ command = FindCommand.COMMAND_WORD + " " + DANIEL.getAddress().value; assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find email of person in address book -> 0 persons found */ + /* Case: find email of employee in address book -> 0 persons found */ command = FindCommand.COMMAND_WORD + " " + DANIEL.getEmail().value; assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find tags of person in address book -> 0 persons found */ + /* Case: find tags of employee in address book -> 0 persons found */ List tags = new ArrayList<>(DANIEL.getTags()); command = FindCommand.COMMAND_WORD + " " + tags.get(0).tagName; assertCommandSuccess(command, expectedModel); assertSelectedCardUnchanged(); - /* Case: find while a person is selected -> selected card deselected */ + /* Case: find while a employee is selected -> selected card deselected */ showAllPersons(); selectPerson(Index.fromOneBased(1)); assertFalse(getPersonListPanel().getHandleToSelectedCard().getName().equals(DANIEL.getName().fullName)); @@ -141,7 +141,7 @@ public void find() { assertCommandSuccess(command, expectedModel); assertSelectedCardDeselected(); - /* Case: find person in empty address book -> 0 persons found */ + /* Case: find employee in empty address book -> 0 persons found */ deleteAllPersons(); command = FindCommand.COMMAND_WORD + " " + KEYWORD_MATCHING_MEIER; expectedModel = getModel(); diff --git a/src/test/java/systemtests/ModelHelper.java b/src/test/java/systemtests/ModelHelper.java index b7950598d36b..688f3be142d4 100644 --- a/src/test/java/systemtests/ModelHelper.java +++ b/src/test/java/systemtests/ModelHelper.java @@ -6,19 +6,19 @@ import java.util.function.Predicate; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; /** * Contains helper methods to set up {@code Model} for testing. */ public class ModelHelper { - private static final Predicate PREDICATE_MATCHING_NO_PERSONS = unused -> false; + private static final Predicate PREDICATE_MATCHING_NO_PERSONS = unused -> false; /** * Updates {@code model}'s filtered list to display only {@code toDisplay}. */ - public static void setFilteredList(Model model, List toDisplay) { - Optional> predicate = + public static void setFilteredList(Model model, List toDisplay) { + Optional> predicate = toDisplay.stream().map(ModelHelper::getPredicateMatching).reduce(Predicate::or); model.updateFilteredPersonList(predicate.orElse(PREDICATE_MATCHING_NO_PERSONS)); } @@ -26,14 +26,14 @@ public static void setFilteredList(Model model, List toDisplay) { /** * @see ModelHelper#setFilteredList(Model, List) */ - public static void setFilteredList(Model model, Person... toDisplay) { + public static void setFilteredList(Model model, Employee... toDisplay) { setFilteredList(model, Arrays.asList(toDisplay)); } /** - * Returns a predicate that evaluates to true if this {@code Person} equals to {@code other}. + * Returns a predicate that evaluates to true if this {@code Employee} equals to {@code other}. */ - private static Predicate getPredicateMatching(Person other) { + private static Predicate getPredicateMatching(Employee other) { return person -> person.equals(other); } } diff --git a/src/test/java/systemtests/SampleDataTest.java b/src/test/java/systemtests/SampleDataTest.java index 81a32ce9487b..c36d69a804f9 100644 --- a/src/test/java/systemtests/SampleDataTest.java +++ b/src/test/java/systemtests/SampleDataTest.java @@ -9,7 +9,7 @@ import org.junit.Test; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.person.Employee; import seedu.address.model.util.SampleDataUtil; import seedu.address.testutil.TestUtil; @@ -45,7 +45,7 @@ private void deleteFileIfExists(String filePath) { @Test public void addressBook_dataFileDoesNotExist_loadSampleData() { - Person[] expectedList = SampleDataUtil.getSamplePersons(); + Employee[] expectedList = SampleDataUtil.getSamplePersons(); assertListMatching(getPersonListPanel(), expectedList); } } diff --git a/src/test/java/systemtests/SelectCommandSystemTest.java b/src/test/java/systemtests/SelectCommandSystemTest.java index ef005de470eb..20496b24cedd 100644 --- a/src/test/java/systemtests/SelectCommandSystemTest.java +++ b/src/test/java/systemtests/SelectCommandSystemTest.java @@ -22,13 +22,13 @@ public class SelectCommandSystemTest extends AddressBookSystemTest { public void select() { /* ------------------------ Perform select operations on the shown unfiltered list -------------------------- */ - /* Case: select the first card in the person list, command with leading spaces and trailing spaces + /* Case: select the first card in the employee list, command with leading spaces and trailing spaces * -> selected */ String command = " " + SelectCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + " "; assertCommandSuccess(command, INDEX_FIRST_PERSON); - /* Case: select the last card in the person list -> selected */ + /* Case: select the last card in the employee list -> selected */ Index personCount = Index.fromOneBased(getTypicalPersons().size()); command = SelectCommand.COMMAND_WORD + " " + personCount.getOneBased(); assertCommandSuccess(command, personCount); @@ -43,7 +43,7 @@ public void select() { expectedResultMessage = RedoCommand.MESSAGE_FAILURE; assertCommandFailure(command, expectedResultMessage); - /* Case: select the middle card in the person list -> selected */ + /* Case: select the middle card in the employee list -> selected */ Index middleIndex = Index.fromOneBased(personCount.getOneBased() / 2); command = SelectCommand.COMMAND_WORD + " " + middleIndex.getOneBased(); assertCommandSuccess(command, middleIndex); @@ -53,14 +53,14 @@ public void select() { /* ------------------------ Perform select operations on the shown filtered list ---------------------------- */ - /* Case: filtered person list, select index within bounds of address book but out of bounds of person list + /* Case: filtered employee list, select index within bounds of address book but out of bounds of employee list * -> rejected */ showPersonsWithName(KEYWORD_MATCHING_MEIER); - int invalidIndex = getModel().getAddressBook().getPersonList().size(); + int invalidIndex = getModel().getAddressBook().getEmployeeList().size(); assertCommandFailure(SelectCommand.COMMAND_WORD + " " + invalidIndex, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); - /* Case: filtered person list, select index within bounds of address book and person list -> selected */ + /* Case: filtered employee list, select index within bounds of address book and employee list -> selected */ Index validIndex = Index.fromOneBased(1); assertTrue(validIndex.getZeroBased() < getModel().getFilteredPersonList().size()); command = SelectCommand.COMMAND_WORD + " " + validIndex.getOneBased(); @@ -102,7 +102,7 @@ public void select() { * 1. Command box displays an empty string.
* 2. Command box has the default style class.
* 3. Result display box displays the success message of executing select command with the - * {@code expectedSelectedCardIndex} of the selected person.
+ * {@code expectedSelectedCardIndex} of the selected employee.
* 4. {@code Model}, {@code Storage} and {@code PersonListPanel} remain unchanged.
* 5. Selected card is at {@code expectedSelectedCardIndex} and the browser url is updated accordingly.
* 6. Status bar remains unchanged.