From 434babd6e847345b2353a92c27372bfbbed2842f Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Fri, 4 Oct 2024 21:32:51 +0800 Subject: [PATCH 1/9] Fix bug in CommandException comment --- .../address/logic/commands/exceptions/CommandException.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java index a16bd14f2cd..f44c0c19186 100644 --- a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java +++ b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java @@ -1,5 +1,7 @@ package seedu.address.logic.commands.exceptions; +import seedu.address.logic.commands.Command; + /** * Represents an error which occurs during execution of a {@link Command}. */ From 2495633d95293c9756fe286215095a3807138817 Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Fri, 4 Oct 2024 22:40:46 +0800 Subject: [PATCH 2/9] Adapt class Person to Student To transform the model design for the original AB3 project to fit with TAchy, the Person class is refactored to Student. Address class is removed as it is not related to the use cases around Student in TAchy. This change makes the model design more relatable to TAchy. --- LICENSE | 4 +- docs/DeveloperGuide.md | 22 +-- docs/UserGuide.md | 40 ++-- .../tracing/LogicSequenceDiagram.puml | 2 +- src/main/java/seedu/address/logic/Logic.java | 4 +- .../seedu/address/logic/LogicManager.java | 4 +- .../java/seedu/address/logic/Messages.java | 18 +- .../address/logic/commands/AddCommand.java | 23 +-- .../address/logic/commands/DeleteCommand.java | 16 +- .../address/logic/commands/EditCommand.java | 104 +++++------ .../address/logic/commands/FindCommand.java | 2 +- .../logic/parser/AddCommandParser.java | 21 +-- .../seedu/address/logic/parser/CliSyntax.java | 1 - .../logic/parser/EditCommandParser.java | 24 +-- .../logic/parser/FindCommandParser.java | 2 +- .../address/logic/parser/ParserUtil.java | 22 +-- .../java/seedu/address/model/AddressBook.java | 46 ++--- src/main/java/seedu/address/model/Model.java | 34 ++-- .../seedu/address/model/ModelManager.java | 38 ++-- .../address/model/ReadOnlyAddressBook.java | 4 +- .../AssignmentNotFoundException.java | 2 +- .../seedu/address/model/person/Address.java | 65 ------- .../model/person/UniquePersonList.java | 150 --------------- .../exceptions/PersonNotFoundException.java | 6 - .../model/{person => student}/Email.java | 4 +- .../model/{person => student}/Name.java | 4 +- .../NameContainsKeywordsPredicate.java | 10 +- .../model/{person => student}/Phone.java | 4 +- .../Person.java => student/Student.java} | 42 ++--- .../model/student/UniqueStudentList.java | 150 +++++++++++++++ .../DuplicateStudentException.java} | 6 +- .../exceptions/StudentNotFoundException.java | 6 + .../address/model/util/SampleDataUtil.java | 35 ++-- ...tedPerson.java => JsonAdaptedStudent.java} | 47 ++--- .../storage/JsonSerializableAddressBook.java | 18 +- .../seedu/address/ui/PersonListPanel.java | 20 +- .../ui/{PersonCard.java => StudentCard.java} | 25 ++- src/main/resources/view/MainWindow.fxml | 2 +- .../seedu/address/logic/LogicManagerTest.java | 9 +- .../commands/AddCommandIntegrationTest.java | 14 +- .../logic/commands/AddCommandTest.java | 66 +++---- .../logic/commands/CommandTestUtil.java | 28 ++- .../logic/commands/DeleteCommandTest.java | 16 +- .../logic/commands/EditCommandTest.java | 60 +++--- ...st.java => EditStudentDescriptorTest.java} | 29 ++- .../logic/commands/FindCommandTest.java | 4 +- .../logic/parser/AddCommandParserTest.java | 76 +++----- .../logic/parser/AddressBookParserTest.java | 16 +- .../logic/parser/EditCommandParserTest.java | 51 ++--- .../logic/parser/FindCommandParserTest.java | 2 +- .../address/logic/parser/ParserUtilTest.java | 32 +--- .../seedu/address/model/AddressBookTest.java | 31 ++-- .../seedu/address/model/ModelManagerTest.java | 2 +- .../address/model/person/AddressTest.java | 56 ------ .../model/person/UniquePersonListTest.java | 175 ------------------ .../model/{person => student}/EmailTest.java | 2 +- .../NameContainsKeywordsPredicateTest.java | 6 +- .../model/{person => student}/NameTest.java | 2 +- .../model/{person => student}/PhoneTest.java | 2 +- .../StudentTest.java} | 29 ++- .../model/student/UniqueStudentListTest.java | 174 +++++++++++++++++ ...nTest.java => JsonAdaptedStudentTest.java} | 52 ++---- .../address/testutil/AddressBookBuilder.java | 8 +- .../testutil/EditPersonDescriptorBuilder.java | 55 +++--- .../seedu/address/testutil/PersonBuilder.java | 46 ++--- .../seedu/address/testutil/PersonUtil.java | 31 ++-- .../java/seedu/address/testutil/TestUtil.java | 10 +- .../address/testutil/TypicalPersons.java | 57 +++--- 68 files changed, 920 insertions(+), 1248 deletions(-) delete mode 100644 src/main/java/seedu/address/model/person/Address.java delete mode 100644 src/main/java/seedu/address/model/person/UniquePersonList.java delete mode 100644 src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java rename src/main/java/seedu/address/model/{person => student}/Email.java (97%) rename src/main/java/seedu/address/model/{person => student}/Name.java (94%) rename src/main/java/seedu/address/model/{person => student}/NameContainsKeywordsPredicate.java (83%) rename src/main/java/seedu/address/model/{person => student}/Phone.java (93%) rename src/main/java/seedu/address/model/{person/Person.java => student/Student.java} (66%) create mode 100644 src/main/java/seedu/address/model/student/UniqueStudentList.java rename src/main/java/seedu/address/model/{person/exceptions/DuplicatePersonException.java => student/exceptions/DuplicateStudentException.java} (57%) create mode 100644 src/main/java/seedu/address/model/student/exceptions/StudentNotFoundException.java rename src/main/java/seedu/address/storage/{JsonAdaptedPerson.java => JsonAdaptedStudent.java} (59%) rename src/main/java/seedu/address/ui/{PersonCard.java => StudentCard.java} (63%) rename src/test/java/seedu/address/logic/commands/{EditPersonDescriptorTest.java => EditStudentDescriptorTest.java} (62%) delete mode 100644 src/test/java/seedu/address/model/person/AddressTest.java delete mode 100644 src/test/java/seedu/address/model/person/UniquePersonListTest.java rename src/test/java/seedu/address/model/{person => student}/EmailTest.java (99%) rename src/test/java/seedu/address/model/{person => student}/NameContainsKeywordsPredicateTest.java (95%) rename src/test/java/seedu/address/model/{person => student}/NameTest.java (98%) rename src/test/java/seedu/address/model/{person => student}/PhoneTest.java (98%) rename src/test/java/seedu/address/model/{person/PersonTest.java => student/StudentTest.java} (72%) create mode 100644 src/test/java/seedu/address/model/student/UniqueStudentListTest.java rename src/test/java/seedu/address/storage/{JsonAdaptedPersonTest.java => JsonAdaptedStudentTest.java} (58%) diff --git a/LICENSE b/LICENSE index 39b3478982c..3ee16000e96 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 student 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 students 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.md b/docs/DeveloperGuide.md index cc3d1d1ef2f..210801fb36a 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -103,7 +103,7 @@ How the `Logic` component works: 1. When `Logic` is called upon to execute a command, it is passed to an `AddressBookParser` object which in turn creates a parser that matches the command (e.g., `DeleteCommandParser`) and uses it to parse the command. 1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeleteCommand`) which is executed by the `LogicManager`. -1. The command can communicate with the `Model` when it is executed (e.g. to delete a person).
+1. The command can communicate with the `Model` when it is executed (e.g. to delete a student).
Note that although this is shown as a single step in the diagram above (for simplicity), in the code it can take several interactions (between the command object and the `Model`) to achieve. 1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`. @@ -176,11 +176,11 @@ Step 1. The user launches the application for the first time. The `VersionedAddr -Step 2. The user executes `delete 5` command to delete the 5th person in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state. +Step 2. The user executes `delete 5` command to delete the 5th student in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state. -Step 3. The user executes `add n/David …​` to add a new person. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`. +Step 3. The user executes `add n/David …​` to add a new student. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`. @@ -190,7 +190,7 @@ Step 3. The user executes `add n/David …​` to add a new person. The `add` co -Step 4. The user now decides that adding the person was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state. +Step 4. The user now decides that adding the student was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state. @@ -246,7 +246,7 @@ The following activity diagram summarizes what happens when a user executes a ne * **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 student being deleted). * Cons: We must ensure that the implementation of each individual command are correct. _{more aspects and alternatives to be added}_ @@ -792,7 +792,7 @@ unless specified otherwise) ### Non-Functional Requirements 1. Should work on any _mainstream OS_ as long as it has Java `17` or above installed. -2. Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage. +2. Should be able to hold up to 1000 students without a noticeable sluggishness in performance for typical usage. 3. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse. - Business/domain rules: Each student must be uniquely identifiable by their student ID, Assignments must have deadlines that cannot be set on a date that has passed, Each class should not exceed 50 students, Assignments must be submitted by students up to the deadline set by the TA @@ -808,7 +808,7 @@ unless specified otherwise) * **Mainstream OS**: Windows, Linux, Unix, MacOS * **Private contact detail**: A contact detail that is not meant to be shared with others -* **TA** : Abbreviation of Teaching Assistant, a person responsible for assisting instructors in managing courses +* **TA** : Abbreviation of Teaching Assistant, a student responsible for assisting instructors in managing courses * **Class**: A group of students taking the same course assigned to a specific tutorial, sectional, laboratory or recitation which a TA is responsible for. -------------------------------------------------------------------------------------------------------------------- @@ -841,17 +841,17 @@ testers are expected to do more *exploratory* testing. 1. _{ more test cases …​ }_ -### Deleting a person +### Deleting a student -1. Deleting a person while all persons are being shown +1. Deleting a student while all students are being shown - 1. Prerequisites: List all persons using the `list` command. Multiple persons in the list. + 1. Prerequisites: List all students using the `list` command. Multiple students in the list. 1. 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. 1. Test case: `delete 0`
- Expected: No person is deleted. Error details shown in the status message. Status bar remains the same. + Expected: No student is deleted. Error details shown in the status message. Status bar remains the same. 1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)
Expected: Similar to previous. diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 40b69b20484..2aa109e305b 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -75,47 +75,47 @@ Shows a message explaning how to access the help page. Format: `help` -### Adding a person: `add` +### Adding a student: `add` -Adds a person to the address book. +Adds a student to the address book. Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…​` -**Tip:** A person can have any number of tags (including 0) +**Tip:** A student can have any number of tags (including 0) Examples: * `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` * `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 t/criminal` -### Listing all persons : `list` +### Listing all students : `list` -Shows a list of all persons in the address book. +Shows a list of all students in the address book. Format: `list` -### Editing a person : `edit` +### Editing a student : `edit` -Edits an existing person in the address book. +Edits an existing student in the address book. Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]…​` -* Edits the person at the specified `INDEX`. The index refers to the index number shown in the displayed person list. The index **must be a positive integer** 1, 2, 3, …​ +* Edits the student at the specified `INDEX`. The index refers to the index number shown in the displayed student list. The index **must be a positive integer** 1, 2, 3, …​ * At least one of the optional fields must be provided. * Existing values will be updated to the input values. -* When editing tags, the existing tags of the person will be removed i.e adding of tags is not cumulative. -* You can remove all the person’s tags by typing `t/` without +* When editing tags, the existing tags of the student will be removed i.e adding of tags is not cumulative. +* You can remove all the student’s tags by typing `t/` without specifying any tags after it. Examples: -* `edit 1 p/91234567 e/johndoe@example.com` Edits the phone number and email address of the 1st person to be `91234567` and `johndoe@example.com` respectively. -* `edit 2 n/Betsy Crower t/` Edits the name of the 2nd person to be `Betsy Crower` and clears all existing tags. +* `edit 1 p/91234567 e/johndoe@example.com` Edits the phone number and email address of the 1st student to be `91234567` and `johndoe@example.com` respectively. +* `edit 2 n/Betsy Crower t/` Edits the name of the 2nd student to be `Betsy Crower` and clears all existing tags. -### Locating persons by name: `find` +### Locating students by name: `find` -Finds persons whose names contain any of the given keywords. +Finds students whose names contain any of the given keywords. Format: `find KEYWORD [MORE_KEYWORDS]` @@ -131,19 +131,19 @@ Examples: * `find alex david` returns `Alex Yeoh`, `David Li`
![result for 'find alex david'](images/findAlexDavidResult.png) -### Deleting a person : `delete` +### Deleting a student : `delete` -Deletes the specified person from the address book. +Deletes the specified student from the address book. Format: `delete INDEX` -* Deletes the person at the specified `INDEX`. -* The index refers to the index number shown in the displayed person list. +* Deletes the student at the specified `INDEX`. +* The index refers to the index number shown in the displayed student list. * The index **must be a positive integer** 1, 2, 3, …​ Examples: -* `list` followed by `delete 2` deletes the 2nd person in the address book. -* `find Betsy` followed by `delete 1` deletes the 1st person in the results of the `find` command. +* `list` followed by `delete 2` deletes the 2nd student in the address book. +* `find Betsy` followed by `delete 1` deletes the 1st student in the results of the `find` command. ### Clearing all entries : `clear` diff --git a/docs/diagrams/tracing/LogicSequenceDiagram.puml b/docs/diagrams/tracing/LogicSequenceDiagram.puml index 42bf46d3ce8..acbf5532bc4 100644 --- a/docs/diagrams/tracing/LogicSequenceDiagram.puml +++ b/docs/diagrams/tracing/LogicSequenceDiagram.puml @@ -14,7 +14,7 @@ create ecp abp -> ecp abp -> ecp ++: parse(arguments) create ec -ecp -> ec ++: index, editPersonDescriptor +ecp -> ec ++: index, editStudentDescriptor ec --> ecp -- ecp --> abp --: command abp --> logic --: command diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 92cd8fa605a..641d315e68d 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -8,7 +8,7 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * API of the Logic component @@ -31,7 +31,7 @@ public interface Logic { ReadOnlyAddressBook getAddressBook(); /** Returns an unmodifiable view of the filtered list of persons */ - ObservableList getFilteredPersonList(); + ObservableList getFilteredPersonList(); /** * Returns the user prefs' address book file path. diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 5aa3b91c7d0..e5ba9807bab 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -15,7 +15,7 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; import seedu.address.storage.Storage; /** @@ -67,7 +67,7 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { return model.getFilteredPersonList(); } diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index 4bdfabc192c..fdd062ef8bd 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -6,7 +6,7 @@ import seedu.address.logic.parser.Prefix; import seedu.address.model.assignment.Assignment; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * Container for user visible messages. @@ -15,7 +15,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 student index provided is invalid"; public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; public static final String MESSAGE_DUPLICATE_FIELDS = "Multiple values specified for the following single-valued field(s): "; @@ -33,19 +33,17 @@ public static String getErrorMessageForDuplicatePrefixes(Prefix... duplicatePref } /** - * Formats the {@code person} for display to the user. + * Formats the {@code student} for display to the user. */ - public static String format(Person person) { + public static String format(Student student) { final StringBuilder builder = new StringBuilder(); - builder.append(person.getName()) + builder.append(student.getName()) .append("; Phone: ") - .append(person.getPhone()) + .append(student.getPhone()) .append("; Email: ") - .append(person.getEmail()) - .append("; Address: ") - .append(person.getAddress()) + .append(student.getEmail()) .append("; Tags: "); - person.getTags().forEach(builder::append); + student.getTags().forEach(builder::append); return builder.toString(); } /** diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 29cd6ef9cb3..6691acf5ca7 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -1,7 +1,6 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -11,41 +10,39 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** - * Adds a person to the address book. + * Adds a student to the address book. */ public class AddCommand extends Command { public static final String COMMAND_WORD = "add_student"; - 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 student to the address book. " + "Parameters: " + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " - + PREFIX_ADDRESS + "ADDRESS " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com " - + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + 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 student added: %1$s"; + public static final String MESSAGE_DUPLICATE_PERSON = "This student already exists in the address book"; - private final Person toAdd; + private final Student toAdd; /** - * Creates an AddCommand to add the specified {@code Person} + * Creates an AddCommand to add the specified {@code Student} */ - public AddCommand(Person person) { - requireNonNull(person); - toAdd = person; + public AddCommand(Student student) { + requireNonNull(student); + toAdd = student; } @Override diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 1135ac19b74..1062fa39e32 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -9,21 +9,21 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** - * Deletes a person identified using it's displayed index from the address book. + * Deletes a student identified using it's displayed index from the address book. */ public class DeleteCommand extends Command { 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 displayed person list.\n" + + ": Deletes the student identified by the index number used in the displayed student list.\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 Student: %1$s"; private final Index targetIndex; @@ -34,15 +34,15 @@ public DeleteCommand(Index targetIndex) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - Person personToDelete = lastShownList.get(targetIndex.getZeroBased()); - model.deletePerson(personToDelete); - return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete))); + Student studentToDelete = lastShownList.get(targetIndex.getZeroBased()); + model.deletePerson(studentToDelete); + return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(studentToDelete))); } @Override diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 4b581c7331e..f3a955d2ce5 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -1,7 +1,6 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -21,87 +20,84 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; +import seedu.address.model.student.Student; import seedu.address.model.tag.Tag; /** - * Edits the details of an existing person in the address book. + * Edits the details of an existing student in the address book. */ public class EditCommand extends Command { 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 displayed person list. " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the student identified " + + "by the index number used in the displayed student list. " + "Existing values will be overwritten by the input values.\n" + "Parameters: INDEX (must be a positive integer) " + "[" + PREFIX_NAME + "NAME] " + "[" + PREFIX_PHONE + "PHONE] " + "[" + PREFIX_EMAIL + "EMAIL] " - + "[" + PREFIX_ADDRESS + "ADDRESS] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " + 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 Student: %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 student already exists in the address book."; private final Index index; - private final EditPersonDescriptor editPersonDescriptor; + private final EditStudentDescriptor editStudentDescriptor; /** - * @param index of the person in the filtered person list to edit - * @param editPersonDescriptor details to edit the person with + * @param index of the student in the filtered student list to edit + * @param editStudentDescriptor details to edit the student with */ - public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { + public EditCommand(Index index, EditStudentDescriptor editStudentDescriptor) { requireNonNull(index); - requireNonNull(editPersonDescriptor); + requireNonNull(editStudentDescriptor); this.index = index; - this.editPersonDescriptor = new EditPersonDescriptor(editPersonDescriptor); + this.editStudentDescriptor = new EditStudentDescriptor(editStudentDescriptor); } @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (index.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - Person personToEdit = lastShownList.get(index.getZeroBased()); - Person editedPerson = createEditedPerson(personToEdit, editPersonDescriptor); + Student studentToEdit = lastShownList.get(index.getZeroBased()); + Student editedStudent = createEditedPerson(studentToEdit, editStudentDescriptor); - if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) { + if (!studentToEdit.isSamePerson(editedStudent) && model.hasPerson(editedStudent)) { throw new CommandException(MESSAGE_DUPLICATE_PERSON); } - model.setPerson(personToEdit, editedPerson); + model.setPerson(studentToEdit, editedStudent); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson))); + return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent))); } /** - * Creates and returns a {@code Person} with the details of {@code personToEdit} - * edited with {@code editPersonDescriptor}. + * Creates and returns a {@code Student} with the details of {@code studentToEdit} + * edited with {@code editStudentDescriptor}. */ - private static Person createEditedPerson(Person personToEdit, EditPersonDescriptor editPersonDescriptor) { - assert personToEdit != null; + private static Student createEditedPerson(Student studentToEdit, EditStudentDescriptor editStudentDescriptor) { + assert studentToEdit != 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 = editStudentDescriptor.getName().orElse(studentToEdit.getName()); + Phone updatedPhone = editStudentDescriptor.getPhone().orElse(studentToEdit.getPhone()); + Email updatedEmail = editStudentDescriptor.getEmail().orElse(studentToEdit.getEmail()); + Set updatedTags = editStudentDescriptor.getTags().orElse(studentToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Student(updatedName, updatedPhone, updatedEmail, updatedTags); } @Override @@ -117,39 +113,37 @@ public boolean equals(Object other) { EditCommand otherEditCommand = (EditCommand) other; return index.equals(otherEditCommand.index) - && editPersonDescriptor.equals(otherEditCommand.editPersonDescriptor); + && editStudentDescriptor.equals(otherEditCommand.editStudentDescriptor); } @Override public String toString() { return new ToStringBuilder(this) .add("index", index) - .add("editPersonDescriptor", editPersonDescriptor) + .add("editStudentDescriptor", editStudentDescriptor) .toString(); } /** - * 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 student with. Each non-empty field value will replace the + * corresponding field value of the student. */ - public static class EditPersonDescriptor { + public static class EditStudentDescriptor { private Name name; private Phone phone; private Email email; - private Address address; private Set tags; - public EditPersonDescriptor() {} + public EditStudentDescriptor() {} /** * Copy constructor. * A defensive copy of {@code tags} is used internally. */ - public EditPersonDescriptor(EditPersonDescriptor toCopy) { + public EditStudentDescriptor(EditStudentDescriptor toCopy) { setName(toCopy.name); setPhone(toCopy.phone); setEmail(toCopy.email); - setAddress(toCopy.address); setTags(toCopy.tags); } @@ -157,7 +151,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, phone, email, address, tags); + return CollectionUtil.isAnyNonNull(name, phone, email, tags); } public void setName(Name name) { @@ -184,14 +178,6 @@ public Optional getEmail() { return Optional.ofNullable(email); } - public void setAddress(Address address) { - this.address = address; - } - - public Optional
getAddress() { - return Optional.ofNullable(address); - } - /** * Sets {@code tags} to this object's {@code tags}. * A defensive copy of {@code tags} is used internally. @@ -216,16 +202,15 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof EditPersonDescriptor)) { + if (!(other instanceof EditStudentDescriptor)) { return false; } - EditPersonDescriptor otherEditPersonDescriptor = (EditPersonDescriptor) other; - return Objects.equals(name, otherEditPersonDescriptor.name) - && Objects.equals(phone, otherEditPersonDescriptor.phone) - && Objects.equals(email, otherEditPersonDescriptor.email) - && Objects.equals(address, otherEditPersonDescriptor.address) - && Objects.equals(tags, otherEditPersonDescriptor.tags); + EditStudentDescriptor otherEditStudentDescriptor = (EditStudentDescriptor) other; + return Objects.equals(name, otherEditStudentDescriptor.name) + && Objects.equals(phone, otherEditStudentDescriptor.phone) + && Objects.equals(email, otherEditStudentDescriptor.email) + && Objects.equals(tags, otherEditStudentDescriptor.tags); } @Override @@ -234,7 +219,6 @@ public String toString() { .add("name", name) .add("phone", phone) .add("email", email) - .add("address", address) .add("tags", tags) .toString(); } diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 72b9eddd3a7..5a7e8fca79f 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -5,7 +5,7 @@ import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; import seedu.address.model.Model; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.student.NameContainsKeywordsPredicate; /** * Finds and lists all persons in address book whose name contains any of the argument keywords. diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 4ff1a97ed77..84432c8c28c 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -1,7 +1,6 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -12,11 +11,10 @@ import seedu.address.logic.commands.AddCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; +import seedu.address.model.student.Student; import seedu.address.model.tag.Tag; /** @@ -31,23 +29,22 @@ public class AddCommandParser implements Parser { */ public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); - 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); + Student student = new Student(name, phone, email, tagList); - return new AddCommand(person); + return new AddCommand(student); } /** diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 5d64374b9ab..654adc17952 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -9,7 +9,6 @@ public class CliSyntax { public static final Prefix PREFIX_NAME = new Prefix("n/"); public static final Prefix PREFIX_PHONE = new Prefix("p/"); public static final Prefix PREFIX_EMAIL = new Prefix("e/"); - public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); public static final Prefix PREFIX_ASSIGNMENT_NAME = new Prefix("assignmentName/"); public static final Prefix PREFIX_ASSIGNMENT_MAX_SCORE = new Prefix("maxScore/"); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 46b3309a78b..690072f8bbe 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -2,7 +2,6 @@ import static java.util.Objects.requireNonNull; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -15,7 +14,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.tag.Tag; @@ -32,7 +31,7 @@ public class EditCommandParser implements Parser { public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_TAG); Index index; @@ -42,29 +41,26 @@ public EditCommand parse(String args) throws ParseException { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL); - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); + EditStudentDescriptor editStudentDescriptor = new EditCommand.EditStudentDescriptor(); if (argMultimap.getValue(PREFIX_NAME).isPresent()) { - editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get())); + editStudentDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get())); } if (argMultimap.getValue(PREFIX_PHONE).isPresent()) { - editPersonDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get())); + editStudentDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get())); } if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) { - editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); + editStudentDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); } - if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) { - editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get())); - } - parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); + parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editStudentDescriptor::setTags); - if (!editPersonDescriptor.isAnyFieldEdited()) { + if (!editStudentDescriptor.isAnyFieldEdited()) { throw new ParseException(EditCommand.MESSAGE_NOT_EDITED); } - return new EditCommand(index, editPersonDescriptor); + return new EditCommand(index, editStudentDescriptor); } /** diff --git a/src/main/java/seedu/address/logic/parser/FindCommandParser.java b/src/main/java/seedu/address/logic/parser/FindCommandParser.java index 2867bde857b..2bd8263a80e 100644 --- a/src/main/java/seedu/address/logic/parser/FindCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FindCommandParser.java @@ -6,7 +6,7 @@ import seedu.address.logic.commands.FindCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.student.NameContainsKeywordsPredicate; /** * Parses input arguments and creates a new FindCommand object diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 1dfe19c33b9..30d35bc5fce 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -10,10 +10,9 @@ import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.assignment.AssignmentName; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; import seedu.address.model.tag.Tag; /** @@ -66,21 +65,6 @@ public static Phone parsePhone(String phone) throws ParseException { return new Phone(trimmedPhone); } - /** - * Parses a {@code String address} into an {@code Address}. - * Leading and trailing whitespaces will be trimmed. - * - * @throws ParseException if the given {@code address} is invalid. - */ - public static Address parseAddress(String address) throws ParseException { - requireNonNull(address); - String trimmedAddress = address.trim(); - if (!Address.isValidAddress(trimmedAddress)) { - throw new ParseException(Address.MESSAGE_CONSTRAINTS); - } - return new Address(trimmedAddress); - } - /** * Parses a {@code String email} into an {@code Email}. * Leading and trailing whitespaces will be trimmed. diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 11ea37b60b9..474549f6027 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -8,8 +8,8 @@ import seedu.address.commons.util.ToStringBuilder; import seedu.address.model.assignment.Assignment; import seedu.address.model.assignment.UniqueAssignmentList; -import seedu.address.model.person.Person; -import seedu.address.model.person.UniquePersonList; +import seedu.address.model.student.Student; +import seedu.address.model.student.UniqueStudentList; /** @@ -18,7 +18,7 @@ */ public class AddressBook implements ReadOnlyAddressBook { - private final UniquePersonList persons; + private final UniqueStudentList persons; private final UniqueAssignmentList assignments; /* @@ -29,7 +29,7 @@ public class AddressBook implements ReadOnlyAddressBook { * among constructors. */ { - persons = new UniquePersonList(); + persons = new UniqueStudentList(); assignments = new UniqueAssignmentList(); } @@ -46,11 +46,11 @@ public AddressBook(ReadOnlyAddressBook toBeCopied) { //// list overwrite operations /** - * Replaces the contents of the person list with {@code persons}. - * {@code persons} must not contain duplicate persons. + * Replaces the contents of the student list with {@code students}. + * {@code students} must not contain duplicate students. */ - public void setPersons(List persons) { - this.persons.setPersons(persons); + public void setPersons(List students) { + this.persons.setPersons(students); } /** @@ -70,40 +70,40 @@ public void resetData(ReadOnlyAddressBook newData) { setPersons(newData.getPersonList()); } - //// person-level operations + //// student-level operations /** - * Returns true if a person with the same identity as {@code person} exists in the address book. + * Returns true if a student with the same identity as {@code student} exists in the address book. */ - public boolean hasPerson(Person person) { - requireNonNull(person); - return persons.contains(person); + public boolean hasPerson(Student student) { + requireNonNull(student); + return persons.contains(student); } /** - * Adds a person to the address book. - * The person must not already exist in the address book. + * Adds a student to the address book. + * The student must not already exist in the address book. */ - public void addPerson(Person p) { + public void addPerson(Student p) { persons.add(p); } /** - * Replaces the given person {@code target} in the list with {@code editedPerson}. + * Replaces the given student {@code target} in the list with {@code editedStudent}. * {@code target} must exist in the address book. - * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. + * The student identity of {@code editedStudent} must not be the same as another existing student in the address book. */ - public void setPerson(Person target, Person editedPerson) { - requireNonNull(editedPerson); + public void setPerson(Student target, Student editedStudent) { + requireNonNull(editedStudent); - persons.setPerson(target, editedPerson); + persons.setPerson(target, editedStudent); } /** * Removes {@code key} from this {@code AddressBook}. * {@code key} must exist in the address book. */ - public void removePerson(Person key) { + public void removePerson(Student key) { persons.remove(key); } @@ -156,7 +156,7 @@ public String toString() { } @Override - public ObservableList getPersonList() { + public ObservableList getPersonList() { return persons.asUnmodifiableObservableList(); } @Override diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index aa5c78c727f..ca4d0175a97 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -6,14 +6,14 @@ import javafx.collections.ObservableList; import seedu.address.commons.core.GuiSettings; import seedu.address.model.assignment.Assignment; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * 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; /** * Replaces user prefs data with the data in {@code userPrefs}. @@ -54,36 +54,36 @@ public interface Model { ReadOnlyAddressBook getAddressBook(); /** - * Returns true if a person with the same identity as {@code person} exists in the address book. + * Returns true if a student with the same identity as {@code student} exists in the address book. */ - boolean hasPerson(Person person); + boolean hasPerson(Student student); /** - * Deletes the given person. - * The person must exist in the address book. + * Deletes the given student. + * The student must exist in the address book. */ - void deletePerson(Person target); + void deletePerson(Student target); /** - * Adds the given person. - * {@code person} must not already exist in the address book. + * Adds the given student. + * {@code student} must not already exist in the address book. */ - void addPerson(Person person); + void addPerson(Student student); /** - * Replaces the given person {@code target} with {@code editedPerson}. + * Replaces the given student {@code target} with {@code editedStudent}. * {@code target} must exist in the address book. - * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. + * The student identity of {@code editedStudent} must not be the same as another existing student in the address book. */ - void setPerson(Person target, Person editedPerson); + void setPerson(Student target, Student editedStudent); - /** Returns an unmodifiable view of the filtered person list */ - ObservableList getFilteredPersonList(); + /** Returns an unmodifiable view of the filtered student list */ + ObservableList getFilteredPersonList(); /** - * Updates the filter of the filtered person list to filter by the given {@code predicate}. + * Updates the filter of the filtered student list to filter by the given {@code predicate}. * @throws NullPointerException if {@code predicate} is null. */ - void updateFilteredPersonList(Predicate predicate); + void updateFilteredPersonList(Predicate predicate); /** * Adds the given assignment. * {@code Assignment} must not already exist in the address book. diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 901611fde11..5b46efeb1be 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -12,7 +12,7 @@ import seedu.address.commons.core.GuiSettings; import seedu.address.commons.core.LogsCenter; import seedu.address.model.assignment.Assignment; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * Represents the in-memory model of the address book data. @@ -22,7 +22,7 @@ public class ModelManager implements Model { private final AddressBook addressBook; private final UserPrefs userPrefs; - private final FilteredList filteredPersons; + private final FilteredList filteredStudents; /** * Initializes a ModelManager with the given addressBook and userPrefs. @@ -34,7 +34,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs this.addressBook = new AddressBook(addressBook); this.userPrefs = new UserPrefs(userPrefs); - filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); + filteredStudents = new FilteredList<>(this.addressBook.getPersonList()); } public ModelManager() { @@ -89,26 +89,26 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public boolean hasPerson(Person person) { - requireNonNull(person); - return addressBook.hasPerson(person); + public boolean hasPerson(Student student) { + requireNonNull(student); + return addressBook.hasPerson(student); } @Override - public void deletePerson(Person target) { + public void deletePerson(Student target) { addressBook.removePerson(target); } @Override - public void addPerson(Person person) { - addressBook.addPerson(person); + public void addPerson(Student student) { + addressBook.addPerson(student); updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); } @Override - public void setPerson(Person target, Person editedPerson) { - requireAllNonNull(target, editedPerson); + public void setPerson(Student target, Student editedStudent) { + requireAllNonNull(target, editedStudent); - addressBook.setPerson(target, editedPerson); + addressBook.setPerson(target, editedStudent); } @Override public boolean hasAssignment(Assignment assignment) { @@ -121,21 +121,21 @@ public void addAssignment(Assignment assignment) { //will probably need to make some changes to keep track of duplicate assignments } - //=========== Filtered Person List Accessors ============================================================= + //=========== Filtered Student 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 Student} backed by the internal list of * {@code versionedAddressBook} */ @Override - public ObservableList getFilteredPersonList() { - return filteredPersons; + public ObservableList getFilteredPersonList() { + return filteredStudents; } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredPersonList(Predicate predicate) { requireNonNull(predicate); - filteredPersons.setPredicate(predicate); + filteredStudents.setPredicate(predicate); } @Override @@ -152,7 +152,7 @@ public boolean equals(Object other) { ModelManager otherModelManager = (ModelManager) other; return addressBook.equals(otherModelManager.addressBook) && userPrefs.equals(otherModelManager.userPrefs) - && filteredPersons.equals(otherModelManager.filteredPersons); + && filteredStudents.equals(otherModelManager.filteredStudents); } } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index 8462a62d885..1cb3c3b51e7 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -2,7 +2,7 @@ import javafx.collections.ObservableList; import seedu.address.model.assignment.Assignment; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * Unmodifiable view of an address book @@ -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 getPersonList(); ObservableList getAssignmentList(); } diff --git a/src/main/java/seedu/address/model/assignment/exceptions/AssignmentNotFoundException.java b/src/main/java/seedu/address/model/assignment/exceptions/AssignmentNotFoundException.java index 766fa78d87b..800228e027a 100644 --- a/src/main/java/seedu/address/model/assignment/exceptions/AssignmentNotFoundException.java +++ b/src/main/java/seedu/address/model/assignment/exceptions/AssignmentNotFoundException.java @@ -1,6 +1,6 @@ package seedu.address.model.assignment.exceptions; /** - * Signals that the operation is unable to find the specified person. + * Signals that the operation is unable to find the specified student. */ public class AssignmentNotFoundException extends RuntimeException {} diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java deleted file mode 100644 index 469a2cc9a1e..00000000000 --- a/src/main/java/seedu/address/model/person/Address.java +++ /dev/null @@ -1,65 +0,0 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.AppUtil.checkArgument; - -/** - * Represents a Person's address in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} - */ -public class Address { - - public static final String MESSAGE_CONSTRAINTS = "Addresses can take any values, and it should not be blank"; - - /* - * The first character of the address must not be a whitespace, - * otherwise " " (a blank string) becomes a valid input. - */ - public static final String VALIDATION_REGEX = "[^\\s].*"; - - public final String value; - - /** - * Constructs an {@code Address}. - * - * @param address A valid address. - */ - public Address(String address) { - requireNonNull(address); - checkArgument(isValidAddress(address), MESSAGE_CONSTRAINTS); - value = address; - } - - /** - * Returns true if a given string is a valid email. - */ - public static boolean isValidAddress(String test) { - return test.matches(VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof Address)) { - return false; - } - - Address otherAddress = (Address) other; - return value.equals(otherAddress.value); - } - - @Override - public int hashCode() { - return value.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 cc0a68d79f9..00000000000 --- a/src/main/java/seedu/address/model/person/UniquePersonList.java +++ /dev/null @@ -1,150 +0,0 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; - -import java.util.Iterator; -import java.util.List; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -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. - * A person is considered unique by comparing using {@code Person#isSamePerson(Person)}. As such, adding and updating of - * persons uses Person#isSamePerson(Person) for equality so as to ensure that the person being added or updated is - * unique in terms of identity in the UniquePersonList. However, the removal of a person uses Person#equals(Object) so - * as to ensure that the person with exactly the same fields will be removed. - * - * Supports a minimal set of list operations. - * - * @see Person#isSamePerson(Person) - */ -public class UniquePersonList implements Iterable { - - private final ObservableList internalList = FXCollections.observableArrayList(); - private final ObservableList internalUnmodifiableList = - FXCollections.unmodifiableObservableList(internalList); - - /** - * Returns true if the list contains an equivalent person as the given argument. - */ - public boolean contains(Person toCheck) { - requireNonNull(toCheck); - return internalList.stream().anyMatch(toCheck::isSamePerson); - } - - /** - * Adds a person to the list. - * The person must not already exist in the list. - */ - public void add(Person toAdd) { - requireNonNull(toAdd); - if (contains(toAdd)) { - throw new DuplicatePersonException(); - } - internalList.add(toAdd); - } - - /** - * Replaces the person {@code target} in the list with {@code editedPerson}. - * {@code target} must exist in the list. - * The person identity of {@code editedPerson} must not be the same as another existing person in the list. - */ - public void setPerson(Person target, Person editedPerson) { - requireAllNonNull(target, editedPerson); - - int index = internalList.indexOf(target); - if (index == -1) { - throw new PersonNotFoundException(); - } - - if (!target.isSamePerson(editedPerson) && contains(editedPerson)) { - throw new DuplicatePersonException(); - } - - internalList.set(index, editedPerson); - } - - /** - * Removes the equivalent person from the list. - * The person must exist in the list. - */ - public void remove(Person toRemove) { - requireNonNull(toRemove); - if (!internalList.remove(toRemove)) { - throw new PersonNotFoundException(); - } - } - - public void setPersons(UniquePersonList replacement) { - requireNonNull(replacement); - internalList.setAll(replacement.internalList); - } - - /** - * Replaces the contents of this list with {@code persons}. - * {@code persons} must not contain duplicate persons. - */ - public void setPersons(List persons) { - requireAllNonNull(persons); - if (!personsAreUnique(persons)) { - throw new DuplicatePersonException(); - } - - internalList.setAll(persons); - } - - /** - * Returns the backing list as an unmodifiable {@code ObservableList}. - */ - public ObservableList asUnmodifiableObservableList() { - return internalUnmodifiableList; - } - - @Override - public Iterator iterator() { - return internalList.iterator(); - } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof UniquePersonList)) { - return false; - } - - UniquePersonList otherUniquePersonList = (UniquePersonList) other; - return internalList.equals(otherUniquePersonList.internalList); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } - - @Override - public String toString() { - return internalList.toString(); - } - - /** - * Returns true if {@code persons} contains only unique persons. - */ - private boolean personsAreUnique(List persons) { - for (int i = 0; i < persons.size() - 1; i++) { - for (int j = i + 1; j < persons.size(); j++) { - if (persons.get(i).isSamePerson(persons.get(j))) { - return false; - } - } - } - return true; - } -} 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 fa764426ca7..00000000000 --- 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 RuntimeException {} diff --git a/src/main/java/seedu/address/model/person/Email.java b/src/main/java/seedu/address/model/student/Email.java similarity index 97% rename from src/main/java/seedu/address/model/person/Email.java rename to src/main/java/seedu/address/model/student/Email.java index c62e512bc29..88e4f1a4fa7 100644 --- a/src/main/java/seedu/address/model/person/Email.java +++ b/src/main/java/seedu/address/model/student/Email.java @@ -1,10 +1,10 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's email in the address book. + * Represents a Student's email in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} */ public class Email { diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/student/Name.java similarity index 94% rename from src/main/java/seedu/address/model/person/Name.java rename to src/main/java/seedu/address/model/student/Name.java index 173f15b9b00..7379cdca9a2 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/student/Name.java @@ -1,10 +1,10 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's name in the address book. + * Represents a Student's name in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} */ public class Name { diff --git a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/student/NameContainsKeywordsPredicate.java similarity index 83% rename from src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java rename to src/main/java/seedu/address/model/student/NameContainsKeywordsPredicate.java index 62d19be2977..cd97267de2d 100644 --- a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/student/NameContainsKeywordsPredicate.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.student; import java.util.List; import java.util.function.Predicate; @@ -7,9 +7,9 @@ import seedu.address.commons.util.ToStringBuilder; /** - * Tests that a {@code Person}'s {@code Name} matches any of the keywords given. + * Tests that a {@code Student}'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) { @@ -17,9 +17,9 @@ public NameContainsKeywordsPredicate(List keywords) { } @Override - public boolean test(Person person) { + public boolean test(Student student) { return keywords.stream() - .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword)); + .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(student.getName().fullName, keyword)); } @Override diff --git a/src/main/java/seedu/address/model/person/Phone.java b/src/main/java/seedu/address/model/student/Phone.java similarity index 93% rename from src/main/java/seedu/address/model/person/Phone.java rename to src/main/java/seedu/address/model/student/Phone.java index d733f63d739..7692ab40d8a 100644 --- a/src/main/java/seedu/address/model/person/Phone.java +++ b/src/main/java/seedu/address/model/student/Phone.java @@ -1,10 +1,10 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's phone number in the address book. + * Represents a Student's phone number in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} */ public class Phone { diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/student/Student.java similarity index 66% rename from src/main/java/seedu/address/model/person/Person.java rename to src/main/java/seedu/address/model/student/Student.java index abe8c46b535..f03fd0db03b 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/student/Student.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; @@ -11,29 +11,26 @@ import seedu.address.model.tag.Tag; /** - * Represents a Person in the address book. + * Represents a Student in the address book. * Guarantees: details are present and not null, field values are validated, immutable. */ -public class Person { +public class Student { // Identity fields private final Name name; private final Phone phone; private final Email email; - // Data fields - private final Address address; private final Set tags = new HashSet<>(); /** * 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 Student(Name name, Phone phone, Email email, Set tags) { + requireAllNonNull(name, phone, email, tags); this.name = name; this.phone = phone; this.email = email; - this.address = address; this.tags.addAll(tags); } @@ -49,10 +46,6 @@ public Email getEmail() { return email; } - public Address getAddress() { - return address; - } - /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. @@ -65,13 +58,13 @@ public Set getTags() { * Returns true if both persons have the same name. * This defines a weaker notion of equality between two persons. */ - public boolean isSamePerson(Person otherPerson) { - if (otherPerson == this) { + public boolean isSamePerson(Student otherStudent) { + if (otherStudent == this) { return true; } - return otherPerson != null - && otherPerson.getName().equals(getName()); + return otherStudent != null + && otherStudent.getName().equals(getName()); } /** @@ -85,22 +78,21 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof Person)) { + if (!(other instanceof Student)) { return false; } - Person otherPerson = (Person) other; - return name.equals(otherPerson.name) - && phone.equals(otherPerson.phone) - && email.equals(otherPerson.email) - && address.equals(otherPerson.address) - && tags.equals(otherPerson.tags); + Student otherStudent = (Student) other; + return name.equals(otherStudent.name) + && phone.equals(otherStudent.phone) + && email.equals(otherStudent.email) + && tags.equals(otherStudent.tags); } @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, tags); } @Override @@ -109,9 +101,7 @@ public String toString() { .add("name", name) .add("phone", phone) .add("email", email) - .add("address", address) .add("tags", tags) .toString(); } - } diff --git a/src/main/java/seedu/address/model/student/UniqueStudentList.java b/src/main/java/seedu/address/model/student/UniqueStudentList.java new file mode 100644 index 00000000000..0c7cf115bc5 --- /dev/null +++ b/src/main/java/seedu/address/model/student/UniqueStudentList.java @@ -0,0 +1,150 @@ +package seedu.address.model.student; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import java.util.Iterator; +import java.util.List; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import seedu.address.model.student.exceptions.DuplicateStudentException; +import seedu.address.model.student.exceptions.StudentNotFoundException; + +/** + * A list of persons that enforces uniqueness between its elements and does not allow nulls. + * A student is considered unique by comparing using {@code Student#isSamePerson(Student)}. As such, adding and updating + * of persons uses Student#isSamePerson(Student) for equality so as to ensure that the student being added or updated is + * unique in terms of identity in the UniqueStudentList. However, the removal of a student uses Student#equals(Object) + * so as to ensure that the student with exactly the same fields will be removed. + * + * Supports a minimal set of list operations. + * + * @see Student#isSamePerson(Student) + */ +public class UniqueStudentList implements Iterable { + + private final ObservableList internalList = FXCollections.observableArrayList(); + private final ObservableList internalUnmodifiableList = + FXCollections.unmodifiableObservableList(internalList); + + /** + * Returns true if the list contains an equivalent student as the given argument. + */ + public boolean contains(Student toCheck) { + requireNonNull(toCheck); + return internalList.stream().anyMatch(toCheck::isSamePerson); + } + + /** + * Adds a student to the list. + * The student must not already exist in the list. + */ + public void add(Student toAdd) { + requireNonNull(toAdd); + if (contains(toAdd)) { + throw new DuplicateStudentException(); + } + internalList.add(toAdd); + } + + /** + * Replaces the student {@code target} in the list with {@code editedStudent}. + * {@code target} must exist in the list. + * The student identity of {@code editedStudent} must not be the same as another existing student in the list. + */ + public void setPerson(Student target, Student editedStudent) { + requireAllNonNull(target, editedStudent); + + int index = internalList.indexOf(target); + if (index == -1) { + throw new StudentNotFoundException(); + } + + if (!target.isSamePerson(editedStudent) && contains(editedStudent)) { + throw new DuplicateStudentException(); + } + + internalList.set(index, editedStudent); + } + + /** + * Removes the equivalent student from the list. + * The student must exist in the list. + */ + public void remove(Student toRemove) { + requireNonNull(toRemove); + if (!internalList.remove(toRemove)) { + throw new StudentNotFoundException(); + } + } + + public void setPersons(UniqueStudentList replacement) { + requireNonNull(replacement); + internalList.setAll(replacement.internalList); + } + + /** + * Replaces the contents of this list with {@code students}. + * {@code students} must not contain duplicate students. + */ + public void setPersons(List students) { + requireAllNonNull(students); + if (!personsAreUnique(students)) { + throw new DuplicateStudentException(); + } + + internalList.setAll(students); + } + + /** + * Returns the backing list as an unmodifiable {@code ObservableList}. + */ + public ObservableList asUnmodifiableObservableList() { + return internalUnmodifiableList; + } + + @Override + public Iterator iterator() { + return internalList.iterator(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof UniqueStudentList)) { + return false; + } + + UniqueStudentList otherUniqueStudentList = (UniqueStudentList) other; + return internalList.equals(otherUniqueStudentList.internalList); + } + + @Override + public int hashCode() { + return internalList.hashCode(); + } + + @Override + public String toString() { + return internalList.toString(); + } + + /** + * Returns true if {@code students} contains only unique students. + */ + private boolean personsAreUnique(List students) { + for (int i = 0; i < students.size() - 1; i++) { + for (int j = i + 1; j < students.size(); j++) { + if (students.get(i).isSamePerson(students.get(j))) { + return false; + } + } + } + return true; + } +} diff --git a/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java b/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java similarity index 57% rename from src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java rename to src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java index d7290f59442..be126bcd35a 100644 --- a/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java +++ b/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java @@ -1,11 +1,11 @@ -package seedu.address.model.person.exceptions; +package seedu.address.model.student.exceptions; /** * Signals that the operation will result in duplicate Persons (Persons are considered duplicates if they have the same * identity). */ -public class DuplicatePersonException extends RuntimeException { - public DuplicatePersonException() { +public class DuplicateStudentException extends RuntimeException { + public DuplicateStudentException() { super("Operation would result in duplicate persons"); } } diff --git a/src/main/java/seedu/address/model/student/exceptions/StudentNotFoundException.java b/src/main/java/seedu/address/model/student/exceptions/StudentNotFoundException.java new file mode 100644 index 00000000000..2b41e9e0296 --- /dev/null +++ b/src/main/java/seedu/address/model/student/exceptions/StudentNotFoundException.java @@ -0,0 +1,6 @@ +package seedu.address.model.student.exceptions; + +/** + * Signals that the operation is unable to find the specified student. + */ +public class StudentNotFoundException extends RuntimeException {} diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 1806da4facf..33f23119161 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -6,44 +6,37 @@ import seedu.address.model.AddressBook; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; +import seedu.address.model.student.Student; 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"), - new Address("Blk 30 Geylang Street 29, #06-40"), + public static Student[] getSamplePersons() { + return new Student[] { + new Student(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), getTagSet("friends")), - new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), - new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), + new Student(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), getTagSet("colleagues", "friends")), - new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), - new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), + new Student(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), getTagSet("neighbours")), - new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), - new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), + new Student(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), getTagSet("family")), - new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), - new Address("Blk 47 Tampines Street 20, #17-35"), + new Student(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), getTagSet("classmates")), - new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), - new Address("Blk 45 Aljunied Street 85, #11-31"), + new Student(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), getTagSet("colleagues")) }; } public static ReadOnlyAddressBook getSampleAddressBook() { AddressBook sampleAb = new AddressBook(); - for (Person samplePerson : getSamplePersons()) { - sampleAb.addPerson(samplePerson); + for (Student sampleStudent : getSamplePersons()) { + sampleAb.addPerson(sampleStudent); } return sampleAb; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedStudent.java similarity index 59% rename from src/main/java/seedu/address/storage/JsonAdaptedPerson.java rename to src/main/java/seedu/address/storage/JsonAdaptedStudent.java index bd1ca0f56c8..35eaf67b4db 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedStudent.java @@ -10,61 +10,57 @@ import com.fasterxml.jackson.annotation.JsonProperty; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; +import seedu.address.model.student.Student; import seedu.address.model.tag.Tag; /** - * Jackson-friendly version of {@link Person}. + * Jackson-friendly version of {@link Student}. */ -class JsonAdaptedPerson { +class JsonAdaptedStudent { - public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!"; + public static final String MISSING_FIELD_MESSAGE_FORMAT = "Student's %s field is missing!"; private final String name; private final String phone; private final String email; - private final String address; private final List tags = new ArrayList<>(); /** - * Constructs a {@code JsonAdaptedPerson} with the given person details. + * Constructs a {@code JsonAdaptedStudent} with the given student details. */ @JsonCreator - public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, - @JsonProperty("email") String email, @JsonProperty("address") String address, - @JsonProperty("tags") List tags) { + public JsonAdaptedStudent(@JsonProperty("name") String name, @JsonProperty("phone") String phone, + @JsonProperty("email") String email, + @JsonProperty("tags") List tags) { this.name = name; this.phone = phone; this.email = email; - this.address = address; if (tags != null) { this.tags.addAll(tags); } } /** - * Converts a given {@code Person} into this class for Jackson use. + * Converts a given {@code Student} into this class for Jackson use. */ - public JsonAdaptedPerson(Person source) { + public JsonAdaptedStudent(Student source) { name = source.getName().fullName; phone = source.getPhone().value; email = source.getEmail().value; - address = source.getAddress().value; tags.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList())); } /** - * Converts this Jackson-friendly adapted person object into the model's {@code Person} object. + * Converts this Jackson-friendly adapted student object into the model's {@code Student} 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 student. */ - public Person toModelType() throws IllegalValueException { + public Student toModelType() throws IllegalValueException { final List personTags = new ArrayList<>(); for (JsonAdaptedTag tag : tags) { personTags.add(tag.toModelType()); @@ -93,17 +89,8 @@ public Person toModelType() throws IllegalValueException { throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS); } final Email modelEmail = new Email(email); - - if (address == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName())); - } - if (!Address.isValidAddress(address)) { - throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS); - } - final Address modelAddress = new Address(address); - final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags); + return new Student(modelName, modelPhone, modelEmail, modelTags); } } diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index 5efd834091d..5654f7c627d 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -11,7 +11,7 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.AddressBook; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * An Immutable AddressBook that is serializable to JSON format. @@ -19,15 +19,15 @@ @JsonRootName(value = "addressbook") class JsonSerializableAddressBook { - public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; + public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate student(s)."; - private final List persons = new ArrayList<>(); + private final List persons = new ArrayList<>(); /** * Constructs a {@code JsonSerializableAddressBook} with the given persons. */ @JsonCreator - public JsonSerializableAddressBook(@JsonProperty("persons") List persons) { + public JsonSerializableAddressBook(@JsonProperty("persons") List persons) { this.persons.addAll(persons); } @@ -37,7 +37,7 @@ public JsonSerializableAddressBook(@JsonProperty("persons") List { private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); @FXML - private ListView personListView; + private ListView personListView; /** * Creates a {@code PersonListPanel} with the given {@code ObservableList}. */ - public PersonListPanel(ObservableList personList) { + public PersonListPanel(ObservableList studentList) { super(FXML); - personListView.setItems(personList); + personListView.setItems(studentList); personListView.setCellFactory(listView -> new PersonListViewCell()); } /** - * Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. + * Custom {@code ListCell} that displays the graphics of a {@code Student} using a {@code StudentCard}. */ - class PersonListViewCell extends ListCell { + class PersonListViewCell extends ListCell { @Override - protected void updateItem(Person person, boolean empty) { - super.updateItem(person, empty); + protected void updateItem(Student student, boolean empty) { + super.updateItem(student, empty); - if (empty || person == null) { + if (empty || student == null) { setGraphic(null); setText(null); } else { - setGraphic(new PersonCard(person, getIndex() + 1).getRoot()); + setGraphic(new StudentCard(student, getIndex() + 1).getRoot()); } } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/StudentCard.java similarity index 63% rename from src/main/java/seedu/address/ui/PersonCard.java rename to src/main/java/seedu/address/ui/StudentCard.java index 094c42cda82..00f2d13db07 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/StudentCard.java @@ -7,12 +7,12 @@ 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.student.Student; /** - * An UI component that displays information of a {@code Person}. + * An UI component that displays information of a {@code Student}. */ -public class PersonCard extends UiPart { +public class StudentCard extends UiPart { private static final String FXML = "PersonListCard.fxml"; @@ -24,7 +24,7 @@ public class PersonCard extends UiPart { * @see The issue on AddressBook level 4 */ - public final Person person; + public final Student student; @FXML private HBox cardPane; @@ -35,24 +35,21 @@ public class PersonCard extends UiPart { @FXML private Label phone; @FXML - private Label address; - @FXML private Label email; @FXML private FlowPane tags; /** - * Creates a {@code PersonCode} with the given {@code Person} and index to display. + * Creates a {@code PersonCode} with the given {@code Student} and index to display. */ - public PersonCard(Person person, int displayedIndex) { + public StudentCard(Student student, int displayedIndex) { super(FXML); - this.person = person; + this.student = student; 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().stream() + name.setText(student.getName().fullName); + phone.setText(student.getPhone().value); + email.setText(student.getEmail().value); + student.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 7778f666a0a..7052021b691 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -46,7 +46,7 @@ - + diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index baf8ce336a2..9d5b25f34d5 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; @@ -27,7 +26,7 @@ import seedu.address.model.ModelManager; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; import seedu.address.storage.JsonAddressBookStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.StorageManager; @@ -166,10 +165,10 @@ public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) // Triggers the saveAddressBook method by executing an add command String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; - Person expectedPerson = new PersonBuilder(AMY).withTags().build(); + + EMAIL_DESC_AMY; + Student expectedStudent = new PersonBuilder(AMY).withTags().build(); ModelManager expectedModel = new ModelManager(); - expectedModel.addPerson(expectedPerson); + expectedModel.addPerson(expectedStudent); assertCommandFailure(addCommand, CommandException.class, expectedMessage, expectedModel); } } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java index 162a0c86031..2e6badb274a 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java @@ -11,7 +11,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.student.Student; import seedu.address.testutil.PersonBuilder; /** @@ -28,20 +28,20 @@ public void setUp() { @Test public void execute_newPerson_success() { - Person validPerson = new PersonBuilder().build(); + Student validStudent = new PersonBuilder().build(); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.addPerson(validPerson); + expectedModel.addPerson(validStudent); - assertCommandSuccess(new AddCommand(validPerson), model, - String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validPerson)), + assertCommandSuccess(new AddCommand(validStudent), model, + String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validStudent)), expectedModel); } @Test public void execute_duplicatePerson_throwsCommandException() { - Person personInList = model.getAddressBook().getPersonList().get(0); - assertCommandFailure(new AddCommand(personInList), model, + Student studentInList = model.getAddressBook().getPersonList().get(0); + assertCommandFailure(new AddCommand(studentInList), model, AddCommand.MESSAGE_DUPLICATE_PERSON); } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index b47b4350aa4..6f7d4186816 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -23,7 +23,7 @@ import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.assignment.Assignment; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; import seedu.address.testutil.PersonBuilder; public class AddCommandTest { @@ -36,28 +36,28 @@ public void constructor_nullPerson_throwsNullPointerException() { @Test public void execute_personAcceptedByModel_addSuccessful() throws Exception { ModelStubAcceptingPersonAdded modelStub = new ModelStubAcceptingPersonAdded(); - Person validPerson = new PersonBuilder().build(); + Student validStudent = new PersonBuilder().build(); - CommandResult commandResult = new AddCommand(validPerson).execute(modelStub); + CommandResult commandResult = new AddCommand(validStudent).execute(modelStub); - assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validPerson)), + assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validStudent)), commandResult.getFeedbackToUser()); - assertEquals(Arrays.asList(validPerson), modelStub.personsAdded); + assertEquals(Arrays.asList(validStudent), modelStub.personsAdded); } @Test public void execute_duplicatePerson_throwsCommandException() { - Person validPerson = new PersonBuilder().build(); - AddCommand addCommand = new AddCommand(validPerson); - ModelStub modelStub = new ModelStubWithPerson(validPerson); + Student validStudent = new PersonBuilder().build(); + AddCommand addCommand = new AddCommand(validStudent); + ModelStub modelStub = new ModelStubWithPerson(validStudent); assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_PERSON, () -> addCommand.execute(modelStub)); } @Test public void equals() { - Person alice = new PersonBuilder().withName("Alice").build(); - Person bob = new PersonBuilder().withName("Bob").build(); + Student alice = new PersonBuilder().withName("Alice").build(); + Student bob = new PersonBuilder().withName("Bob").build(); AddCommand addAliceCommand = new AddCommand(alice); AddCommand addBobCommand = new AddCommand(bob); @@ -74,7 +74,7 @@ public void equals() { // null -> returns false assertFalse(addAliceCommand.equals(null)); - // different person -> returns false + // different student -> returns false assertFalse(addAliceCommand.equals(addBobCommand)); } @@ -120,7 +120,7 @@ public void setAddressBookFilePath(Path addressBookFilePath) { } @Override - public void addPerson(Person person) { + public void addPerson(Student student) { throw new AssertionError("This method should not be called."); } @@ -140,7 +140,7 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public boolean hasPerson(Person person) { + public boolean hasPerson(Student student) { throw new AssertionError("This method should not be called."); } @@ -150,60 +150,60 @@ public boolean hasAssignment(Assignment assignment) { } @Override - public void deletePerson(Person target) { + public void deletePerson(Student target) { throw new AssertionError("This method should not be called."); } @Override - public void setPerson(Person target, Person editedPerson) { + public void setPerson(Student target, Student editedStudent) { throw new AssertionError("This method should not be called."); } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { throw new AssertionError("This method should not be called."); } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredPersonList(Predicate predicate) { throw new AssertionError("This method should not be called."); } } /** - * A Model stub that contains a single person. + * A Model stub that contains a single student. */ private class ModelStubWithPerson extends ModelStub { - private final Person person; + private final Student student; - ModelStubWithPerson(Person person) { - requireNonNull(person); - this.person = person; + ModelStubWithPerson(Student student) { + requireNonNull(student); + this.student = student; } @Override - public boolean hasPerson(Person person) { - requireNonNull(person); - return this.person.isSamePerson(person); + public boolean hasPerson(Student student) { + requireNonNull(student); + return this.student.isSamePerson(student); } } /** - * A Model stub that always accept the person being added. + * A Model stub that always accept the student being added. */ private class ModelStubAcceptingPersonAdded extends ModelStub { - final ArrayList personsAdded = new ArrayList<>(); + final ArrayList personsAdded = new ArrayList<>(); @Override - public boolean hasPerson(Person person) { - requireNonNull(person); - return personsAdded.stream().anyMatch(person::isSamePerson); + public boolean hasPerson(Student student) { + requireNonNull(student); + return personsAdded.stream().anyMatch(student::isSamePerson); } @Override - public void addPerson(Person person) { - requireNonNull(person); - personsAdded.add(person); + public void addPerson(Student student) { + requireNonNull(student); + personsAdded.add(student); } @Override diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 643a1d08069..92fef29f929 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -17,8 +16,8 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; -import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.Person; +import seedu.address.model.student.NameContainsKeywordsPredicate; +import seedu.address.model.student.Student; import seedu.address.testutil.EditPersonDescriptorBuilder; /** @@ -32,8 +31,6 @@ public class CommandTestUtil { public static final String VALID_PHONE_BOB = "22222222"; public static final String VALID_EMAIL_AMY = "amy@example.com"; public static final String VALID_EMAIL_BOB = "bob@example.com"; - public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1"; - public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3"; public static final String VALID_TAG_HUSBAND = "husband"; public static final String VALID_TAG_FRIEND = "friend"; @@ -43,29 +40,26 @@ public class CommandTestUtil { public static final String PHONE_DESC_BOB = " " + PREFIX_PHONE + VALID_PHONE_BOB; public static final String EMAIL_DESC_AMY = " " + PREFIX_EMAIL + VALID_EMAIL_AMY; public static final String EMAIL_DESC_BOB = " " + PREFIX_EMAIL + VALID_EMAIL_BOB; - public static final String ADDRESS_DESC_AMY = " " + PREFIX_ADDRESS + VALID_ADDRESS_AMY; - public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB; public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND; public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND; public static final String INVALID_NAME_DESC = " " + PREFIX_NAME + "James&"; // '&' not allowed in names public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol - public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags public static final String PREAMBLE_WHITESPACE = "\t \r \n"; public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble"; - public static final EditCommand.EditPersonDescriptor DESC_AMY; - public static final EditCommand.EditPersonDescriptor DESC_BOB; + public static final EditCommand.EditStudentDescriptor DESC_AMY; + public static final EditCommand.EditStudentDescriptor DESC_BOB; static { DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) .withTags(VALID_TAG_FRIEND).build(); DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) + .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); } @@ -99,27 +93,27 @@ 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, filtered person list and selected person in {@code actualModel} remain unchanged + * - the address book, filtered student list and selected student in {@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()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); assertEquals(expectedAddressBook, actualModel.getAddressBook()); assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); } /** - * 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 student 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+"); + Student student = model.getFilteredPersonList().get(targetIndex.getZeroBased()); + final String[] splitName = student.getName().fullName.split("\\s+"); model.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); assertEquals(1, model.getFilteredPersonList().size()); diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index b6f332eabca..99bc83503e7 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -17,7 +17,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.student.Student; /** * Contains integration tests (interaction with the Model) and unit tests for @@ -29,14 +29,14 @@ public class DeleteCommandTest { @Test public void execute_validIndexUnfilteredList_success() { - Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Student studentToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, - Messages.format(personToDelete)); + Messages.format(studentToDelete)); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(personToDelete); + expectedModel.deletePerson(studentToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @@ -53,14 +53,14 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() { public void execute_validIndexFilteredList_success() { showPersonAtIndex(model, INDEX_FIRST_PERSON); - Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Student studentToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, - Messages.format(personToDelete)); + Messages.format(studentToDelete)); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(personToDelete); + expectedModel.deletePerson(studentToDelete); showNoPerson(expectedModel); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); @@ -97,7 +97,7 @@ public void equals() { // null -> returns false assertFalse(deleteFirstCommand.equals(null)); - // different person -> returns false + // different student -> 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 469dd97daa7..25663c00291 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -19,12 +19,12 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.Messages; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; import seedu.address.model.AddressBook; 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.student.Student; import seedu.address.testutil.EditPersonDescriptorBuilder; import seedu.address.testutil.PersonBuilder; @@ -37,14 +37,14 @@ public class EditCommandTest { @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { - Person editedPerson = new PersonBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); + Student editedStudent = new PersonBuilder().build(); + EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder(editedStudent).build(); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.setPerson(model.getFilteredPersonList().get(0), editedStudent); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -52,30 +52,30 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { @Test public void execute_someFieldsSpecifiedUnfilteredList_success() { Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); - Person lastPerson = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); + Student lastStudent = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); - PersonBuilder personInList = new PersonBuilder(lastPerson); - Person editedPerson = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + PersonBuilder personInList = new PersonBuilder(lastStudent); + Student editedStudent = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withTags(VALID_TAG_HUSBAND).build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) + EditCommand.EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_HUSBAND).build(); EditCommand editCommand = new EditCommand(indexLastPerson, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(lastPerson, editedPerson); + expectedModel.setPerson(lastStudent, editedStudent); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test public void execute_noFieldSpecifiedUnfilteredList_success() { - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptor()); - Person editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditStudentDescriptor()); + Student editedStudent = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); @@ -86,23 +86,23 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { public void execute_filteredList_success() { showPersonAtIndex(model, INDEX_FIRST_PERSON); - Person personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - Person editedPerson = new PersonBuilder(personInFilteredList).withName(VALID_NAME_BOB).build(); + Student studentInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Student editedStudent = new PersonBuilder(studentInFilteredList).withName(VALID_NAME_BOB).build(); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.setPerson(model.getFilteredPersonList().get(0), editedStudent); 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(); + Student firstStudent = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditCommand.EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder(firstStudent).build(); EditCommand editCommand = new EditCommand(INDEX_SECOND_PERSON, descriptor); assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); @@ -112,10 +112,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 student in filtered list into a duplicate in address book + Student studentInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, - new EditPersonDescriptorBuilder(personInList).build()); + new EditPersonDescriptorBuilder(studentInList).build()); assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); } @@ -123,7 +123,7 @@ public void execute_duplicatePersonFilteredList_failure() { @Test public void execute_invalidPersonIndexUnfilteredList_failure() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build(); + EditCommand.EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build(); EditCommand editCommand = new EditCommand(outOfBoundIndex, descriptor); assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); @@ -151,7 +151,7 @@ public void equals() { final EditCommand standardCommand = new EditCommand(INDEX_FIRST_PERSON, DESC_AMY); // same values -> returns true - EditPersonDescriptor copyDescriptor = new EditPersonDescriptor(DESC_AMY); + EditStudentDescriptor copyDescriptor = new EditCommand.EditStudentDescriptor(DESC_AMY); EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_PERSON, copyDescriptor); assertTrue(standardCommand.equals(commandWithSameValues)); @@ -174,10 +174,10 @@ public void equals() { @Test public void toStringMethod() { Index index = Index.fromOneBased(1); - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); - EditCommand editCommand = new EditCommand(index, editPersonDescriptor); - String expected = EditCommand.class.getCanonicalName() + "{index=" + index + ", editPersonDescriptor=" - + editPersonDescriptor + "}"; + EditStudentDescriptor editStudentDescriptor = new EditCommand.EditStudentDescriptor(); + EditCommand editCommand = new EditCommand(index, editStudentDescriptor); + String expected = EditCommand.class.getCanonicalName() + "{index=" + index + ", editStudentDescriptor=" + + editStudentDescriptor + "}"; assertEquals(expected, editCommand.toString()); } diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java similarity index 62% rename from src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java rename to src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java index b17c1f3d5c2..8387b3c5ba0 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java @@ -5,7 +5,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; @@ -13,15 +12,14 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; import seedu.address.testutil.EditPersonDescriptorBuilder; -public class EditPersonDescriptorTest { +public class EditStudentDescriptorTest { @Test public void equals() { // same values -> returns true - EditPersonDescriptor descriptorWithSameValues = new EditPersonDescriptor(DESC_AMY); + EditCommand.EditStudentDescriptor descriptorWithSameValues = new EditCommand.EditStudentDescriptor(DESC_AMY); assertTrue(DESC_AMY.equals(descriptorWithSameValues)); // same object -> returns true @@ -37,7 +35,9 @@ public void equals() { assertFalse(DESC_AMY.equals(DESC_BOB)); // different name -> returns false - EditPersonDescriptor editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withName(VALID_NAME_BOB).build(); + EditCommand.EditStudentDescriptor editedAmy = new EditPersonDescriptorBuilder(DESC_AMY) + .withName(VALID_NAME_BOB) + .build(); assertFalse(DESC_AMY.equals(editedAmy)); // different phone -> returns false @@ -48,10 +48,6 @@ public void equals() { editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withEmail(VALID_EMAIL_BOB).build(); assertFalse(DESC_AMY.equals(editedAmy)); - // different address -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withAddress(VALID_ADDRESS_BOB).build(); - assertFalse(DESC_AMY.equals(editedAmy)); - // different tags -> returns false editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_HUSBAND).build(); assertFalse(DESC_AMY.equals(editedAmy)); @@ -59,13 +55,12 @@ public void equals() { @Test public void toStringMethod() { - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); - String expected = EditPersonDescriptor.class.getCanonicalName() + "{name=" - + editPersonDescriptor.getName().orElse(null) + ", phone=" - + editPersonDescriptor.getPhone().orElse(null) + ", email=" - + editPersonDescriptor.getEmail().orElse(null) + ", address=" - + editPersonDescriptor.getAddress().orElse(null) + ", tags=" - + editPersonDescriptor.getTags().orElse(null) + "}"; - assertEquals(expected, editPersonDescriptor.toString()); + EditCommand.EditStudentDescriptor editStudentDescriptor = new EditCommand.EditStudentDescriptor(); + String expected = EditCommand.EditStudentDescriptor.class.getCanonicalName() + "{name=" + + editStudentDescriptor.getName().orElse(null) + ", phone=" + + editStudentDescriptor.getPhone().orElse(null) + ", email=" + + editStudentDescriptor.getEmail().orElse(null) + ", tags=" + + editStudentDescriptor.getTags().orElse(null) + "}"; + assertEquals(expected, editStudentDescriptor.toString()); } } diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index b8b7dbba91a..5b69d78ec12 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -18,7 +18,7 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.student.NameContainsKeywordsPredicate; /** * Contains integration tests (interaction with the Model) for {@code FindCommand}. @@ -50,7 +50,7 @@ public void equals() { // null -> returns false assertFalse(findFirstCommand.equals(null)); - // different person -> returns false + // different student -> returns false assertFalse(findFirstCommand.equals(findSecondCommand)); } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 5bc11d3cdaa..ea1625d4764 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -1,11 +1,8 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; @@ -18,13 +15,11 @@ import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -37,11 +32,10 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.AddCommand; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; +import seedu.address.model.student.Student; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; @@ -50,25 +44,25 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { - Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND).build(); + Student expectedStudent = new PersonBuilder(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)); + + TAG_DESC_FRIEND, new AddCommand(expectedStudent)); // multiple tags - all accepted - Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) + Student expectedStudentMultipleTags = new PersonBuilder(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)); + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + new AddCommand(expectedStudentMultipleTags)); } @Test public void parse_repeatedNonTagValue_failure() { String validExpectedPersonString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND; + + TAG_DESC_FRIEND; // multiple names assertParseFailure(parser, NAME_DESC_AMY + validExpectedPersonString, @@ -82,15 +76,11 @@ public void parse_repeatedNonTagValue_failure() { assertParseFailure(parser, EMAIL_DESC_AMY + validExpectedPersonString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMAIL)); - // multiple addresses - assertParseFailure(parser, ADDRESS_DESC_AMY + validExpectedPersonString, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_ADDRESS)); - // multiple fields repeated assertParseFailure(parser, - validExpectedPersonString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY + ADDRESS_DESC_AMY + validExpectedPersonString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY + validExpectedPersonString, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_ADDRESS, PREFIX_EMAIL, PREFIX_PHONE)); + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_EMAIL, PREFIX_PHONE)); // invalid value followed by valid value @@ -106,10 +96,6 @@ public void parse_repeatedNonTagValue_failure() { assertParseFailure(parser, INVALID_PHONE_DESC + validExpectedPersonString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); - // invalid address - assertParseFailure(parser, INVALID_ADDRESS_DESC + validExpectedPersonString, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_ADDRESS)); - // valid value followed by invalid value // invalid name @@ -123,18 +109,14 @@ public void parse_repeatedNonTagValue_failure() { // invalid phone assertParseFailure(parser, validExpectedPersonString + INVALID_PHONE_DESC, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); - - // invalid address - assertParseFailure(parser, validExpectedPersonString + INVALID_ADDRESS_DESC, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_ADDRESS)); } @Test public void parse_optionalFieldsMissing_success() { // zero tags - Person expectedPerson = new PersonBuilder(AMY).withTags().build(); - assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY, - new AddCommand(expectedPerson)); + Student expectedStudent = new PersonBuilder(AMY).withTags().build(); + assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY, + new AddCommand(expectedStudent)); } @Test @@ -142,55 +124,47 @@ public void parse_compulsoryFieldMissing_failure() { String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE); // missing name prefix - assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, + assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB, expectedMessage); // missing phone prefix - assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, + assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB, expectedMessage); // missing email prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB, - expectedMessage); - - // missing address prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB, + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB, expectedMessage); // all prefixes missing - assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB, + assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB, expectedMessage); } @Test public void parse_invalidValue_failure() { // invalid name - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Name.MESSAGE_CONSTRAINTS); // invalid phone - assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_CONSTRAINTS); // invalid email - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Email.MESSAGE_CONSTRAINTS); - // invalid address - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); - // invalid tag - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_TAG_DESC + VALID_TAG_FRIEND, Tag.MESSAGE_CONSTRAINTS); // two invalid values, only first invalid value reported - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC, + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + INVALID_EMAIL_DESC, Name.MESSAGE_CONSTRAINTS); // non-empty preamble assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } } diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 5a1ab3dbc0c..2291432d3b8 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -17,14 +17,14 @@ import seedu.address.logic.commands.ClearCommand; import seedu.address.logic.commands.DeleteCommand; import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.Person; +import seedu.address.model.student.NameContainsKeywordsPredicate; +import seedu.address.model.student.Student; import seedu.address.testutil.EditPersonDescriptorBuilder; import seedu.address.testutil.PersonBuilder; import seedu.address.testutil.PersonUtil; @@ -35,9 +35,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); + Student student = new PersonBuilder().build(); + AddCommand command = (AddCommand) parser.parseCommand(PersonUtil.getAddCommand(student)); + assertEquals(new AddCommand(student), command); } @Test @@ -55,8 +55,8 @@ public void parseCommand_delete() throws Exception { @Test public void parseCommand_edit() throws Exception { - Person person = new PersonBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build(); + Student student = new PersonBuilder().build(); + EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder(student).build(); EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + " " + PersonUtil.getEditPersonDescriptorDetails(descriptor)); 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 cc7175172d4..99dfefb69cd 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -1,11 +1,8 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; @@ -15,14 +12,12 @@ import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -37,11 +32,10 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.Messages; import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; import seedu.address.model.tag.Tag; import seedu.address.testutil.EditPersonDescriptorBuilder; @@ -86,20 +80,19 @@ public void parse_invalidValue_failure() { assertParseFailure(parser, "1" + INVALID_NAME_DESC, Name.MESSAGE_CONSTRAINTS); // invalid name assertParseFailure(parser, "1" + INVALID_PHONE_DESC, Phone.MESSAGE_CONSTRAINTS); // invalid phone assertParseFailure(parser, "1" + INVALID_EMAIL_DESC, Email.MESSAGE_CONSTRAINTS); // invalid email - assertParseFailure(parser, "1" + INVALID_ADDRESS_DESC, Address.MESSAGE_CONSTRAINTS); // invalid address assertParseFailure(parser, "1" + INVALID_TAG_DESC, Tag.MESSAGE_CONSTRAINTS); // invalid tag // invalid phone followed by valid email assertParseFailure(parser, "1" + INVALID_PHONE_DESC + EMAIL_DESC_AMY, Phone.MESSAGE_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 Student} 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_CONSTRAINTS); assertParseFailure(parser, "1" + TAG_DESC_FRIEND + TAG_EMPTY + TAG_DESC_HUSBAND, Tag.MESSAGE_CONSTRAINTS); assertParseFailure(parser, "1" + TAG_EMPTY + TAG_DESC_FRIEND + TAG_DESC_HUSBAND, Tag.MESSAGE_CONSTRAINTS); // multiple invalid values, but only the first invalid value is captured - assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_ADDRESS_AMY + VALID_PHONE_AMY, + assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_PHONE_AMY, Name.MESSAGE_CONSTRAINTS); } @@ -107,10 +100,10 @@ public void parse_invalidValue_failure() { public void parse_allFieldsSpecified_success() { Index targetIndex = INDEX_SECOND_PERSON; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + TAG_DESC_HUSBAND - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; + + EMAIL_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) + .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); @@ -122,7 +115,7 @@ public void parse_someFieldsSpecified_success() { Index targetIndex = INDEX_FIRST_PERSON; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + EMAIL_DESC_AMY; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_PHONE_BOB) + EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_AMY).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); @@ -134,7 +127,7 @@ public void parse_oneFieldSpecified_success() { // name Index targetIndex = INDEX_THIRD_PERSON; String userInput = targetIndex.getOneBased() + NAME_DESC_AMY; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY).build(); + EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); @@ -150,12 +143,6 @@ public void parse_oneFieldSpecified_success() { expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); - // address - userInput = targetIndex.getOneBased() + ADDRESS_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withAddress(VALID_ADDRESS_AMY).build(); - expectedCommand = new EditCommand(targetIndex, descriptor); - assertParseSuccess(parser, userInput, expectedCommand); - // tags userInput = targetIndex.getOneBased() + TAG_DESC_FRIEND; descriptor = new EditPersonDescriptorBuilder().withTags(VALID_TAG_FRIEND).build(); @@ -180,19 +167,19 @@ public void parse_multipleRepeatedFields_failure() { assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); // mulltiple valid fields repeated - userInput = targetIndex.getOneBased() + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY - + TAG_DESC_FRIEND + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY + TAG_DESC_FRIEND - + PHONE_DESC_BOB + ADDRESS_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND; + userInput = targetIndex.getOneBased() + PHONE_DESC_AMY + EMAIL_DESC_AMY + + TAG_DESC_FRIEND + PHONE_DESC_AMY + EMAIL_DESC_AMY + TAG_DESC_FRIEND + + PHONE_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND; assertParseFailure(parser, userInput, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)); + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL)); // multiple invalid values - userInput = targetIndex.getOneBased() + INVALID_PHONE_DESC + INVALID_ADDRESS_DESC + INVALID_EMAIL_DESC - + INVALID_PHONE_DESC + INVALID_ADDRESS_DESC + INVALID_EMAIL_DESC; + userInput = targetIndex.getOneBased() + INVALID_PHONE_DESC + INVALID_EMAIL_DESC + + INVALID_PHONE_DESC + INVALID_EMAIL_DESC; assertParseFailure(parser, userInput, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)); + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL)); } @Test @@ -200,7 +187,7 @@ public void parse_resetTags_success() { Index targetIndex = INDEX_THIRD_PERSON; String userInput = targetIndex.getOneBased() + TAG_EMPTY; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withTags().build(); + EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withTags().build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java index d92e64d12f9..7161c70351f 100644 --- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.commands.FindCommand; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.student.NameContainsKeywordsPredicate; public class FindCommandParserTest { diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 4256788b1a7..90aa63afaaa 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -14,22 +14,19 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; import seedu.address.model.tag.Tag; public class ParserUtilTest { private static final String INVALID_NAME = "R@chel"; private static final String INVALID_PHONE = "+651234"; - private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_TAG = "#friend"; private static final String VALID_NAME = "Rachel Walker"; private static final String VALID_PHONE = "123456"; - private static final String VALID_ADDRESS = "123 Main Street #0505"; private static final String VALID_EMAIL = "rachel@example.com"; private static final String VALID_TAG_1 = "friend"; private static final String VALID_TAG_2 = "neighbour"; @@ -102,29 +99,6 @@ public void parsePhone_validValueWithWhitespace_returnsTrimmedPhone() throws Exc assertEquals(expectedPhone, ParserUtil.parsePhone(phoneWithWhitespace)); } - @Test - public void parseAddress_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseAddress((String) null)); - } - - @Test - public void parseAddress_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseAddress(INVALID_ADDRESS)); - } - - @Test - public void parseAddress_validValueWithoutWhitespace_returnsAddress() throws Exception { - Address expectedAddress = new Address(VALID_ADDRESS); - assertEquals(expectedAddress, ParserUtil.parseAddress(VALID_ADDRESS)); - } - - @Test - public void parseAddress_validValueWithWhitespace_returnsTrimmedAddress() throws Exception { - String addressWithWhitespace = WHITESPACE + VALID_ADDRESS + WHITESPACE; - Address expectedAddress = new Address(VALID_ADDRESS); - assertEquals(expectedAddress, ParserUtil.parseAddress(addressWithWhitespace)); - } - @Test public void parseEmail_null_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail((String) null)); diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index 1417132c469..cd55a9cd805 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.ALICE; @@ -20,8 +19,8 @@ import javafx.collections.ObservableList; import seedu.address.model.assignment.Assignment; import seedu.address.model.assignment.AssignmentName; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.DuplicatePersonException; +import seedu.address.model.student.Student; +import seedu.address.model.student.exceptions.DuplicateStudentException; import seedu.address.testutil.PersonBuilder; public class AddressBookTest { @@ -47,15 +46,15 @@ public void resetData_withValidReadOnlyAddressBook_replacesData() { @Test public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { - // Two persons with the same identity fields - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + // Two students with the same identity fields + Student editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND) .build(); - List newPersons = Arrays.asList(ALICE, editedAlice); + List newStudents = Arrays.asList(ALICE, editedAlice); List newAssignments = Arrays.asList(new Assignment(new AssignmentName("Assignment1"), 100)); - AddressBookStub newData = new AddressBookStub(newPersons, newAssignments); + AddressBookStub newData = new AddressBookStub(newStudents, newAssignments); - assertThrows(DuplicatePersonException.class, () -> addressBook.resetData(newData)); + assertThrows(DuplicateStudentException.class, () -> addressBook.resetData(newData)); } @Test @@ -77,7 +76,7 @@ public void hasPerson_personInAddressBook_returnsTrue() { @Test public void hasPerson_personWithSameIdentityFieldsInAddressBook_returnsTrue() { addressBook.addPerson(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + Student editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND) .build(); assertTrue(addressBook.hasPerson(editedAlice)); } @@ -90,25 +89,25 @@ public void getPersonList_modifyList_throwsUnsupportedOperationException() { /* Temporarily removed this test as new Assignment was created @Test public void toStringMethod() { - String expected = AddressBook.class.getCanonicalName() + "{persons=" + addressBook.getPersonList() + "}"; + String expected = AddressBook.class.getCanonicalName() + "{students=" + addressBook.getPersonList() + "}"; assertEquals(expected, addressBook.toString()); } */ /** - * A stub ReadOnlyAddressBook whose persons list can violate interface constraints. + * A stub ReadOnlyAddressBook whose students list can violate interface constraints. */ private static class AddressBookStub implements ReadOnlyAddressBook { - private final ObservableList persons = FXCollections.observableArrayList(); + private final ObservableList students = FXCollections.observableArrayList(); private final ObservableList assignments = FXCollections.observableArrayList(); - AddressBookStub(Collection persons, Collection assignments) { - this.persons.setAll(persons); + AddressBookStub(Collection students, Collection assignments) { + this.students.setAll(students); this.assignments.setAll(assignments); } @Override - public ObservableList getPersonList() { - return persons; + public ObservableList getPersonList() { + return students; } @Override diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 2cf1418d116..a416b2f626e 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test; import seedu.address.commons.core.GuiSettings; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.student.NameContainsKeywordsPredicate; import seedu.address.testutil.AddressBookBuilder; public class ModelManagerTest { diff --git a/src/test/java/seedu/address/model/person/AddressTest.java b/src/test/java/seedu/address/model/person/AddressTest.java deleted file mode 100644 index 314885eca26..00000000000 --- a/src/test/java/seedu/address/model/person/AddressTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package seedu.address.model.person; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.testutil.Assert.assertThrows; - -import org.junit.jupiter.api.Test; - -public class AddressTest { - - @Test - public void constructor_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new Address(null)); - } - - @Test - public void constructor_invalidAddress_throwsIllegalArgumentException() { - String invalidAddress = ""; - assertThrows(IllegalArgumentException.class, () -> new Address(invalidAddress)); - } - - @Test - public void isValidAddress() { - // null address - assertThrows(NullPointerException.class, () -> Address.isValidAddress(null)); - - // invalid addresses - assertFalse(Address.isValidAddress("")); // empty string - assertFalse(Address.isValidAddress(" ")); // spaces only - - // valid addresses - assertTrue(Address.isValidAddress("Blk 456, Den Road, #01-355")); - assertTrue(Address.isValidAddress("-")); // one character - assertTrue(Address.isValidAddress("Leng Inc; 1234 Market St; San Francisco CA 2349879; USA")); // long address - } - - @Test - public void equals() { - Address address = new Address("Valid Address"); - - // same values -> returns true - assertTrue(address.equals(new Address("Valid Address"))); - - // same object -> returns true - assertTrue(address.equals(address)); - - // null -> returns false - assertFalse(address.equals(null)); - - // different types -> returns false - assertFalse(address.equals(5.0f)); - - // different values -> returns false - assertFalse(address.equals(new Address("Other Valid Address"))); - } -} diff --git a/src/test/java/seedu/address/model/person/UniquePersonListTest.java b/src/test/java/seedu/address/model/person/UniquePersonListTest.java deleted file mode 100644 index 17ae501df08..00000000000 --- a/src/test/java/seedu/address/model/person/UniquePersonListTest.java +++ /dev/null @@ -1,175 +0,0 @@ -package seedu.address.model.person; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; -import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.ALICE; -import static seedu.address.testutil.TypicalPersons.BOB; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.Test; - -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; -import seedu.address.testutil.PersonBuilder; - -public class UniquePersonListTest { - - private final UniquePersonList uniquePersonList = new UniquePersonList(); - - @Test - public void contains_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.contains(null)); - } - - @Test - public void contains_personNotInList_returnsFalse() { - assertFalse(uniquePersonList.contains(ALICE)); - } - - @Test - public void contains_personInList_returnsTrue() { - uniquePersonList.add(ALICE); - assertTrue(uniquePersonList.contains(ALICE)); - } - - @Test - public void contains_personWithSameIdentityFieldsInList_returnsTrue() { - uniquePersonList.add(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) - .build(); - assertTrue(uniquePersonList.contains(editedAlice)); - } - - @Test - public void add_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.add(null)); - } - - @Test - public void add_duplicatePerson_throwsDuplicatePersonException() { - uniquePersonList.add(ALICE); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.add(ALICE)); - } - - @Test - public void setPerson_nullTargetPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPerson(null, ALICE)); - } - - @Test - public void setPerson_nullEditedPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPerson(ALICE, null)); - } - - @Test - public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() { - assertThrows(PersonNotFoundException.class, () -> uniquePersonList.setPerson(ALICE, ALICE)); - } - - @Test - public void setPerson_editedPersonIsSamePerson_success() { - uniquePersonList.add(ALICE); - uniquePersonList.setPerson(ALICE, ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(ALICE); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPerson_editedPersonHasSameIdentity_success() { - uniquePersonList.add(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) - .build(); - uniquePersonList.setPerson(ALICE, editedAlice); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(editedAlice); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPerson_editedPersonHasDifferentIdentity_success() { - uniquePersonList.add(ALICE); - uniquePersonList.setPerson(ALICE, BOB); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() { - uniquePersonList.add(ALICE); - uniquePersonList.add(BOB); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPerson(ALICE, BOB)); - } - - @Test - public void remove_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.remove(null)); - } - - @Test - public void remove_personDoesNotExist_throwsPersonNotFoundException() { - assertThrows(PersonNotFoundException.class, () -> uniquePersonList.remove(ALICE)); - } - - @Test - public void remove_existingPerson_removesPerson() { - uniquePersonList.add(ALICE); - uniquePersonList.remove(ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPersons_nullUniquePersonList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((UniquePersonList) null)); - } - - @Test - public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonList() { - uniquePersonList.add(ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - uniquePersonList.setPersons(expectedUniquePersonList); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPersons_nullList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((List) null)); - } - - @Test - public void setPersons_list_replacesOwnListWithProvidedList() { - uniquePersonList.add(ALICE); - List personList = Collections.singletonList(BOB); - uniquePersonList.setPersons(personList); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - assertEquals(expectedUniquePersonList, uniquePersonList); - } - - @Test - public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() { - List listWithDuplicatePersons = Arrays.asList(ALICE, ALICE); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPersons(listWithDuplicatePersons)); - } - - @Test - public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () - -> uniquePersonList.asUnmodifiableObservableList().remove(0)); - } - - @Test - public void toStringMethod() { - assertEquals(uniquePersonList.asUnmodifiableObservableList().toString(), uniquePersonList.toString()); - } -} diff --git a/src/test/java/seedu/address/model/person/EmailTest.java b/src/test/java/seedu/address/model/student/EmailTest.java similarity index 99% rename from src/test/java/seedu/address/model/person/EmailTest.java rename to src/test/java/seedu/address/model/student/EmailTest.java index f08cdff0a64..69cb7d61e60 100644 --- a/src/test/java/seedu/address/model/person/EmailTest.java +++ b/src/test/java/seedu/address/model/student/EmailTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java similarity index 95% rename from src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java rename to src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java index 6b3fd90ade7..9d6caecd9b1 100644 --- a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java +++ b/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -35,7 +35,7 @@ public void equals() { // null -> returns false assertFalse(firstPredicate.equals(null)); - // different person -> returns false + // different student -> returns false assertFalse(firstPredicate.equals(secondPredicate)); } @@ -71,7 +71,7 @@ public void test_nameDoesNotContainKeywords_returnsFalse() { // 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") - .withEmail("alice@email.com").withAddress("Main Street").build())); + .withEmail("alice@email.com").build())); } @Test diff --git a/src/test/java/seedu/address/model/person/NameTest.java b/src/test/java/seedu/address/model/student/NameTest.java similarity index 98% rename from src/test/java/seedu/address/model/person/NameTest.java rename to src/test/java/seedu/address/model/student/NameTest.java index 94e3dd726bd..227d3e36159 100644 --- a/src/test/java/seedu/address/model/person/NameTest.java +++ b/src/test/java/seedu/address/model/student/NameTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/seedu/address/model/person/PhoneTest.java b/src/test/java/seedu/address/model/student/PhoneTest.java similarity index 98% rename from src/test/java/seedu/address/model/person/PhoneTest.java rename to src/test/java/seedu/address/model/student/PhoneTest.java index deaaa5ba190..752c58f93d9 100644 --- a/src/test/java/seedu/address/model/person/PhoneTest.java +++ b/src/test/java/seedu/address/model/student/PhoneTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/student/StudentTest.java similarity index 72% rename from src/test/java/seedu/address/model/person/PersonTest.java rename to src/test/java/seedu/address/model/student/StudentTest.java index 31a10d156c9..3eb82b51ee5 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/student/StudentTest.java @@ -1,9 +1,8 @@ -package seedu.address.model.person; +package seedu.address.model.student; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; @@ -16,12 +15,12 @@ import seedu.address.testutil.PersonBuilder; -public class PersonTest { +public class StudentTest { @Test public void asObservableList_modifyList_throwsUnsupportedOperationException() { - Person person = new PersonBuilder().build(); - assertThrows(UnsupportedOperationException.class, () -> person.getTags().remove(0)); + Student student = new PersonBuilder().build(); + assertThrows(UnsupportedOperationException.class, () -> student.getTags().remove(0)); } @Test @@ -33,8 +32,8 @@ public void isSamePerson() { assertFalse(ALICE.isSamePerson(null)); // same name, all other attributes different -> returns true - Person editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) - .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND).build(); + Student editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) + .withTags(VALID_TAG_HUSBAND).build(); assertTrue(ALICE.isSamePerson(editedAlice)); // different name, all other attributes same -> returns false @@ -42,7 +41,7 @@ public void isSamePerson() { assertFalse(ALICE.isSamePerson(editedAlice)); // name differs in case, all other attributes same -> returns false - Person editedBob = new PersonBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); + Student editedBob = new PersonBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); assertFalse(BOB.isSamePerson(editedBob)); // name has trailing spaces, all other attributes same -> returns false @@ -54,7 +53,7 @@ public void isSamePerson() { @Test public void equals() { // same values -> returns true - Person aliceCopy = new PersonBuilder(ALICE).build(); + Student aliceCopy = new PersonBuilder(ALICE).build(); assertTrue(ALICE.equals(aliceCopy)); // same object -> returns true @@ -66,11 +65,11 @@ public void equals() { // different type -> returns false assertFalse(ALICE.equals(5)); - // different person -> returns false + // different student -> returns false assertFalse(ALICE.equals(BOB)); // different name -> returns false - Person editedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build(); + Student editedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build(); assertFalse(ALICE.equals(editedAlice)); // different phone -> returns false @@ -81,10 +80,6 @@ public void equals() { editedAlice = new PersonBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build(); assertFalse(ALICE.equals(editedAlice)); - // different address -> returns false - editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build(); - assertFalse(ALICE.equals(editedAlice)); - // different tags -> returns false editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build(); assertFalse(ALICE.equals(editedAlice)); @@ -92,8 +87,8 @@ public void equals() { @Test public void toStringMethod() { - String expected = Person.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone() - + ", email=" + ALICE.getEmail() + ", address=" + ALICE.getAddress() + ", tags=" + ALICE.getTags() + "}"; + String expected = Student.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone() + + ", email=" + ALICE.getEmail() + ", tags=" + ALICE.getTags() + "}"; assertEquals(expected, ALICE.toString()); } } diff --git a/src/test/java/seedu/address/model/student/UniqueStudentListTest.java b/src/test/java/seedu/address/model/student/UniqueStudentListTest.java new file mode 100644 index 00000000000..f1944f6d609 --- /dev/null +++ b/src/test/java/seedu/address/model/student/UniqueStudentListTest.java @@ -0,0 +1,174 @@ +package seedu.address.model.student; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.testutil.Assert.assertThrows; +import static seedu.address.testutil.TypicalPersons.ALICE; +import static seedu.address.testutil.TypicalPersons.BOB; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.api.Test; + +import seedu.address.model.student.exceptions.DuplicateStudentException; +import seedu.address.model.student.exceptions.StudentNotFoundException; +import seedu.address.testutil.PersonBuilder; + +public class UniqueStudentListTest { + + private final UniqueStudentList uniqueStudentList = new UniqueStudentList(); + + @Test + public void contains_nullPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.contains(null)); + } + + @Test + public void contains_personNotInList_returnsFalse() { + assertFalse(uniqueStudentList.contains(ALICE)); + } + + @Test + public void contains_personInList_returnsTrue() { + uniqueStudentList.add(ALICE); + assertTrue(uniqueStudentList.contains(ALICE)); + } + + @Test + public void contains_personWithSameIdentityFieldsInList_returnsTrue() { + uniqueStudentList.add(ALICE); + Student editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + .build(); + assertTrue(uniqueStudentList.contains(editedAlice)); + } + + @Test + public void add_nullPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.add(null)); + } + + @Test + public void add_duplicatePerson_throwsDuplicatePersonException() { + uniqueStudentList.add(ALICE); + assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.add(ALICE)); + } + + @Test + public void setPerson_nullTargetPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setPerson(null, ALICE)); + } + + @Test + public void setPerson_nullEditedPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setPerson(ALICE, null)); + } + + @Test + public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() { + assertThrows(StudentNotFoundException.class, () -> uniqueStudentList.setPerson(ALICE, ALICE)); + } + + @Test + public void setPerson_editedPersonIsSamePerson_success() { + uniqueStudentList.add(ALICE); + uniqueStudentList.setPerson(ALICE, ALICE); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(ALICE); + assertEquals(expectedUniqueStudentList, uniqueStudentList); + } + + @Test + public void setPerson_editedPersonHasSameIdentity_success() { + uniqueStudentList.add(ALICE); + Student editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + .build(); + uniqueStudentList.setPerson(ALICE, editedAlice); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(editedAlice); + assertEquals(expectedUniqueStudentList, uniqueStudentList); + } + + @Test + public void setPerson_editedPersonHasDifferentIdentity_success() { + uniqueStudentList.add(ALICE); + uniqueStudentList.setPerson(ALICE, BOB); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(BOB); + assertEquals(expectedUniqueStudentList, uniqueStudentList); + } + + @Test + public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() { + uniqueStudentList.add(ALICE); + uniqueStudentList.add(BOB); + assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.setPerson(ALICE, BOB)); + } + + @Test + public void remove_nullPerson_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.remove(null)); + } + + @Test + public void remove_personDoesNotExist_throwsPersonNotFoundException() { + assertThrows(StudentNotFoundException.class, () -> uniqueStudentList.remove(ALICE)); + } + + @Test + public void remove_existingPerson_removesPerson() { + uniqueStudentList.add(ALICE); + uniqueStudentList.remove(ALICE); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + assertEquals(expectedUniqueStudentList, uniqueStudentList); + } + + @Test + public void setPersons_nullUniquePersonList_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setPersons((UniqueStudentList) null)); + } + + @Test + public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonList() { + uniqueStudentList.add(ALICE); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(BOB); + uniqueStudentList.setPersons(expectedUniqueStudentList); + assertEquals(expectedUniqueStudentList, uniqueStudentList); + } + + @Test + public void setPersons_nullList_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setPersons((List) null)); + } + + @Test + public void setPersons_list_replacesOwnListWithProvidedList() { + uniqueStudentList.add(ALICE); + List studentList = Collections.singletonList(BOB); + uniqueStudentList.setPersons(studentList); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(BOB); + assertEquals(expectedUniqueStudentList, uniqueStudentList); + } + + @Test + public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() { + List listWithDuplicateStudents = Arrays.asList(ALICE, ALICE); + assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.setPersons(listWithDuplicateStudents)); + } + + @Test + public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () + -> uniqueStudentList.asUnmodifiableObservableList().remove(0)); + } + + @Test + public void toStringMethod() { + assertEquals(uniqueStudentList.asUnmodifiableObservableList().toString(), uniqueStudentList.toString()); + } +} diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java similarity index 58% rename from src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java rename to src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java index 83b11331cdb..32205b1d5ec 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java @@ -1,7 +1,7 @@ package seedu.address.storage; import static org.junit.jupiter.api.Assertions.assertEquals; -import static seedu.address.storage.JsonAdaptedPerson.MISSING_FIELD_MESSAGE_FORMAT; +import static seedu.address.storage.JsonAdaptedStudent.MISSING_FIELD_MESSAGE_FORMAT; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.BENSON; @@ -12,98 +12,80 @@ import org.junit.jupiter.api.Test; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; -public class JsonAdaptedPersonTest { +public class JsonAdaptedStudentTest { private static final String INVALID_NAME = "R@chel"; private static final String INVALID_PHONE = "+651234"; - private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_TAG = "#friend"; private static final String VALID_NAME = BENSON.getName().toString(); private static final String VALID_PHONE = BENSON.getPhone().toString(); private static final String VALID_EMAIL = BENSON.getEmail().toString(); - private static final String VALID_ADDRESS = BENSON.getAddress().toString(); private static final List VALID_TAGS = BENSON.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList()); @Test public void toModelType_validPersonDetails_returnsPerson() throws Exception { - JsonAdaptedPerson person = new JsonAdaptedPerson(BENSON); + JsonAdaptedStudent person = new JsonAdaptedStudent(BENSON); assertEquals(BENSON, person.toModelType()); } @Test public void toModelType_invalidName_throwsIllegalValueException() { - JsonAdaptedPerson person = - new JsonAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedStudent person = + new JsonAdaptedStudent(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_TAGS); String expectedMessage = Name.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullName_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedStudent person = new JsonAdaptedStudent(null, VALID_PHONE, VALID_EMAIL, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_invalidPhone_throwsIllegalValueException() { - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedStudent person = + new JsonAdaptedStudent(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_TAGS); String expectedMessage = Phone.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullPhone_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedStudent person = new JsonAdaptedStudent(VALID_NAME, null, VALID_EMAIL, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_invalidEmail_throwsIllegalValueException() { - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedStudent person = + new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_TAGS); String expectedMessage = Email.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullEmail_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedStudent person = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, null, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } - @Test - public void toModelType_invalidAddress_throwsIllegalValueException() { - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_TAGS); - String expectedMessage = Address.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); - } - - @Test - public void toModelType_nullAddress_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_TAGS); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); - } - @Test public void toModelType_invalidTags_throwsIllegalValueException() { List invalidTags = new ArrayList<>(VALID_TAGS); invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); + JsonAdaptedStudent person = + new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, VALID_EMAIL, invalidTags); assertThrows(IllegalValueException.class, person::toModelType); } diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index d53799fd110..e375a1b29e1 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -1,7 +1,7 @@ package seedu.address.testutil; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * A utility class to help with building Addressbook objects. @@ -21,10 +21,10 @@ public AddressBookBuilder(AddressBook addressBook) { } /** - * Adds a new {@code Person} to the {@code AddressBook} that we are building. + * Adds a new {@code Student} to the {@code AddressBook} that we are building. */ - public AddressBookBuilder withPerson(Person person) { - addressBook.addPerson(person); + public AddressBookBuilder withPerson(Student student) { + addressBook.addPerson(student); return this; } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 4584bd5044e..24a60b31dbb 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -4,43 +4,42 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.logic.commands.EditCommand; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; +import seedu.address.model.student.Student; import seedu.address.model.tag.Tag; /** - * A utility class to help with building EditPersonDescriptor objects. + * A utility class to help with building EditStudentDescriptor objects. */ public class EditPersonDescriptorBuilder { - private EditPersonDescriptor descriptor; + private EditCommand.EditStudentDescriptor descriptor; public EditPersonDescriptorBuilder() { - descriptor = new EditPersonDescriptor(); + descriptor = new EditCommand.EditStudentDescriptor(); } - public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) { - this.descriptor = new EditPersonDescriptor(descriptor); + public EditPersonDescriptorBuilder(EditCommand.EditStudentDescriptor descriptor) { + this.descriptor = new EditCommand.EditStudentDescriptor(descriptor); } /** - * Returns an {@code EditPersonDescriptor} with fields containing {@code person}'s details + * Returns an {@code EditStudentDescriptor} with fields containing {@code student}'s details */ - public EditPersonDescriptorBuilder(Person person) { - descriptor = new EditPersonDescriptor(); - descriptor.setName(person.getName()); - descriptor.setPhone(person.getPhone()); - descriptor.setEmail(person.getEmail()); - descriptor.setAddress(person.getAddress()); - descriptor.setTags(person.getTags()); + public EditPersonDescriptorBuilder(Student student) { + descriptor = new EditStudentDescriptor(); + descriptor.setName(student.getName()); + descriptor.setPhone(student.getPhone()); + descriptor.setEmail(student.getEmail()); + descriptor.setTags(student.getTags()); } /** - * Sets the {@code Name} of the {@code EditPersonDescriptor} that we are building. + * Sets the {@code Name} of the {@code EditStudentDescriptor} that we are building. */ public EditPersonDescriptorBuilder withName(String name) { descriptor.setName(new Name(name)); @@ -48,7 +47,7 @@ public EditPersonDescriptorBuilder withName(String name) { } /** - * Sets the {@code Phone} of the {@code EditPersonDescriptor} that we are building. + * Sets the {@code Phone} of the {@code EditStudentDescriptor} that we are building. */ public EditPersonDescriptorBuilder withPhone(String phone) { descriptor.setPhone(new Phone(phone)); @@ -56,7 +55,7 @@ public EditPersonDescriptorBuilder withPhone(String phone) { } /** - * Sets the {@code Email} of the {@code EditPersonDescriptor} that we are building. + * Sets the {@code Email} of the {@code EditStudentDescriptor} that we are building. */ public EditPersonDescriptorBuilder withEmail(String email) { descriptor.setEmail(new Email(email)); @@ -64,15 +63,7 @@ public EditPersonDescriptorBuilder withEmail(String email) { } /** - * Sets the {@code Address} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withAddress(String address) { - descriptor.setAddress(new Address(address)); - return this; - } - - /** - * Parses the {@code tags} into a {@code Set} and set it to the {@code EditPersonDescriptor} + * Parses the {@code tags} into a {@code Set} and set it to the {@code EditStudentDescriptor} * that we are building. */ public EditPersonDescriptorBuilder withTags(String... tags) { @@ -81,7 +72,7 @@ public EditPersonDescriptorBuilder withTags(String... tags) { return this; } - public EditPersonDescriptor build() { + public EditCommand.EditStudentDescriptor build() { return descriptor; } } diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index 6be381d39ba..eb957f95d15 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -3,16 +3,15 @@ import java.util.HashSet; import java.util.Set; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; +import seedu.address.model.student.Student; 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 Student objects. */ public class PersonBuilder { @@ -24,7 +23,6 @@ public class PersonBuilder { private Name name; private Phone phone; private Email email; - private Address address; private Set tags; /** @@ -34,23 +32,21 @@ public PersonBuilder() { name = new Name(DEFAULT_NAME); phone = new Phone(DEFAULT_PHONE); email = new Email(DEFAULT_EMAIL); - address = new Address(DEFAULT_ADDRESS); tags = new HashSet<>(); } /** - * Initializes the PersonBuilder with the data of {@code personToCopy}. + * Initializes the PersonBuilder with the data of {@code studentToCopy}. */ - public PersonBuilder(Person personToCopy) { - name = personToCopy.getName(); - phone = personToCopy.getPhone(); - email = personToCopy.getEmail(); - address = personToCopy.getAddress(); - tags = new HashSet<>(personToCopy.getTags()); + public PersonBuilder(Student studentToCopy) { + name = studentToCopy.getName(); + phone = studentToCopy.getPhone(); + email = studentToCopy.getEmail(); + tags = new HashSet<>(studentToCopy.getTags()); } /** - * Sets the {@code Name} of the {@code Person} that we are building. + * Sets the {@code Name} of the {@code Student} that we are building. */ public PersonBuilder withName(String name) { this.name = new Name(name); @@ -58,7 +54,7 @@ public PersonBuilder withName(String name) { } /** - * 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 Student} that we are building. */ public PersonBuilder withTags(String ... tags) { this.tags = SampleDataUtil.getTagSet(tags); @@ -66,15 +62,7 @@ public PersonBuilder withTags(String ... tags) { } /** - * Sets the {@code Address} of the {@code Person} that we are building. - */ - public PersonBuilder 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 Student} that we are building. */ public PersonBuilder withPhone(String phone) { this.phone = new Phone(phone); @@ -82,15 +70,15 @@ public PersonBuilder withPhone(String phone) { } /** - * Sets the {@code Email} of the {@code Person} that we are building. + * Sets the {@code Email} of the {@code Student} that we are building. */ public PersonBuilder withEmail(String email) { this.email = new Email(email); return this; } - public Person build() { - return new Person(name, phone, email, address, tags); + public Student build() { + return new Student(name, phone, email, tags); } } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index 90849945183..0c2efb3c5ad 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -1,6 +1,5 @@ package seedu.address.testutil; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -9,46 +8,44 @@ import java.util.Set; import seedu.address.logic.commands.AddCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.person.Person; +import seedu.address.logic.commands.EditCommand; +import seedu.address.model.student.Student; import seedu.address.model.tag.Tag; /** - * A utility class for Person. + * A utility class for Student. */ public class PersonUtil { /** - * Returns an add command string for adding the {@code person}. + * Returns an add command string for adding the {@code student}. */ - public static String getAddCommand(Person person) { - return AddCommand.COMMAND_WORD + " " + getPersonDetails(person); + public static String getAddCommand(Student student) { + return AddCommand.COMMAND_WORD + " " + getPersonDetails(student); } /** - * Returns the part of command string for the given {@code person}'s details. + * Returns the part of command string for the given {@code student}'s details. */ - public static String getPersonDetails(Person person) { + public static String getPersonDetails(Student student) { 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 + student.getName().fullName + " "); + sb.append(PREFIX_PHONE + student.getPhone().value + " "); + sb.append(PREFIX_EMAIL + student.getEmail().value + " "); + student.getTags().stream().forEach( s -> sb.append(PREFIX_TAG + s.tagName + " ") ); return sb.toString(); } /** - * Returns the part of command string for the given {@code EditPersonDescriptor}'s details. + * Returns the part of command string for the given {@code EditStudentDescriptor}'s details. */ - public static String getEditPersonDescriptorDetails(EditPersonDescriptor descriptor) { + public static String getEditPersonDescriptorDetails(EditCommand.EditStudentDescriptor descriptor) { StringBuilder sb = new StringBuilder(); descriptor.getName().ifPresent(name -> sb.append(PREFIX_NAME).append(name.fullName).append(" ")); descriptor.getPhone().ifPresent(phone -> sb.append(PREFIX_PHONE).append(phone.value).append(" ")); descriptor.getEmail().ifPresent(email -> sb.append(PREFIX_EMAIL).append(email.value).append(" ")); - descriptor.getAddress().ifPresent(address -> sb.append(PREFIX_ADDRESS).append(address.value).append(" ")); if (descriptor.getTags().isPresent()) { Set tags = descriptor.getTags().get(); if (tags.isEmpty()) { diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/seedu/address/testutil/TestUtil.java index 896d103eb0b..71617e9ad83 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/seedu/address/testutil/TestUtil.java @@ -7,7 +7,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * A utility class for test cases. @@ -33,23 +33,23 @@ public static Path getFilePathInSandboxFolder(String fileName) { } /** - * Returns the middle index of the person in the {@code model}'s person list. + * Returns the middle index of the student in the {@code model}'s student list. */ public static Index getMidIndex(Model model) { return Index.fromOneBased(model.getFilteredPersonList().size() / 2); } /** - * Returns the last index of the person in the {@code model}'s person list. + * Returns the last index of the student in the {@code model}'s student list. */ public static Index getLastIndex(Model model) { return Index.fromOneBased(model.getFilteredPersonList().size()); } /** - * Returns the person in the {@code model}'s person list at {@code index}. + * Returns the student in the {@code model}'s student list at {@code index}. */ - public static Person getPerson(Model model, Index index) { + public static Student getPerson(Model model, Index index) { return model.getFilteredPersonList().get(index.getZeroBased()); } } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index fec76fb7129..52fd97e2a86 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -1,7 +1,5 @@ package seedu.address.testutil; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; @@ -16,43 +14,42 @@ import java.util.List; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** - * A utility class containing a list of {@code Person} objects to be used in tests. + * A utility class containing a list of {@code Student} objects to be used in tests. */ public class TypicalPersons { - public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") - .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") + public static final Student ALICE = new PersonBuilder().withName("Alice Pauline") + .withEmail("alice@example.com") .withPhone("94351253") .withTags("friends").build(); - public static final Person BENSON = new PersonBuilder().withName("Benson Meier") - .withAddress("311, Clementi Ave 2, #02-25") + public static final Student BENSON = new PersonBuilder().withName("Benson Meier") .withEmail("johnd@example.com").withPhone("98765432") .withTags("owesMoney", "friends").build(); - public static final Person CARL = new PersonBuilder().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") - .withEmail("cornelia@example.com").withAddress("10th street").withTags("friends").build(); - public static final Person ELLE = new PersonBuilder().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") - .withEmail("lydia@example.com").withAddress("little tokyo").build(); - public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") - .withEmail("anna@example.com").withAddress("4th street").build(); + public static final Student CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") + .withEmail("heinz@example.com").build(); + public static final Student DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") + .withEmail("cornelia@example.com").withTags("friends").build(); + public static final Student ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") + .withEmail("werner@example.com").build(); + public static final Student FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") + .withEmail("lydia@example.com").build(); + public static final Student GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") + .withEmail("anna@example.com").build(); // Manually added - public static final Person HOON = new PersonBuilder().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") - .withEmail("hans@example.com").withAddress("chicago ave").build(); + public static final Student HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") + .withEmail("stefan@example.com").build(); + public static final Student IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") + .withEmail("hans@example.com").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) - .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) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) + // Manually added - Student's details found in {@code CommandTestUtil} + public static final Student AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) + .withEmail(VALID_EMAIL_AMY).withTags(VALID_TAG_FRIEND).build(); + public static final Student BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + .withEmail(VALID_EMAIL_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER @@ -64,13 +61,13 @@ private TypicalPersons() {} // prevents instantiation */ public static AddressBook getTypicalAddressBook() { AddressBook ab = new AddressBook(); - for (Person person : getTypicalPersons()) { - ab.addPerson(person); + for (Student student : getTypicalPersons()) { + ab.addPerson(student); } return ab; } - public static List getTypicalPersons() { + public static List getTypicalPersons() { return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); } } From f30f52e4ca153d9c87674d8ec460421f5a2335ba Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Fri, 4 Oct 2024 23:04:14 +0800 Subject: [PATCH 3/9] Revert "Fix bug in CommandException comment" This reverts commit 434babd6e847345b2353a92c27372bfbbed2842f. --- .../address/logic/commands/exceptions/CommandException.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java index f44c0c19186..a16bd14f2cd 100644 --- a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java +++ b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java @@ -1,7 +1,5 @@ package seedu.address.logic.commands.exceptions; -import seedu.address.logic.commands.Command; - /** * Represents an error which occurs during execution of a {@link Command}. */ From b2aebf36d0de6a09628d85067918ac745b61821c Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Fri, 4 Oct 2024 23:12:17 +0800 Subject: [PATCH 4/9] Remove place holder for "address" form UI --- .../address/logic/commands/exceptions/CommandException.java | 2 -- src/main/resources/view/PersonListCard.fxml | 1 - 2 files changed, 3 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java index f44c0c19186..a16bd14f2cd 100644 --- a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java +++ b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java @@ -1,7 +1,5 @@ package seedu.address.logic.commands.exceptions; -import seedu.address.logic.commands.Command; - /** * Represents an error which occurs during execution of a {@link Command}. */ diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index 84e09833a87..ff2f4f3dd5e 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -29,7 +29,6 @@
From f1ba2a833c3cb2a5ae55d2a927ea9fd00bc0639a Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Fri, 4 Oct 2024 23:15:44 +0800 Subject: [PATCH 5/9] Satisfy coding standard to improve code quality --- src/main/java/seedu/address/model/AddressBook.java | 9 +++++++-- src/main/java/seedu/address/model/Model.java | 3 ++- .../seedu/address/logic/commands/EditCommandTest.java | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 474549f6027..1453f4fe5c2 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -91,7 +91,8 @@ public void addPerson(Student p) { /** * Replaces the given student {@code target} in the list with {@code editedStudent}. * {@code target} must exist in the address book. - * The student identity of {@code editedStudent} must not be the same as another existing student in the address book. + * The student identity of {@code editedStudent} must not be the same as another existing student in the address + * book. */ public void setPerson(Student target, Student editedStudent) { requireNonNull(editedStudent); @@ -159,8 +160,12 @@ public String toString() { public ObservableList getPersonList() { return persons.asUnmodifiableObservableList(); } + @Override - public ObservableList getAssignmentList() { return assignments.asUnmodifiableObservableList(); } + public ObservableList getAssignmentList() { + return assignments.asUnmodifiableObservableList(); + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index ca4d0175a97..df53185d1d7 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -72,7 +72,8 @@ public interface Model { /** * Replaces the given student {@code target} with {@code editedStudent}. * {@code target} must exist in the address book. - * The student identity of {@code editedStudent} must not be the same as another existing student in the address book. + * The student identity of {@code editedStudent} must not be the same as another existing student in the address + * book. */ void setPerson(Student target, Student editedStudent); diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 25663c00291..65108303f03 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -123,7 +123,8 @@ public void execute_duplicatePersonFilteredList_failure() { @Test public void execute_invalidPersonIndexUnfilteredList_failure() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); - EditCommand.EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build(); + EditCommand.EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) + .build(); EditCommand editCommand = new EditCommand(outOfBoundIndex, descriptor); assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); From 4a17398b4c6733164a2dc5513eff1675f88018c4 Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Fri, 4 Oct 2024 23:20:29 +0800 Subject: [PATCH 6/9] CommandException.java: Fix a bug in comment --- .../address/logic/commands/exceptions/CommandException.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java index a16bd14f2cd..f44c0c19186 100644 --- a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java +++ b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java @@ -1,5 +1,7 @@ package seedu.address.logic.commands.exceptions; +import seedu.address.logic.commands.Command; + /** * Represents an error which occurs during execution of a {@link Command}. */ From 7d9ed336c63825110be2f0edb0f6325b26537501 Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Wed, 9 Oct 2024 23:04:39 +0800 Subject: [PATCH 7/9] Change "person" to "student" in all code and comments --- docs/UserGuide.md | 2 +- src/main/java/seedu/address/logic/Logic.java | 4 +- .../seedu/address/logic/LogicManager.java | 4 +- .../java/seedu/address/logic/Messages.java | 4 +- .../address/logic/commands/AddCommand.java | 8 +- .../address/logic/commands/DeleteCommand.java | 10 +- .../address/logic/commands/EditCommand.java | 24 ++-- .../address/logic/commands/FindCommand.java | 8 +- .../address/logic/commands/ListCommand.java | 8 +- .../commands/exceptions/CommandException.java | 4 +- .../java/seedu/address/model/AddressBook.java | 40 +++---- src/main/java/seedu/address/model/Model.java | 14 +-- .../seedu/address/model/ModelManager.java | 24 ++-- .../address/model/ReadOnlyAddressBook.java | 6 +- .../assignment/UniqueAssignmentList.java | 2 +- .../DuplicateAssignmentException.java | 4 +- .../seedu/address/model/student/Student.java | 11 +- .../model/student/UniqueStudentList.java | 27 +++-- .../exceptions/DuplicateStudentException.java | 6 +- .../address/model/util/SampleDataUtil.java | 6 +- .../address/storage/JsonAdaptedStudent.java | 6 +- .../storage/JsonSerializableAddressBook.java | 20 ++-- .../java/seedu/address/ui/MainWindow.java | 12 +- .../java/seedu/address/ui/StudentCard.java | 4 +- ...onListPanel.java => StudentListPanel.java} | 20 ++-- src/main/resources/view/DarkTheme.css | 2 +- src/main/resources/view/MainWindow.fxml | 2 +- ...rsonListCard.fxml => StudentListCard.fxml} | 0 ...onListPanel.fxml => StudentListPanel.fxml} | 2 +- ...=> invalidAndValidStudentAddressBook.json} | 6 +- ...ok.json => invalidStudentAddressBook.json} | 4 +- ....json => duplicateStudentAddressBook.json} | 2 +- ...ok.json => invalidStudentAddressBook.json} | 2 +- ...k.json => typicalStudentsAddressBook.json} | 4 +- .../address/commons/core/index/IndexTest.java | 14 +-- .../seedu/address/logic/LogicManagerTest.java | 16 +-- .../commands/AddCommandIntegrationTest.java | 16 +-- .../logic/commands/AddCommandTest.java | 58 ++++----- .../logic/commands/ClearCommandTest.java | 2 +- .../logic/commands/CommandTestUtil.java | 20 ++-- .../logic/commands/DeleteCommandTest.java | 52 ++++---- .../logic/commands/EditCommandTest.java | 112 +++++++++--------- .../commands/EditStudentDescriptorTest.java | 10 +- .../logic/commands/FindCommandTest.java | 26 ++-- .../logic/commands/ListCommandTest.java | 8 +- .../logic/parser/AddCommandParserTest.java | 36 +++--- .../logic/parser/AddressBookParserTest.java | 24 ++-- .../logic/parser/DeleteCommandParserTest.java | 4 +- .../logic/parser/EditCommandParserTest.java | 32 ++--- .../address/logic/parser/ParserUtilTest.java | 6 +- .../seedu/address/model/AddressBookTest.java | 42 +++---- .../seedu/address/model/ModelManagerTest.java | 30 ++--- .../NameContainsKeywordsPredicateTest.java | 16 +-- .../address/model/student/StudentTest.java | 40 +++---- .../model/student/UniqueStudentListTest.java | 76 ++++++------ .../storage/JsonAdaptedStudentTest.java | 36 +++--- .../storage/JsonAddressBookStorageTest.java | 22 ++-- .../JsonSerializableAddressBookTest.java | 26 ++-- .../address/storage/StorageManagerTest.java | 2 +- .../address/testutil/AddressBookBuilder.java | 6 +- ...java => EditStudentDescriptorBuilder.java} | 16 +-- ...PersonBuilder.java => StudentBuilder.java} | 18 +-- .../{PersonUtil.java => StudentUtil.java} | 8 +- .../java/seedu/address/testutil/TestUtil.java | 8 +- .../address/testutil/TypicalIndexes.java | 6 +- ...picalPersons.java => TypicalStudents.java} | 34 +++--- 66 files changed, 564 insertions(+), 560 deletions(-) rename src/main/java/seedu/address/ui/{PersonListPanel.java => StudentListPanel.java} (59%) rename src/main/resources/view/{PersonListCard.fxml => StudentListCard.fxml} (100%) rename src/main/resources/view/{PersonListPanel.fxml => StudentListPanel.fxml} (77%) rename src/test/data/JsonAddressBookStorageTest/{invalidAndValidPersonAddressBook.json => invalidAndValidStudentAddressBook.json} (66%) rename src/test/data/JsonAddressBookStorageTest/{invalidPersonAddressBook.json => invalidStudentAddressBook.json} (54%) rename src/test/data/JsonSerializableAddressBookTest/{duplicatePersonAddressBook.json => duplicateStudentAddressBook.json} (94%) rename src/test/data/JsonSerializableAddressBookTest/{invalidPersonAddressBook.json => invalidStudentAddressBook.json} (87%) rename src/test/data/JsonSerializableAddressBookTest/{typicalPersonsAddressBook.json => typicalStudentsAddressBook.json} (88%) rename src/test/java/seedu/address/testutil/{EditPersonDescriptorBuilder.java => EditStudentDescriptorBuilder.java} (80%) rename src/test/java/seedu/address/testutil/{PersonBuilder.java => StudentBuilder.java} (80%) rename src/test/java/seedu/address/testutil/{PersonUtil.java => StudentUtil.java} (88%) rename src/test/java/seedu/address/testutil/{TypicalPersons.java => TypicalStudents.java} (60%) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 2aa109e305b..bd960556e24 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -123,7 +123,7 @@ Format: `find KEYWORD [MORE_KEYWORDS]` * The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans` * Only the name is searched. * Only full words will be matched e.g. `Han` will not match `Hans` -* Persons matching at least one keyword will be returned (i.e. `OR` search). +* Students matching at least one keyword will be returned (i.e. `OR` search). e.g. `Hans Bo` will return `Hans Gruber`, `Bo Yang` Examples: diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 641d315e68d..6696e55727a 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -30,8 +30,8 @@ public interface Logic { */ ReadOnlyAddressBook getAddressBook(); - /** Returns an unmodifiable view of the filtered list of persons */ - ObservableList getFilteredPersonList(); + /** Returns an unmodifiable view of the filtered list of students */ + ObservableList getFilteredStudentList(); /** * Returns the user prefs' address book file path. diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index e5ba9807bab..9f4986b9890 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -67,8 +67,8 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public ObservableList getFilteredPersonList() { - return model.getFilteredPersonList(); + public ObservableList getFilteredStudentList() { + return model.getFilteredStudentList(); } @Override diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index fdd062ef8bd..8ed9acc8044 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -15,8 +15,8 @@ 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 student index provided is invalid"; - public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; + public static final String MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX = "The student index provided is invalid"; + public static final String MESSAGE_STUDENTS_LISTED_OVERVIEW = "%1$d students listed!"; public static final String MESSAGE_DUPLICATE_FIELDS = "Multiple values specified for the following single-valued field(s): "; diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 6691acf5ca7..cc23e78d05d 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -33,7 +33,7 @@ public class AddCommand extends Command { + PREFIX_TAG + "owesMoney"; public static final String MESSAGE_SUCCESS = "New student added: %1$s"; - public static final String MESSAGE_DUPLICATE_PERSON = "This student already exists in the address book"; + public static final String MESSAGE_DUPLICATE_STUDENT = "This student already exists in the address book"; private final Student toAdd; @@ -49,11 +49,11 @@ public AddCommand(Student student) { public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - if (model.hasPerson(toAdd)) { - throw new CommandException(MESSAGE_DUPLICATE_PERSON); + if (model.hasStudent(toAdd)) { + throw new CommandException(MESSAGE_DUPLICATE_STUDENT); } - model.addPerson(toAdd); + model.addStudent(toAdd); return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd))); } diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 1062fa39e32..61d805ef44d 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -23,7 +23,7 @@ public class DeleteCommand extends Command { + "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1"; - public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Student: %1$s"; + public static final String MESSAGE_DELETE_STUDENT_SUCCESS = "Deleted Student: %1$s"; private final Index targetIndex; @@ -34,15 +34,15 @@ public DeleteCommand(Index targetIndex) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredStudentList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { - throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + throw new CommandException(Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } Student studentToDelete = lastShownList.get(targetIndex.getZeroBased()); - model.deletePerson(studentToDelete); - return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(studentToDelete))); + model.deleteStudent(studentToDelete); + return new CommandResult(String.format(MESSAGE_DELETE_STUDENT_SUCCESS, Messages.format(studentToDelete))); } @Override diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index f3a955d2ce5..41ff2d72155 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -5,7 +5,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STUDENTS; import java.util.Collections; import java.util.HashSet; @@ -45,9 +45,9 @@ public class EditCommand extends Command { + PREFIX_PHONE + "91234567 " + PREFIX_EMAIL + "johndoe@example.com"; - public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Student: %1$s"; + public static final String MESSAGE_EDIT_STUDENT_SUCCESS = "Edited Student: %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 student already exists in the address book."; + public static final String MESSAGE_DUPLICATE_STUDENT = "This student already exists in the address book."; private final Index index; private final EditStudentDescriptor editStudentDescriptor; @@ -67,29 +67,29 @@ public EditCommand(Index index, EditStudentDescriptor editStudentDescriptor) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredStudentList(); if (index.getZeroBased() >= lastShownList.size()) { - throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + throw new CommandException(Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } Student studentToEdit = lastShownList.get(index.getZeroBased()); - Student editedStudent = createEditedPerson(studentToEdit, editStudentDescriptor); + Student editedStudent = createEditedStudent(studentToEdit, editStudentDescriptor); - if (!studentToEdit.isSamePerson(editedStudent) && model.hasPerson(editedStudent)) { - throw new CommandException(MESSAGE_DUPLICATE_PERSON); + if (!studentToEdit.isSameStudent(editedStudent) && model.hasStudent(editedStudent)) { + throw new CommandException(MESSAGE_DUPLICATE_STUDENT); } - model.setPerson(studentToEdit, editedStudent); - model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent))); + model.setStudent(studentToEdit, editedStudent); + model.updateFilteredStudentList(PREDICATE_SHOW_ALL_STUDENTS); + return new CommandResult(String.format(MESSAGE_EDIT_STUDENT_SUCCESS, Messages.format(editedStudent))); } /** * Creates and returns a {@code Student} with the details of {@code studentToEdit} * edited with {@code editStudentDescriptor}. */ - private static Student createEditedPerson(Student studentToEdit, EditStudentDescriptor editStudentDescriptor) { + private static Student createEditedStudent(Student studentToEdit, EditStudentDescriptor editStudentDescriptor) { assert studentToEdit != null; Name updatedName = editStudentDescriptor.getName().orElse(studentToEdit.getName()); diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 5a7e8fca79f..952cbb2d6d3 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -8,14 +8,14 @@ import seedu.address.model.student.NameContainsKeywordsPredicate; /** - * Finds and lists all persons in address book whose name contains any of the argument keywords. + * Finds and lists all students in address book whose name contains any of the argument keywords. * Keyword matching is case insensitive. */ public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all students whose names contain any of " + "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n" + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" + "Example: " + COMMAND_WORD + " alice bob charlie"; @@ -29,9 +29,9 @@ public FindCommand(NameContainsKeywordsPredicate predicate) { @Override public CommandResult execute(Model model) { requireNonNull(model); - model.updateFilteredPersonList(predicate); + model.updateFilteredStudentList(predicate); return new CommandResult( - String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); + String.format(Messages.MESSAGE_STUDENTS_LISTED_OVERVIEW, model.getFilteredStudentList().size())); } @Override diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 84be6ad2596..77ab100be7c 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -1,24 +1,24 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STUDENTS; import seedu.address.model.Model; /** - * Lists all persons in the address book to the user. + * Lists all students in the address book to the user. */ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; - public static final String MESSAGE_SUCCESS = "Listed all persons"; + public static final String MESSAGE_SUCCESS = "Listed all students"; @Override public CommandResult execute(Model model) { requireNonNull(model); - model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + model.updateFilteredStudentList(PREDICATE_SHOW_ALL_STUDENTS); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java index f44c0c19186..d337e36196a 100644 --- a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java +++ b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java @@ -1,9 +1,7 @@ package seedu.address.logic.commands.exceptions; -import seedu.address.logic.commands.Command; - /** - * Represents an error which occurs during execution of a {@link Command}. + * Represents an error which occurs during execution of a {@link seedu.address.logic.commands.Command}. */ public class CommandException extends Exception { public CommandException(String message) { diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 1453f4fe5c2..3d0b6bc559a 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -14,11 +14,11 @@ /** * Wraps all data at the address-book level - * Duplicates are not allowed (by .isSamePerson comparison) + * Duplicates are not allowed (by .isSameStudent comparison) */ public class AddressBook implements ReadOnlyAddressBook { - private final UniqueStudentList persons; + private final UniqueStudentList students; private final UniqueAssignmentList assignments; /* @@ -29,14 +29,14 @@ public class AddressBook implements ReadOnlyAddressBook { * among constructors. */ { - persons = new UniqueStudentList(); + students = new UniqueStudentList(); assignments = new UniqueAssignmentList(); } public AddressBook() {} /** - * Creates an AddressBook using the Persons in the {@code toBeCopied} + * Creates an AddressBook using the Students in the {@code toBeCopied} */ public AddressBook(ReadOnlyAddressBook toBeCopied) { this(); @@ -49,8 +49,8 @@ public AddressBook(ReadOnlyAddressBook toBeCopied) { * Replaces the contents of the student list with {@code students}. * {@code students} must not contain duplicate students. */ - public void setPersons(List students) { - this.persons.setPersons(students); + public void setStudents(List students) { + this.students.setStudents(students); } /** @@ -67,7 +67,7 @@ public void setAssignments(List assignments) { */ public void resetData(ReadOnlyAddressBook newData) { requireNonNull(newData); - setPersons(newData.getPersonList()); + setStudents(newData.getStudentList()); } //// student-level operations @@ -75,17 +75,17 @@ public void resetData(ReadOnlyAddressBook newData) { /** * Returns true if a student with the same identity as {@code student} exists in the address book. */ - public boolean hasPerson(Student student) { + public boolean hasStudent(Student student) { requireNonNull(student); - return persons.contains(student); + return students.contains(student); } /** * Adds a student to the address book. * The student must not already exist in the address book. */ - public void addPerson(Student p) { - persons.add(p); + public void addStudent(Student p) { + students.add(p); } /** @@ -94,18 +94,18 @@ public void addPerson(Student p) { * The student identity of {@code editedStudent} must not be the same as another existing student in the address * book. */ - public void setPerson(Student target, Student editedStudent) { + public void setStudent(Student target, Student editedStudent) { requireNonNull(editedStudent); - persons.setPerson(target, editedStudent); + students.setStudent(target, editedStudent); } /** * Removes {@code key} from this {@code AddressBook}. * {@code key} must exist in the address book. */ - public void removePerson(Student key) { - persons.remove(key); + public void removeStudent(Student key) { + students.remove(key); } //// assignment-level operations @@ -151,14 +151,14 @@ public void removeAssignment(Assignment key) { @Override public String toString() { return new ToStringBuilder(this) - .add("persons", persons) + .add("students", students) .add("assignments", assignments) .toString(); } @Override - public ObservableList getPersonList() { - return persons.asUnmodifiableObservableList(); + public ObservableList getStudentList() { + return students.asUnmodifiableObservableList(); } @Override @@ -178,11 +178,11 @@ public boolean equals(Object other) { } AddressBook otherAddressBook = (AddressBook) other; - return persons.equals(otherAddressBook.persons) && assignments.equals(otherAddressBook.assignments); + return students.equals(otherAddressBook.students) && assignments.equals(otherAddressBook.assignments); } @Override public int hashCode() { - return persons.hashCode(); + return students.hashCode(); } } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index df53185d1d7..3025fd63f57 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -13,7 +13,7 @@ */ public interface Model { /** {@code Predicate} that always evaluate to true */ - Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; + Predicate PREDICATE_SHOW_ALL_STUDENTS = unused -> true; /** * Replaces user prefs data with the data in {@code userPrefs}. @@ -56,35 +56,35 @@ public interface Model { /** * Returns true if a student with the same identity as {@code student} exists in the address book. */ - boolean hasPerson(Student student); + boolean hasStudent(Student student); /** * Deletes the given student. * The student must exist in the address book. */ - void deletePerson(Student target); + void deleteStudent(Student target); /** * Adds the given student. * {@code student} must not already exist in the address book. */ - void addPerson(Student student); + void addStudent(Student student); /** * Replaces the given student {@code target} with {@code editedStudent}. * {@code target} must exist in the address book. * The student identity of {@code editedStudent} must not be the same as another existing student in the address * book. */ - void setPerson(Student target, Student editedStudent); + void setStudent(Student target, Student editedStudent); /** Returns an unmodifiable view of the filtered student list */ - ObservableList getFilteredPersonList(); + ObservableList getFilteredStudentList(); /** * Updates the filter of the filtered student list to filter by the given {@code predicate}. * @throws NullPointerException if {@code predicate} is null. */ - void updateFilteredPersonList(Predicate predicate); + void updateFilteredStudentList(Predicate predicate); /** * Adds the given assignment. * {@code Assignment} must not already exist in the address book. diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 5b46efeb1be..f5056a2ae6a 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -34,7 +34,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs this.addressBook = new AddressBook(addressBook); this.userPrefs = new UserPrefs(userPrefs); - filteredStudents = new FilteredList<>(this.addressBook.getPersonList()); + filteredStudents = new FilteredList<>(this.addressBook.getStudentList()); } public ModelManager() { @@ -89,26 +89,26 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public boolean hasPerson(Student student) { + public boolean hasStudent(Student student) { requireNonNull(student); - return addressBook.hasPerson(student); + return addressBook.hasStudent(student); } @Override - public void deletePerson(Student target) { - addressBook.removePerson(target); + public void deleteStudent(Student target) { + addressBook.removeStudent(target); } @Override - public void addPerson(Student student) { - addressBook.addPerson(student); - updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + public void addStudent(Student student) { + addressBook.addStudent(student); + updateFilteredStudentList(PREDICATE_SHOW_ALL_STUDENTS); } @Override - public void setPerson(Student target, Student editedStudent) { + public void setStudent(Student target, Student editedStudent) { requireAllNonNull(target, editedStudent); - addressBook.setPerson(target, editedStudent); + addressBook.setStudent(target, editedStudent); } @Override public boolean hasAssignment(Assignment assignment) { @@ -128,12 +128,12 @@ public void addAssignment(Assignment assignment) { * {@code versionedAddressBook} */ @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredStudentList() { return filteredStudents; } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredStudentList(Predicate predicate) { requireNonNull(predicate); filteredStudents.setPredicate(predicate); } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index 1cb3c3b51e7..defcb6584ab 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -10,10 +10,10 @@ public interface ReadOnlyAddressBook { /** - * Returns an unmodifiable view of the persons list. - * This list will not contain any duplicate persons. + * Returns an unmodifiable view of the students list. + * This list will not contain any duplicate students. */ - ObservableList getPersonList(); + ObservableList getStudentList(); ObservableList getAssignmentList(); } diff --git a/src/main/java/seedu/address/model/assignment/UniqueAssignmentList.java b/src/main/java/seedu/address/model/assignment/UniqueAssignmentList.java index fa15e7ea5a1..2462d8e3440 100644 --- a/src/main/java/seedu/address/model/assignment/UniqueAssignmentList.java +++ b/src/main/java/seedu/address/model/assignment/UniqueAssignmentList.java @@ -133,7 +133,7 @@ public String toString() { } /** - * Returns true if {@code persons} contains only unique persons. + * Returns true if {@code students} contains only unique students. */ private boolean assignmentsAreUnique(List assignments) { for (int i = 0; i < assignments.size() - 1; i++) { diff --git a/src/main/java/seedu/address/model/assignment/exceptions/DuplicateAssignmentException.java b/src/main/java/seedu/address/model/assignment/exceptions/DuplicateAssignmentException.java index c9907994a12..2989ddfc6ef 100644 --- a/src/main/java/seedu/address/model/assignment/exceptions/DuplicateAssignmentException.java +++ b/src/main/java/seedu/address/model/assignment/exceptions/DuplicateAssignmentException.java @@ -1,8 +1,8 @@ package seedu.address.model.assignment.exceptions; /** - * Signals that the operation will result in duplicate Persons (Persons are considered duplicates if they have the same - * identity). + * Signals that the operation will result in duplicate Students (Students are considered duplicates if they have the + * same identity). */ public class DuplicateAssignmentException extends RuntimeException { public DuplicateAssignmentException() { diff --git a/src/main/java/seedu/address/model/student/Student.java b/src/main/java/seedu/address/model/student/Student.java index f03fd0db03b..7fc1b5b6aba 100644 --- a/src/main/java/seedu/address/model/student/Student.java +++ b/src/main/java/seedu/address/model/student/Student.java @@ -21,6 +21,7 @@ public class Student { private final Phone phone; private final Email email; + // Data fields private final Set tags = new HashSet<>(); /** @@ -55,10 +56,10 @@ public Set getTags() { } /** - * Returns true if both persons have the same name. - * This defines a weaker notion of equality between two persons. + * Returns true if both students have the same name. + * This defines a weaker notion of equality between two students. */ - public boolean isSamePerson(Student otherStudent) { + public boolean isSameStudent(Student otherStudent) { if (otherStudent == this) { return true; } @@ -68,8 +69,8 @@ public boolean isSamePerson(Student otherStudent) { } /** - * Returns true if both persons have the same identity and data fields. - * This defines a stronger notion of equality between two persons. + * Returns true if both students have the same identity and data fields. + * This defines a stronger notion of equality between two students. */ @Override public boolean equals(Object other) { diff --git a/src/main/java/seedu/address/model/student/UniqueStudentList.java b/src/main/java/seedu/address/model/student/UniqueStudentList.java index 0c7cf115bc5..d1588be8991 100644 --- a/src/main/java/seedu/address/model/student/UniqueStudentList.java +++ b/src/main/java/seedu/address/model/student/UniqueStudentList.java @@ -12,15 +12,16 @@ import seedu.address.model.student.exceptions.StudentNotFoundException; /** - * A list of persons that enforces uniqueness between its elements and does not allow nulls. - * A student is considered unique by comparing using {@code Student#isSamePerson(Student)}. As such, adding and updating - * of persons uses Student#isSamePerson(Student) for equality so as to ensure that the student being added or updated is - * unique in terms of identity in the UniqueStudentList. However, the removal of a student uses Student#equals(Object) + * A list of students that enforces uniqueness between its elements and does not allow nulls. + * A student is considered unique by comparing using {@code Student#isSameStudent(Student)}. As such, adding and + * updating of students uses Student#isSameStudent(Student) for equality so as to ensure that the student being added or + * updated is unique in terms of identity in the UniqueStudentList. However, the removal of a student uses + * Student#equals(Object) * so as to ensure that the student with exactly the same fields will be removed. * * Supports a minimal set of list operations. * - * @see Student#isSamePerson(Student) + * @see Student#isSameStudent(Student) */ public class UniqueStudentList implements Iterable { @@ -33,7 +34,7 @@ public class UniqueStudentList implements Iterable { */ public boolean contains(Student toCheck) { requireNonNull(toCheck); - return internalList.stream().anyMatch(toCheck::isSamePerson); + return internalList.stream().anyMatch(toCheck::isSameStudent); } /** @@ -53,7 +54,7 @@ public void add(Student toAdd) { * {@code target} must exist in the list. * The student identity of {@code editedStudent} must not be the same as another existing student in the list. */ - public void setPerson(Student target, Student editedStudent) { + public void setStudent(Student target, Student editedStudent) { requireAllNonNull(target, editedStudent); int index = internalList.indexOf(target); @@ -61,7 +62,7 @@ public void setPerson(Student target, Student editedStudent) { throw new StudentNotFoundException(); } - if (!target.isSamePerson(editedStudent) && contains(editedStudent)) { + if (!target.isSameStudent(editedStudent) && contains(editedStudent)) { throw new DuplicateStudentException(); } @@ -79,7 +80,7 @@ public void remove(Student toRemove) { } } - public void setPersons(UniqueStudentList replacement) { + public void setStudents(UniqueStudentList replacement) { requireNonNull(replacement); internalList.setAll(replacement.internalList); } @@ -88,9 +89,9 @@ public void setPersons(UniqueStudentList replacement) { * Replaces the contents of this list with {@code students}. * {@code students} must not contain duplicate students. */ - public void setPersons(List students) { + public void setStudents(List students) { requireAllNonNull(students); - if (!personsAreUnique(students)) { + if (!studentsAreUnique(students)) { throw new DuplicateStudentException(); } @@ -137,10 +138,10 @@ public String toString() { /** * Returns true if {@code students} contains only unique students. */ - private boolean personsAreUnique(List students) { + private boolean studentsAreUnique(List students) { for (int i = 0; i < students.size() - 1; i++) { for (int j = i + 1; j < students.size(); j++) { - if (students.get(i).isSamePerson(students.get(j))) { + if (students.get(i).isSameStudent(students.get(j))) { return false; } } diff --git a/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java b/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java index be126bcd35a..d1a8f9ce635 100644 --- a/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java +++ b/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java @@ -1,11 +1,11 @@ package seedu.address.model.student.exceptions; /** - * Signals that the operation will result in duplicate Persons (Persons are considered duplicates if they have the same - * identity). + * Signals that the operation will result in duplicate Students (Students are considered duplicates if they have the + * same identity). */ public class DuplicateStudentException extends RuntimeException { public DuplicateStudentException() { - super("Operation would result in duplicate persons"); + super("Operation would result in duplicate students"); } } diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 33f23119161..b4b868f9ed8 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -16,7 +16,7 @@ * Contains utility methods for populating {@code AddressBook} with sample data. */ public class SampleDataUtil { - public static Student[] getSamplePersons() { + public static Student[] getSampleStudents() { return new Student[] { new Student(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), getTagSet("friends")), @@ -35,8 +35,8 @@ public static Student[] getSamplePersons() { public static ReadOnlyAddressBook getSampleAddressBook() { AddressBook sampleAb = new AddressBook(); - for (Student sampleStudent : getSamplePersons()) { - sampleAb.addPerson(sampleStudent); + for (Student sampleStudent : getSampleStudents()) { + sampleAb.addStudent(sampleStudent); } return sampleAb; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedStudent.java b/src/main/java/seedu/address/storage/JsonAdaptedStudent.java index 35eaf67b4db..1cf8249f87c 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedStudent.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedStudent.java @@ -61,9 +61,9 @@ public JsonAdaptedStudent(Student source) { * @throws IllegalValueException if there were any data constraints violated in the adapted student. */ public Student toModelType() throws IllegalValueException { - final List personTags = new ArrayList<>(); + final List studentTags = new ArrayList<>(); for (JsonAdaptedTag tag : tags) { - personTags.add(tag.toModelType()); + studentTags.add(tag.toModelType()); } if (name == null) { @@ -89,7 +89,7 @@ public Student toModelType() throws IllegalValueException { throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS); } final Email modelEmail = new Email(email); - final Set modelTags = new HashSet<>(personTags); + final Set modelTags = new HashSet<>(studentTags); return new Student(modelName, modelPhone, modelEmail, modelTags); } diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index 5654f7c627d..921fb608a5c 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -19,16 +19,16 @@ @JsonRootName(value = "addressbook") class JsonSerializableAddressBook { - public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate student(s)."; + public static final String MESSAGE_DUPLICATE_STUDENT = "Students list contains duplicate student(s)."; - private final List persons = new ArrayList<>(); + private final List students = new ArrayList<>(); /** - * Constructs a {@code JsonSerializableAddressBook} with the given persons. + * Constructs a {@code JsonSerializableAddressBook} with the given students. */ @JsonCreator - public JsonSerializableAddressBook(@JsonProperty("persons") List persons) { - this.persons.addAll(persons); + public JsonSerializableAddressBook(@JsonProperty("students") List students) { + this.students.addAll(students); } /** @@ -37,7 +37,7 @@ public JsonSerializableAddressBook(@JsonProperty("persons") List { private Logic logic; // Independent Ui parts residing in this Ui container - private PersonListPanel personListPanel; + private StudentListPanel studentListPanel; private ResultDisplay resultDisplay; private HelpWindow helpWindow; @@ -42,7 +42,7 @@ public class MainWindow extends UiPart { private MenuItem helpMenuItem; @FXML - private StackPane personListPanelPlaceholder; + private StackPane studentListPanelPlaceholder; @FXML private StackPane resultDisplayPlaceholder; @@ -110,8 +110,8 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { * Fills up all the placeholders of this window. */ void fillInnerParts() { - personListPanel = new PersonListPanel(logic.getFilteredPersonList()); - personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); + studentListPanel = new StudentListPanel(logic.getFilteredStudentList()); + studentListPanelPlaceholder.getChildren().add(studentListPanel.getRoot()); resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); @@ -163,8 +163,8 @@ private void handleExit() { primaryStage.hide(); } - public PersonListPanel getPersonListPanel() { - return personListPanel; + public StudentListPanel getStudentListPanel() { + return studentListPanel; } /** diff --git a/src/main/java/seedu/address/ui/StudentCard.java b/src/main/java/seedu/address/ui/StudentCard.java index 00f2d13db07..5a7a4e948f2 100644 --- a/src/main/java/seedu/address/ui/StudentCard.java +++ b/src/main/java/seedu/address/ui/StudentCard.java @@ -14,7 +14,7 @@ */ public class StudentCard extends UiPart { - private static final String FXML = "PersonListCard.fxml"; + private static final String FXML = "StudentListCard.fxml"; /** * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. @@ -40,7 +40,7 @@ public class StudentCard extends UiPart { private FlowPane tags; /** - * Creates a {@code PersonCode} with the given {@code Student} and index to display. + * Creates a {@code StudentCode} with the given {@code Student} and index to display. */ public StudentCard(Student student, int displayedIndex) { super(FXML); diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/StudentListPanel.java similarity index 59% rename from src/main/java/seedu/address/ui/PersonListPanel.java rename to src/main/java/seedu/address/ui/StudentListPanel.java index 70a81e0c2ab..c906d3f82b3 100644 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ b/src/main/java/seedu/address/ui/StudentListPanel.java @@ -11,28 +11,28 @@ import seedu.address.model.student.Student; /** - * Panel containing the list of persons. + * Panel containing the list of students. */ -public class PersonListPanel extends UiPart { - private static final String FXML = "PersonListPanel.fxml"; - private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); +public class StudentListPanel extends UiPart { + private static final String FXML = "StudentListPanel.fxml"; + private final Logger logger = LogsCenter.getLogger(StudentListPanel.class); @FXML - private ListView personListView; + private ListView studentListView; /** - * Creates a {@code PersonListPanel} with the given {@code ObservableList}. + * Creates a {@code StudentListPanel} with the given {@code ObservableList}. */ - public PersonListPanel(ObservableList studentList) { + public StudentListPanel(ObservableList studentList) { super(FXML); - personListView.setItems(studentList); - personListView.setCellFactory(listView -> new PersonListViewCell()); + studentListView.setItems(studentList); + studentListView.setCellFactory(listView -> new StudentListViewCell()); } /** * Custom {@code ListCell} that displays the graphics of a {@code Student} using a {@code StudentCard}. */ - class PersonListViewCell extends ListCell { + class StudentListViewCell extends ListCell { @Override protected void updateItem(Student student, boolean empty) { super.updateItem(student, empty); diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index 36e6b001cd8..83a9ed84fda 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -328,7 +328,7 @@ -fx-text-fill: white; } -#filterField, #personListPanel, #personWebpage { +#filterField, #studentListPanel, #studentWebpage { -fx-effect: innershadow(gaussian, black, 10, 0, 0, 0); } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 7052021b691..1832b2f96bf 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -50,7 +50,7 @@ - +
diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/StudentListCard.fxml similarity index 100% rename from src/main/resources/view/PersonListCard.fxml rename to src/main/resources/view/StudentListCard.fxml diff --git a/src/main/resources/view/PersonListPanel.fxml b/src/main/resources/view/StudentListPanel.fxml similarity index 77% rename from src/main/resources/view/PersonListPanel.fxml rename to src/main/resources/view/StudentListPanel.fxml index a1bb6bbace8..e164fbf0524 100644 --- a/src/main/resources/view/PersonListPanel.fxml +++ b/src/main/resources/view/StudentListPanel.fxml @@ -4,5 +4,5 @@ - + diff --git a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidAndValidStudentAddressBook.json similarity index 66% rename from src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json rename to src/test/data/JsonAddressBookStorageTest/invalidAndValidStudentAddressBook.json index 6a4d2b7181c..4bf2f991bad 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidAndValidStudentAddressBook.json @@ -1,11 +1,11 @@ { - "persons": [ { - "name": "Valid Person", + "students": [ { + "name": "Valid Student", "phone": "9482424", "email": "hans@example.com", "address": "4th street" }, { - "name": "Person With Invalid Phone Field", + "name": "Student With Invalid Phone Field", "phone": "948asdf2424", "email": "hans@example.com", "address": "4th street" diff --git a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidStudentAddressBook.json similarity index 54% rename from src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json rename to src/test/data/JsonAddressBookStorageTest/invalidStudentAddressBook.json index ccd21f7d1a9..3489ec31584 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidStudentAddressBook.json @@ -1,6 +1,6 @@ { - "persons": [ { - "name": "Person with invalid name field: Ha!ns Mu@ster", + "students": [ { + "name": "Student with invalid name field: Ha!ns Mu@ster", "phone": "9482424", "email": "hans@example.com", "address": "4th street" diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicateStudentAddressBook.json similarity index 94% rename from src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json rename to src/test/data/JsonSerializableAddressBookTest/duplicateStudentAddressBook.json index a7427fe7aa2..2b8a465f1f7 100644 --- a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/duplicateStudentAddressBook.json @@ -1,5 +1,5 @@ { - "persons": [ { + "students": [ { "name": "Alice Pauline", "phone": "94351253", "email": "alice@example.com", diff --git a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/invalidStudentAddressBook.json similarity index 87% rename from src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json rename to src/test/data/JsonSerializableAddressBookTest/invalidStudentAddressBook.json index ad3f135ae42..d606a1ed218 100644 --- a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/invalidStudentAddressBook.json @@ -1,5 +1,5 @@ { - "persons": [ { + "students": [ { "name": "Hans Muster", "phone": "9482424", "email": "invalid@email!3e", diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalStudentsAddressBook.json similarity index 88% rename from src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json rename to src/test/data/JsonSerializableAddressBookTest/typicalStudentsAddressBook.json index 72262099d35..520d43dee31 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalStudentsAddressBook.json @@ -1,6 +1,6 @@ { - "_comment": "AddressBook save file which contains the same Person values as in TypicalPersons#getTypicalAddressBook()", - "persons" : [ { + "_comment": "AddressBook save file which contains the same Student values as in TypicalStudents#getTypicalAddressBook()", + "students": [ { "name" : "Alice Pauline", "phone" : "94351253", "email" : "alice@example.com", diff --git a/src/test/java/seedu/address/commons/core/index/IndexTest.java b/src/test/java/seedu/address/commons/core/index/IndexTest.java index fc395ab964b..ec55ee8b759 100644 --- a/src/test/java/seedu/address/commons/core/index/IndexTest.java +++ b/src/test/java/seedu/address/commons/core/index/IndexTest.java @@ -39,23 +39,23 @@ public void createZeroBasedIndex() { @Test public void equals() { - final Index fifthPersonIndex = Index.fromOneBased(5); + final Index fifthStuIndex = Index.fromOneBased(5); // same values -> returns true - assertTrue(fifthPersonIndex.equals(Index.fromOneBased(5))); - assertTrue(fifthPersonIndex.equals(Index.fromZeroBased(4))); + assertTrue(fifthStuIndex.equals(Index.fromOneBased(5))); + assertTrue(fifthStuIndex.equals(Index.fromZeroBased(4))); // same object -> returns true - assertTrue(fifthPersonIndex.equals(fifthPersonIndex)); + assertTrue(fifthStuIndex.equals(fifthStuIndex)); // null -> returns false - assertFalse(fifthPersonIndex.equals(null)); + assertFalse(fifthStuIndex.equals(null)); // different types -> returns false - assertFalse(fifthPersonIndex.equals(5.0f)); + assertFalse(fifthStuIndex.equals(5.0f)); // different index -> returns false - assertFalse(fifthPersonIndex.equals(Index.fromOneBased(1))); + assertFalse(fifthStuIndex.equals(Index.fromOneBased(1))); } @Test diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 9d5b25f34d5..0e83f060d58 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -1,13 +1,13 @@ package seedu.address.logic; import static org.junit.jupiter.api.Assertions.assertEquals; -import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; +import static seedu.address.logic.Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX; import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.AMY; +import static seedu.address.testutil.TypicalStudents.AMY; import java.io.IOException; import java.nio.file.AccessDeniedException; @@ -30,7 +30,7 @@ import seedu.address.storage.JsonAddressBookStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.StorageManager; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.StudentBuilder; public class LogicManagerTest { private static final IOException DUMMY_IO_EXCEPTION = new IOException("dummy IO exception"); @@ -60,7 +60,7 @@ public void execute_invalidCommandFormat_throwsParseException() { @Test public void execute_commandExecutionError_throwsCommandException() { String deleteCommand = "delete 9"; - assertCommandException(deleteCommand, MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandException(deleteCommand, MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } @Test @@ -82,8 +82,8 @@ public void execute_storageThrowsAdException_throwsCommandException() { } @Test - public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredPersonList().remove(0)); + public void getFilteredStudentList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredStudentList().remove(0)); } /** @@ -166,9 +166,9 @@ public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) // Triggers the saveAddressBook method by executing an add command String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY; - Student expectedStudent = new PersonBuilder(AMY).withTags().build(); + Student expectedStudent = new StudentBuilder(AMY).withTags().build(); ModelManager expectedModel = new ModelManager(); - expectedModel.addPerson(expectedStudent); + expectedModel.addStudent(expectedStudent); assertCommandFailure(addCommand, CommandException.class, expectedMessage, expectedModel); } } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java index 2e6badb274a..f4ff87328b6 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java @@ -2,7 +2,7 @@ import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -12,7 +12,7 @@ import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; import seedu.address.model.student.Student; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.StudentBuilder; /** * Contains integration tests (interaction with the Model) for {@code AddCommand}. @@ -27,11 +27,11 @@ public void setUp() { } @Test - public void execute_newPerson_success() { - Student validStudent = new PersonBuilder().build(); + public void execute_newStudent_success() { + Student validStudent = new StudentBuilder().build(); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.addPerson(validStudent); + expectedModel.addStudent(validStudent); assertCommandSuccess(new AddCommand(validStudent), model, String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validStudent)), @@ -39,10 +39,10 @@ public void execute_newPerson_success() { } @Test - public void execute_duplicatePerson_throwsCommandException() { - Student studentInList = model.getAddressBook().getPersonList().get(0); + public void execute_duplicateStudent_throwsCommandException() { + Student studentInList = model.getAddressBook().getStudentList().get(0); assertCommandFailure(new AddCommand(studentInList), model, - AddCommand.MESSAGE_DUPLICATE_PERSON); + AddCommand.MESSAGE_DUPLICATE_STUDENT); } } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 6f7d4186816..dee32203720 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -5,7 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.ALICE; +import static seedu.address.testutil.TypicalStudents.ALICE; import java.nio.file.Path; import java.util.ArrayList; @@ -24,40 +24,40 @@ import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.assignment.Assignment; import seedu.address.model.student.Student; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.StudentBuilder; public class AddCommandTest { @Test - public void constructor_nullPerson_throwsNullPointerException() { + public void constructor_nullStudent_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> new AddCommand(null)); } @Test - public void execute_personAcceptedByModel_addSuccessful() throws Exception { - ModelStubAcceptingPersonAdded modelStub = new ModelStubAcceptingPersonAdded(); - Student validStudent = new PersonBuilder().build(); + public void execute_studentAcceptedByModel_addSuccessful() throws Exception { + ModelStubAcceptingStudentAdded modelStub = new ModelStubAcceptingStudentAdded(); + Student validStudent = new StudentBuilder().build(); CommandResult commandResult = new AddCommand(validStudent).execute(modelStub); assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validStudent)), commandResult.getFeedbackToUser()); - assertEquals(Arrays.asList(validStudent), modelStub.personsAdded); + assertEquals(Arrays.asList(validStudent), modelStub.studentsAdded); } @Test - public void execute_duplicatePerson_throwsCommandException() { - Student validStudent = new PersonBuilder().build(); + public void execute_duplicateStudent_throwsCommandException() { + Student validStudent = new StudentBuilder().build(); AddCommand addCommand = new AddCommand(validStudent); - ModelStub modelStub = new ModelStubWithPerson(validStudent); + ModelStub modelStub = new ModelStubWithStudent(validStudent); - assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_PERSON, () -> addCommand.execute(modelStub)); + assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_STUDENT, () -> addCommand.execute(modelStub)); } @Test public void equals() { - Student alice = new PersonBuilder().withName("Alice").build(); - Student bob = new PersonBuilder().withName("Bob").build(); + Student alice = new StudentBuilder().withName("Alice").build(); + Student bob = new StudentBuilder().withName("Bob").build(); AddCommand addAliceCommand = new AddCommand(alice); AddCommand addBobCommand = new AddCommand(bob); @@ -120,7 +120,7 @@ public void setAddressBookFilePath(Path addressBookFilePath) { } @Override - public void addPerson(Student student) { + public void addStudent(Student student) { throw new AssertionError("This method should not be called."); } @@ -140,7 +140,7 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public boolean hasPerson(Student student) { + public boolean hasStudent(Student student) { throw new AssertionError("This method should not be called."); } @@ -150,22 +150,22 @@ public boolean hasAssignment(Assignment assignment) { } @Override - public void deletePerson(Student target) { + public void deleteStudent(Student target) { throw new AssertionError("This method should not be called."); } @Override - public void setPerson(Student target, Student editedStudent) { + public void setStudent(Student target, Student editedStudent) { throw new AssertionError("This method should not be called."); } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredStudentList() { throw new AssertionError("This method should not be called."); } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredStudentList(Predicate predicate) { throw new AssertionError("This method should not be called."); } } @@ -173,37 +173,37 @@ public void updateFilteredPersonList(Predicate predicate) { /** * A Model stub that contains a single student. */ - private class ModelStubWithPerson extends ModelStub { + private class ModelStubWithStudent extends ModelStub { private final Student student; - ModelStubWithPerson(Student student) { + ModelStubWithStudent(Student student) { requireNonNull(student); this.student = student; } @Override - public boolean hasPerson(Student student) { + public boolean hasStudent(Student student) { requireNonNull(student); - return this.student.isSamePerson(student); + return this.student.isSameStudent(student); } } /** * A Model stub that always accept the student being added. */ - private class ModelStubAcceptingPersonAdded extends ModelStub { - final ArrayList personsAdded = new ArrayList<>(); + private class ModelStubAcceptingStudentAdded extends ModelStub { + final ArrayList studentsAdded = new ArrayList<>(); @Override - public boolean hasPerson(Student student) { + public boolean hasStudent(Student student) { requireNonNull(student); - return personsAdded.stream().anyMatch(student::isSamePerson); + return studentsAdded.stream().anyMatch(student::isSameStudent); } @Override - public void addPerson(Student student) { + public void addStudent(Student student) { requireNonNull(student); - personsAdded.add(student); + studentsAdded.add(student); } @Override diff --git a/src/test/java/seedu/address/logic/commands/ClearCommandTest.java b/src/test/java/seedu/address/logic/commands/ClearCommandTest.java index 80d9110c03a..2020fcec74b 100644 --- a/src/test/java/seedu/address/logic/commands/ClearCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ClearCommandTest.java @@ -1,7 +1,7 @@ package seedu.address.logic.commands; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import org.junit.jupiter.api.Test; diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 92fef29f929..b826ddf2779 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -18,7 +18,7 @@ import seedu.address.model.Model; import seedu.address.model.student.NameContainsKeywordsPredicate; import seedu.address.model.student.Student; -import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.testutil.EditStudentDescriptorBuilder; /** * Contains helper methods for testing commands. @@ -55,10 +55,10 @@ public class CommandTestUtil { public static final EditCommand.EditStudentDescriptor DESC_BOB; static { - DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) + DESC_AMY = new EditStudentDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) .withTags(VALID_TAG_FRIEND).build(); - DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) + DESC_BOB = new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); } @@ -99,24 +99,24 @@ public static void assertCommandFailure(Command command, Model actualModel, Stri // 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.getFilteredStudentList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); assertEquals(expectedAddressBook, actualModel.getAddressBook()); - assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); + assertEquals(expectedFilteredList, actualModel.getFilteredStudentList()); } /** * Updates {@code model}'s filtered list to show only the student 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()); + public static void showStudentAtIndex(Model model, Index targetIndex) { + assertTrue(targetIndex.getZeroBased() < model.getFilteredStudentList().size()); - Student student = model.getFilteredPersonList().get(targetIndex.getZeroBased()); + Student student = model.getFilteredStudentList().get(targetIndex.getZeroBased()); final String[] splitName = student.getName().fullName.split("\\s+"); - model.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); + model.updateFilteredStudentList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); - assertEquals(1, model.getFilteredPersonList().size()); + assertEquals(1, model.getFilteredStudentList().size()); } } diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 99bc83503e7..e60539c1483 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -5,10 +5,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.logic.commands.CommandTestUtil.showStudentAtIndex; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import org.junit.jupiter.api.Test; @@ -29,66 +29,66 @@ public class DeleteCommandTest { @Test public void execute_validIndexUnfilteredList_success() { - Student studentToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); + Student studentToDelete = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); + DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_STUDENT); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_STUDENT_SUCCESS, Messages.format(studentToDelete)); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(studentToDelete); + expectedModel.deleteStudent(studentToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexUnfilteredList_throwsCommandException() { - Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredStudentList().size() + 1); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); - assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } @Test public void execute_validIndexFilteredList_success() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showStudentAtIndex(model, INDEX_FIRST_STUDENT); - Student studentToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); + Student studentToDelete = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); + DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_STUDENT); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_STUDENT_SUCCESS, Messages.format(studentToDelete)); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(studentToDelete); - showNoPerson(expectedModel); + expectedModel.deleteStudent(studentToDelete); + showNoStudent(expectedModel); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexFilteredList_throwsCommandException() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showStudentAtIndex(model, INDEX_FIRST_STUDENT); - Index outOfBoundIndex = INDEX_SECOND_PERSON; + Index outOfBoundIndex = INDEX_SECOND_STUDENT; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getStudentList().size()); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); - assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(deleteCommand, model, Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } @Test public void equals() { - DeleteCommand deleteFirstCommand = new DeleteCommand(INDEX_FIRST_PERSON); - DeleteCommand deleteSecondCommand = new DeleteCommand(INDEX_SECOND_PERSON); + DeleteCommand deleteFirstCommand = new DeleteCommand(INDEX_FIRST_STUDENT); + DeleteCommand deleteSecondCommand = new DeleteCommand(INDEX_SECOND_STUDENT); // same object -> returns true assertTrue(deleteFirstCommand.equals(deleteFirstCommand)); // same values -> returns true - DeleteCommand deleteFirstCommandCopy = new DeleteCommand(INDEX_FIRST_PERSON); + DeleteCommand deleteFirstCommandCopy = new DeleteCommand(INDEX_FIRST_STUDENT); assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy)); // different types -> returns false @@ -112,9 +112,9 @@ public void toStringMethod() { /** * Updates {@code model}'s filtered list to show no one. */ - private void showNoPerson(Model model) { - model.updateFilteredPersonList(p -> false); + private void showNoStudent(Model model) { + model.updateFilteredStudentList(p -> false); - assertTrue(model.getFilteredPersonList().isEmpty()); + assertTrue(model.getFilteredStudentList().isEmpty()); } } diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 65108303f03..f03bb1f690b 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -10,10 +10,10 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.logic.commands.CommandTestUtil.showStudentAtIndex; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import org.junit.jupiter.api.Test; @@ -25,8 +25,8 @@ import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; import seedu.address.model.student.Student; -import seedu.address.testutil.EditPersonDescriptorBuilder; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.EditStudentDescriptorBuilder; +import seedu.address.testutil.StudentBuilder; /** * Contains integration tests (interaction with the Model) and unit tests for EditCommand. @@ -37,45 +37,48 @@ public class EditCommandTest { @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { - Student editedStudent = new PersonBuilder().build(); - EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder(editedStudent).build(); - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, descriptor); + Student editedStudent = new StudentBuilder().build(); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder(editedStudent).build(); + EditCommand editCommand = new EditCommand(INDEX_FIRST_STUDENT, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_STUDENT_SUCCESS, + Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedStudent); + expectedModel.setStudent(model.getFilteredStudentList().get(0), editedStudent); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test public void execute_someFieldsSpecifiedUnfilteredList_success() { - Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); - Student lastStudent = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); + Index indexLastStudent = Index.fromOneBased(model.getFilteredStudentList().size()); + Student lastStudent = model.getFilteredStudentList().get(indexLastStudent.getZeroBased()); - PersonBuilder personInList = new PersonBuilder(lastStudent); - Student editedStudent = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + StudentBuilder studentInList = new StudentBuilder(lastStudent); + Student editedStudent = studentInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withTags(VALID_TAG_HUSBAND).build(); - EditCommand.EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) + EditCommand.EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_HUSBAND).build(); - EditCommand editCommand = new EditCommand(indexLastPerson, descriptor); + EditCommand editCommand = new EditCommand(indexLastStudent, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_STUDENT_SUCCESS, + Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(lastStudent, editedStudent); + expectedModel.setStudent(lastStudent, editedStudent); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test public void execute_noFieldSpecifiedUnfilteredList_success() { - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditStudentDescriptor()); - Student editedStudent = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditCommand editCommand = new EditCommand(INDEX_FIRST_STUDENT, new EditStudentDescriptor()); + Student editedStudent = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_STUDENT_SUCCESS, + Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); @@ -84,50 +87,51 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { @Test public void execute_filteredList_success() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showStudentAtIndex(model, INDEX_FIRST_STUDENT); - Student studentInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - Student editedStudent = new PersonBuilder(studentInFilteredList).withName(VALID_NAME_BOB).build(); - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, - new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); + Student studentInFilteredList = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); + Student editedStudent = new StudentBuilder(studentInFilteredList).withName(VALID_NAME_BOB).build(); + EditCommand editCommand = new EditCommand(INDEX_FIRST_STUDENT, + new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB).build()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_STUDENT_SUCCESS, + Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedStudent); + expectedModel.setStudent(model.getFilteredStudentList().get(0), editedStudent); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test - public void execute_duplicatePersonUnfilteredList_failure() { - Student firstStudent = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - EditCommand.EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder(firstStudent).build(); - EditCommand editCommand = new EditCommand(INDEX_SECOND_PERSON, descriptor); + public void execute_duplicateStudentUnfilteredList_failure() { + Student firstStudent = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); + EditCommand.EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder(firstStudent).build(); + EditCommand editCommand = new EditCommand(INDEX_SECOND_STUDENT, descriptor); - assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); + assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_STUDENT); } @Test - public void execute_duplicatePersonFilteredList_failure() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + public void execute_duplicateStudentFilteredList_failure() { + showStudentAtIndex(model, INDEX_FIRST_STUDENT); // edit student in filtered list into a duplicate in address book - Student studentInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, - new EditPersonDescriptorBuilder(studentInList).build()); + Student studentInList = model.getAddressBook().getStudentList().get(INDEX_SECOND_STUDENT.getZeroBased()); + EditCommand editCommand = new EditCommand(INDEX_FIRST_STUDENT, + new EditStudentDescriptorBuilder(studentInList).build()); - assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); + assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_STUDENT); } @Test - public void execute_invalidPersonIndexUnfilteredList_failure() { - Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); - EditCommand.EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) + public void execute_invalidStudentIndexUnfilteredList_failure() { + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredStudentList().size() + 1); + EditCommand.EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB) .build(); EditCommand editCommand = new EditCommand(outOfBoundIndex, descriptor); - assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } /** @@ -135,25 +139,25 @@ public void execute_invalidPersonIndexUnfilteredList_failure() { * but smaller than size of address book */ @Test - public void execute_invalidPersonIndexFilteredList_failure() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); - Index outOfBoundIndex = INDEX_SECOND_PERSON; + public void execute_invalidStudentIndexFilteredList_failure() { + showStudentAtIndex(model, INDEX_FIRST_STUDENT); + Index outOfBoundIndex = INDEX_SECOND_STUDENT; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getStudentList().size()); EditCommand editCommand = new EditCommand(outOfBoundIndex, - new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); + new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB).build()); - assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } @Test public void equals() { - final EditCommand standardCommand = new EditCommand(INDEX_FIRST_PERSON, DESC_AMY); + final EditCommand standardCommand = new EditCommand(INDEX_FIRST_STUDENT, DESC_AMY); // same values -> returns true EditStudentDescriptor copyDescriptor = new EditCommand.EditStudentDescriptor(DESC_AMY); - EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_PERSON, copyDescriptor); + EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_STUDENT, copyDescriptor); assertTrue(standardCommand.equals(commandWithSameValues)); // same object -> returns true @@ -166,10 +170,10 @@ public void equals() { assertFalse(standardCommand.equals(new ClearCommand())); // different index -> returns false - assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_PERSON, DESC_AMY))); + assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_STUDENT, DESC_AMY))); // different descriptor -> returns false - assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_PERSON, DESC_BOB))); + assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_STUDENT, DESC_BOB))); } @Test diff --git a/src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java index 8387b3c5ba0..7c50f8dba4c 100644 --- a/src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test; -import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.testutil.EditStudentDescriptorBuilder; public class EditStudentDescriptorTest { @@ -35,21 +35,21 @@ public void equals() { assertFalse(DESC_AMY.equals(DESC_BOB)); // different name -> returns false - EditCommand.EditStudentDescriptor editedAmy = new EditPersonDescriptorBuilder(DESC_AMY) + EditCommand.EditStudentDescriptor editedAmy = new EditStudentDescriptorBuilder(DESC_AMY) .withName(VALID_NAME_BOB) .build(); assertFalse(DESC_AMY.equals(editedAmy)); // different phone -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withPhone(VALID_PHONE_BOB).build(); + editedAmy = new EditStudentDescriptorBuilder(DESC_AMY).withPhone(VALID_PHONE_BOB).build(); assertFalse(DESC_AMY.equals(editedAmy)); // different email -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withEmail(VALID_EMAIL_BOB).build(); + editedAmy = new EditStudentDescriptorBuilder(DESC_AMY).withEmail(VALID_EMAIL_BOB).build(); assertFalse(DESC_AMY.equals(editedAmy)); // different tags -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_HUSBAND).build(); + editedAmy = new EditStudentDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_HUSBAND).build(); assertFalse(DESC_AMY.equals(editedAmy)); } diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 5b69d78ec12..7f5d3f4a48c 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -3,12 +3,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.Messages.MESSAGE_PERSONS_LISTED_OVERVIEW; +import static seedu.address.logic.Messages.MESSAGE_STUDENTS_LISTED_OVERVIEW; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.testutil.TypicalPersons.CARL; -import static seedu.address.testutil.TypicalPersons.ELLE; -import static seedu.address.testutil.TypicalPersons.FIONA; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalStudents.CARL; +import static seedu.address.testutil.TypicalStudents.ELLE; +import static seedu.address.testutil.TypicalStudents.FIONA; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import java.util.Arrays; import java.util.Collections; @@ -55,23 +55,23 @@ public void equals() { } @Test - public void execute_zeroKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); + public void execute_zeroKeywords_noStudentFound() { + String expectedMessage = String.format(MESSAGE_STUDENTS_LISTED_OVERVIEW, 0); NameContainsKeywordsPredicate predicate = preparePredicate(" "); FindCommand command = new FindCommand(predicate); - expectedModel.updateFilteredPersonList(predicate); + expectedModel.updateFilteredStudentList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); - assertEquals(Collections.emptyList(), model.getFilteredPersonList()); + assertEquals(Collections.emptyList(), model.getFilteredStudentList()); } @Test - public void execute_multipleKeywords_multiplePersonsFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 3); + public void execute_multipleKeywords_multipleStudentsFound() { + String expectedMessage = String.format(MESSAGE_STUDENTS_LISTED_OVERVIEW, 3); NameContainsKeywordsPredicate predicate = preparePredicate("Kurz Elle Kunz"); FindCommand command = new FindCommand(predicate); - expectedModel.updateFilteredPersonList(predicate); + expectedModel.updateFilteredStudentList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); - assertEquals(Arrays.asList(CARL, ELLE, FIONA), model.getFilteredPersonList()); + assertEquals(Arrays.asList(CARL, ELLE, FIONA), model.getFilteredStudentList()); } @Test diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java index 435ff1f7275..b6c00c69f86 100644 --- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java @@ -1,9 +1,9 @@ package seedu.address.logic.commands; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.logic.commands.CommandTestUtil.showStudentAtIndex; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,7 +33,7 @@ public void execute_listIsNotFiltered_showsSameList() { @Test public void execute_listIsFiltered_showsEverything() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showStudentAtIndex(model, INDEX_FIRST_STUDENT); assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); } } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index ea1625d4764..2624b541401 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -25,8 +25,8 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalPersons.AMY; -import static seedu.address.testutil.TypicalPersons.BOB; +import static seedu.address.testutil.TypicalStudents.AMY; +import static seedu.address.testutil.TypicalStudents.BOB; import org.junit.jupiter.api.Test; @@ -37,14 +37,14 @@ import seedu.address.model.student.Phone; import seedu.address.model.student.Student; import seedu.address.model.tag.Tag; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.StudentBuilder; public class AddCommandParserTest { private AddCommandParser parser = new AddCommandParser(); @Test public void parse_allFieldsPresent_success() { - Student expectedStudent = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND).build(); + Student expectedStudent = new StudentBuilder(BOB).withTags(VALID_TAG_FRIEND).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB @@ -52,7 +52,7 @@ public void parse_allFieldsPresent_success() { // multiple tags - all accepted - Student expectedStudentMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) + Student expectedStudentMultipleTags = new StudentBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) .build(); assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, @@ -61,60 +61,60 @@ public void parse_allFieldsPresent_success() { @Test public void parse_repeatedNonTagValue_failure() { - String validExpectedPersonString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + String validExpectedStudentString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_FRIEND; // multiple names - assertParseFailure(parser, NAME_DESC_AMY + validExpectedPersonString, + assertParseFailure(parser, NAME_DESC_AMY + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // multiple phones - assertParseFailure(parser, PHONE_DESC_AMY + validExpectedPersonString, + assertParseFailure(parser, PHONE_DESC_AMY + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); // multiple emails - assertParseFailure(parser, EMAIL_DESC_AMY + validExpectedPersonString, + assertParseFailure(parser, EMAIL_DESC_AMY + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMAIL)); // multiple fields repeated assertParseFailure(parser, - validExpectedPersonString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY - + validExpectedPersonString, + validExpectedStudentString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY + + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_EMAIL, PREFIX_PHONE)); // invalid value followed by valid value // invalid name - assertParseFailure(parser, INVALID_NAME_DESC + validExpectedPersonString, + assertParseFailure(parser, INVALID_NAME_DESC + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // invalid email - assertParseFailure(parser, INVALID_EMAIL_DESC + validExpectedPersonString, + assertParseFailure(parser, INVALID_EMAIL_DESC + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMAIL)); // invalid phone - assertParseFailure(parser, INVALID_PHONE_DESC + validExpectedPersonString, + assertParseFailure(parser, INVALID_PHONE_DESC + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); // valid value followed by invalid value // invalid name - assertParseFailure(parser, validExpectedPersonString + INVALID_NAME_DESC, + assertParseFailure(parser, validExpectedStudentString + INVALID_NAME_DESC, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // invalid email - assertParseFailure(parser, validExpectedPersonString + INVALID_EMAIL_DESC, + assertParseFailure(parser, validExpectedStudentString + INVALID_EMAIL_DESC, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMAIL)); // invalid phone - assertParseFailure(parser, validExpectedPersonString + INVALID_PHONE_DESC, + assertParseFailure(parser, validExpectedStudentString + INVALID_PHONE_DESC, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); } @Test public void parse_optionalFieldsMissing_success() { // zero tags - Student expectedStudent = new PersonBuilder(AMY).withTags().build(); + Student expectedStudent = new StudentBuilder(AMY).withTags().build(); assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY, new AddCommand(expectedStudent)); } diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 2291432d3b8..378f8f3636c 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -5,7 +5,7 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; import java.util.Arrays; import java.util.List; @@ -25,9 +25,9 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.student.NameContainsKeywordsPredicate; import seedu.address.model.student.Student; -import seedu.address.testutil.EditPersonDescriptorBuilder; -import seedu.address.testutil.PersonBuilder; -import seedu.address.testutil.PersonUtil; +import seedu.address.testutil.EditStudentDescriptorBuilder; +import seedu.address.testutil.StudentBuilder; +import seedu.address.testutil.StudentUtil; public class AddressBookParserTest { @@ -35,8 +35,8 @@ public class AddressBookParserTest { @Test public void parseCommand_add() throws Exception { - Student student = new PersonBuilder().build(); - AddCommand command = (AddCommand) parser.parseCommand(PersonUtil.getAddCommand(student)); + Student student = new StudentBuilder().build(); + AddCommand command = (AddCommand) parser.parseCommand(StudentUtil.getAddCommand(student)); assertEquals(new AddCommand(student), command); } @@ -49,17 +49,17 @@ public void parseCommand_clear() throws Exception { @Test public void parseCommand_delete() throws Exception { DeleteCommand command = (DeleteCommand) parser.parseCommand( - DeleteCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased()); - assertEquals(new DeleteCommand(INDEX_FIRST_PERSON), command); + DeleteCommand.COMMAND_WORD + " " + INDEX_FIRST_STUDENT.getOneBased()); + assertEquals(new DeleteCommand(INDEX_FIRST_STUDENT), command); } @Test public void parseCommand_edit() throws Exception { - Student student = new PersonBuilder().build(); - EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder(student).build(); + Student student = new StudentBuilder().build(); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder(student).build(); EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " - + INDEX_FIRST_PERSON.getOneBased() + " " + PersonUtil.getEditPersonDescriptorDetails(descriptor)); - assertEquals(new EditCommand(INDEX_FIRST_PERSON, descriptor), command); + + INDEX_FIRST_STUDENT.getOneBased() + " " + StudentUtil.getEditStudentDescriptorDetails(descriptor)); + assertEquals(new EditCommand(INDEX_FIRST_STUDENT, descriptor), command); } @Test diff --git a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java b/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java index 6a40e14a649..33bdab39bb6 100644 --- a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java @@ -3,7 +3,7 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; import org.junit.jupiter.api.Test; @@ -22,7 +22,7 @@ public class DeleteCommandParserTest { @Test public void parse_validArgs_returnsDeleteCommand() { - assertParseSuccess(parser, "1", new DeleteCommand(INDEX_FIRST_PERSON)); + assertParseSuccess(parser, "1", new DeleteCommand(INDEX_FIRST_STUDENT)); } @Test diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 99dfefb69cd..1b5a9702d4c 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -23,9 +23,9 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD_STUDENT; import org.junit.jupiter.api.Test; @@ -37,7 +37,7 @@ import seedu.address.model.student.Name; import seedu.address.model.student.Phone; import seedu.address.model.tag.Tag; -import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.testutil.EditStudentDescriptorBuilder; public class EditCommandParserTest { @@ -98,11 +98,11 @@ public void parse_invalidValue_failure() { @Test public void parse_allFieldsSpecified_success() { - Index targetIndex = INDEX_SECOND_PERSON; + Index targetIndex = INDEX_SECOND_STUDENT; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + TAG_DESC_HUSBAND + EMAIL_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; - EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); @@ -112,10 +112,10 @@ public void parse_allFieldsSpecified_success() { @Test public void parse_someFieldsSpecified_success() { - Index targetIndex = INDEX_FIRST_PERSON; + Index targetIndex = INDEX_FIRST_STUDENT; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + EMAIL_DESC_AMY; - EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_PHONE_BOB) + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_AMY).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); @@ -125,27 +125,27 @@ public void parse_someFieldsSpecified_success() { @Test public void parse_oneFieldSpecified_success() { // name - Index targetIndex = INDEX_THIRD_PERSON; + Index targetIndex = INDEX_THIRD_STUDENT; String userInput = targetIndex.getOneBased() + NAME_DESC_AMY; - EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY).build(); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withName(VALID_NAME_AMY).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // phone userInput = targetIndex.getOneBased() + PHONE_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_PHONE_AMY).build(); + descriptor = new EditStudentDescriptorBuilder().withPhone(VALID_PHONE_AMY).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // email userInput = targetIndex.getOneBased() + EMAIL_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withEmail(VALID_EMAIL_AMY).build(); + descriptor = new EditStudentDescriptorBuilder().withEmail(VALID_EMAIL_AMY).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // tags userInput = targetIndex.getOneBased() + TAG_DESC_FRIEND; - descriptor = new EditPersonDescriptorBuilder().withTags(VALID_TAG_FRIEND).build(); + descriptor = new EditStudentDescriptorBuilder().withTags(VALID_TAG_FRIEND).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); } @@ -156,7 +156,7 @@ public void parse_multipleRepeatedFields_failure() { // AddCommandParserTest#parse_repeatedNonTagValue_failure() // valid followed by invalid - Index targetIndex = INDEX_FIRST_PERSON; + Index targetIndex = INDEX_FIRST_STUDENT; String userInput = targetIndex.getOneBased() + INVALID_PHONE_DESC + PHONE_DESC_BOB; assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); @@ -184,10 +184,10 @@ public void parse_multipleRepeatedFields_failure() { @Test public void parse_resetTags_success() { - Index targetIndex = INDEX_THIRD_PERSON; + Index targetIndex = INDEX_THIRD_STUDENT; String userInput = targetIndex.getOneBased() + TAG_EMPTY; - EditStudentDescriptor descriptor = new EditPersonDescriptorBuilder().withTags().build(); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withTags().build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 90aa63afaaa..ca76398393d 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.parser.ParserUtil.MESSAGE_INVALID_INDEX; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; import java.util.Arrays; import java.util.Collections; @@ -47,10 +47,10 @@ public void parseIndex_outOfRangeInput_throwsParseException() { @Test public void parseIndex_validInput_success() throws Exception { // No whitespaces - assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex("1")); + assertEquals(INDEX_FIRST_STUDENT, ParserUtil.parseIndex("1")); // Leading and trailing whitespaces - assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex(" 1 ")); + assertEquals(INDEX_FIRST_STUDENT, ParserUtil.parseIndex(" 1 ")); } @Test diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index cd55a9cd805..1ab42953e10 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -5,8 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.ALICE; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalStudents.ALICE; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import java.util.Arrays; import java.util.Collection; @@ -21,7 +21,7 @@ import seedu.address.model.assignment.AssignmentName; import seedu.address.model.student.Student; import seedu.address.model.student.exceptions.DuplicateStudentException; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.StudentBuilder; public class AddressBookTest { @@ -29,7 +29,7 @@ public class AddressBookTest { @Test public void constructor() { - assertEquals(Collections.emptyList(), addressBook.getPersonList()); + assertEquals(Collections.emptyList(), addressBook.getStudentList()); } @Test @@ -45,9 +45,9 @@ public void resetData_withValidReadOnlyAddressBook_replacesData() { } @Test - public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { + public void resetData_withDuplicateStudents_throwsDuplicateStudentException() { // Two students with the same identity fields - Student editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND) .build(); List newStudents = Arrays.asList(ALICE, editedAlice); List newAssignments = Arrays.asList(new Assignment(new AssignmentName("Assignment1"), @@ -58,38 +58,38 @@ public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { } @Test - public void hasPerson_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> addressBook.hasPerson(null)); + public void hasStudent_nullStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> addressBook.hasStudent(null)); } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { - assertFalse(addressBook.hasPerson(ALICE)); + public void hasStudent_studentNotInAddressBook_returnsFalse() { + assertFalse(addressBook.hasStudent(ALICE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { - addressBook.addPerson(ALICE); - assertTrue(addressBook.hasPerson(ALICE)); + public void hasStudent_studentInAddressBook_returnsTrue() { + addressBook.addStudent(ALICE); + assertTrue(addressBook.hasStudent(ALICE)); } @Test - public void hasPerson_personWithSameIdentityFieldsInAddressBook_returnsTrue() { - addressBook.addPerson(ALICE); - Student editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + public void hasStudent_studentWithSameIdentityFieldsInAddressBook_returnsTrue() { + addressBook.addStudent(ALICE); + Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND) .build(); - assertTrue(addressBook.hasPerson(editedAlice)); + assertTrue(addressBook.hasStudent(editedAlice)); } @Test - public void getPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> addressBook.getPersonList().remove(0)); + public void getStudentList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () -> addressBook.getStudentList().remove(0)); } /* Temporarily removed this test as new Assignment was created @Test public void toStringMethod() { - String expected = AddressBook.class.getCanonicalName() + "{students=" + addressBook.getPersonList() + "}"; + String expected = AddressBook.class.getCanonicalName() + "{students=" + addressBook.getStudentList() + "}"; assertEquals(expected, addressBook.toString()); } */ @@ -106,7 +106,7 @@ private static class AddressBookStub implements ReadOnlyAddressBook { this.assignments.setAll(assignments); } @Override - public ObservableList getPersonList() { + public ObservableList getStudentList() { return students; } diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index a416b2f626e..466563a3022 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -3,10 +3,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STUDENTS; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.ALICE; -import static seedu.address.testutil.TypicalPersons.BENSON; +import static seedu.address.testutil.TypicalStudents.ALICE; +import static seedu.address.testutil.TypicalStudents.BENSON; import java.nio.file.Path; import java.nio.file.Paths; @@ -73,29 +73,29 @@ public void setAddressBookFilePath_validPath_setsAddressBookFilePath() { } @Test - public void hasPerson_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.hasPerson(null)); + public void hasStudent_nullStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> modelManager.hasStudent(null)); } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { - assertFalse(modelManager.hasPerson(ALICE)); + public void hasStudent_studentNotInAddressBook_returnsFalse() { + assertFalse(modelManager.hasStudent(ALICE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { - modelManager.addPerson(ALICE); - assertTrue(modelManager.hasPerson(ALICE)); + public void hasStudent_studentInAddressBook_returnsTrue() { + modelManager.addStudent(ALICE); + assertTrue(modelManager.hasStudent(ALICE)); } @Test - public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredPersonList().remove(0)); + public void getFilteredStudentList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredStudentList().remove(0)); } @Test public void equals() { - AddressBook addressBook = new AddressBookBuilder().withPerson(ALICE).withPerson(BENSON).build(); + AddressBook addressBook = new AddressBookBuilder().withStudent(ALICE).withStudent(BENSON).build(); AddressBook differentAddressBook = new AddressBook(); UserPrefs userPrefs = new UserPrefs(); @@ -118,11 +118,11 @@ public void equals() { // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); - modelManager.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); + modelManager.updateFilteredStudentList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); assertFalse(modelManager.equals(new ModelManager(addressBook, userPrefs))); // resets modelManager to initial state for upcoming tests - modelManager.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + modelManager.updateFilteredStudentList(PREDICATE_SHOW_ALL_STUDENTS); // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); diff --git a/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java index 9d6caecd9b1..a493c83d51b 100644 --- a/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java +++ b/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.StudentBuilder; public class NameContainsKeywordsPredicateTest { @@ -43,34 +43,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 StudentBuilder().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 StudentBuilder().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 StudentBuilder().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 StudentBuilder().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 StudentBuilder().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 StudentBuilder().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 StudentBuilder().withName("Alice").withPhone("12345") .withEmail("alice@email.com").build())); } diff --git a/src/test/java/seedu/address/model/student/StudentTest.java b/src/test/java/seedu/address/model/student/StudentTest.java index 3eb82b51ee5..b1fa6cf10de 100644 --- a/src/test/java/seedu/address/model/student/StudentTest.java +++ b/src/test/java/seedu/address/model/student/StudentTest.java @@ -8,52 +8,52 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.ALICE; -import static seedu.address.testutil.TypicalPersons.BOB; +import static seedu.address.testutil.TypicalStudents.ALICE; +import static seedu.address.testutil.TypicalStudents.BOB; import org.junit.jupiter.api.Test; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.StudentBuilder; public class StudentTest { @Test public void asObservableList_modifyList_throwsUnsupportedOperationException() { - Student student = new PersonBuilder().build(); + Student student = new StudentBuilder().build(); assertThrows(UnsupportedOperationException.class, () -> student.getTags().remove(0)); } @Test - public void isSamePerson() { + public void isSameStudent() { // same object -> returns true - assertTrue(ALICE.isSamePerson(ALICE)); + assertTrue(ALICE.isSameStudent(ALICE)); // null -> returns false - assertFalse(ALICE.isSamePerson(null)); + assertFalse(ALICE.isSameStudent(null)); // same name, all other attributes different -> returns true - Student editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) + Student editedAlice = new StudentBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) .withTags(VALID_TAG_HUSBAND).build(); - assertTrue(ALICE.isSamePerson(editedAlice)); + assertTrue(ALICE.isSameStudent(editedAlice)); // different name, all other attributes same -> returns false - editedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build(); - assertFalse(ALICE.isSamePerson(editedAlice)); + editedAlice = new StudentBuilder(ALICE).withName(VALID_NAME_BOB).build(); + assertFalse(ALICE.isSameStudent(editedAlice)); // name differs in case, all other attributes same -> returns false - Student editedBob = new PersonBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); - assertFalse(BOB.isSamePerson(editedBob)); + Student editedBob = new StudentBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); + assertFalse(BOB.isSameStudent(editedBob)); // name has trailing spaces, all other attributes same -> returns false String nameWithTrailingSpaces = VALID_NAME_BOB + " "; - editedBob = new PersonBuilder(BOB).withName(nameWithTrailingSpaces).build(); - assertFalse(BOB.isSamePerson(editedBob)); + editedBob = new StudentBuilder(BOB).withName(nameWithTrailingSpaces).build(); + assertFalse(BOB.isSameStudent(editedBob)); } @Test public void equals() { // same values -> returns true - Student aliceCopy = new PersonBuilder(ALICE).build(); + Student aliceCopy = new StudentBuilder(ALICE).build(); assertTrue(ALICE.equals(aliceCopy)); // same object -> returns true @@ -69,19 +69,19 @@ public void equals() { assertFalse(ALICE.equals(BOB)); // different name -> returns false - Student editedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build(); + Student editedAlice = new StudentBuilder(ALICE).withName(VALID_NAME_BOB).build(); assertFalse(ALICE.equals(editedAlice)); // different phone -> returns false - editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).build(); + editedAlice = new StudentBuilder(ALICE).withPhone(VALID_PHONE_BOB).build(); assertFalse(ALICE.equals(editedAlice)); // different email -> returns false - editedAlice = new PersonBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build(); + editedAlice = new StudentBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build(); assertFalse(ALICE.equals(editedAlice)); // different tags -> returns false - editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build(); + editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build(); assertFalse(ALICE.equals(editedAlice)); } diff --git a/src/test/java/seedu/address/model/student/UniqueStudentListTest.java b/src/test/java/seedu/address/model/student/UniqueStudentListTest.java index f1944f6d609..2c444467322 100644 --- a/src/test/java/seedu/address/model/student/UniqueStudentListTest.java +++ b/src/test/java/seedu/address/model/student/UniqueStudentListTest.java @@ -5,8 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.ALICE; -import static seedu.address.testutil.TypicalPersons.BOB; +import static seedu.address.testutil.TypicalStudents.ALICE; +import static seedu.address.testutil.TypicalStudents.BOB; import java.util.Arrays; import java.util.Collections; @@ -16,110 +16,110 @@ import seedu.address.model.student.exceptions.DuplicateStudentException; import seedu.address.model.student.exceptions.StudentNotFoundException; -import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.StudentBuilder; public class UniqueStudentListTest { private final UniqueStudentList uniqueStudentList = new UniqueStudentList(); @Test - public void contains_nullPerson_throwsNullPointerException() { + public void contains_nullStudent_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueStudentList.contains(null)); } @Test - public void contains_personNotInList_returnsFalse() { + public void contains_studentNotInList_returnsFalse() { assertFalse(uniqueStudentList.contains(ALICE)); } @Test - public void contains_personInList_returnsTrue() { + public void contains_studentInList_returnsTrue() { uniqueStudentList.add(ALICE); assertTrue(uniqueStudentList.contains(ALICE)); } @Test - public void contains_personWithSameIdentityFieldsInList_returnsTrue() { + public void contains_studentWithSameIdentityFieldsInList_returnsTrue() { uniqueStudentList.add(ALICE); - Student editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND) .build(); assertTrue(uniqueStudentList.contains(editedAlice)); } @Test - public void add_nullPerson_throwsNullPointerException() { + public void add_nullStudent_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueStudentList.add(null)); } @Test - public void add_duplicatePerson_throwsDuplicatePersonException() { + public void add_duplicateStudent_throwsDuplicateStudentException() { uniqueStudentList.add(ALICE); assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.add(ALICE)); } @Test - public void setPerson_nullTargetPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniqueStudentList.setPerson(null, ALICE)); + public void setStudent_nullTargetStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setStudent(null, ALICE)); } @Test - public void setPerson_nullEditedPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniqueStudentList.setPerson(ALICE, null)); + public void setStudent_nullEditedStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setStudent(ALICE, null)); } @Test - public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() { - assertThrows(StudentNotFoundException.class, () -> uniqueStudentList.setPerson(ALICE, ALICE)); + public void setStudent_targetStudentNotInList_throwsStudentNotFoundException() { + assertThrows(StudentNotFoundException.class, () -> uniqueStudentList.setStudent(ALICE, ALICE)); } @Test - public void setPerson_editedPersonIsSamePerson_success() { + public void setStudent_editedStudentIsSameStudent_success() { uniqueStudentList.add(ALICE); - uniqueStudentList.setPerson(ALICE, ALICE); + uniqueStudentList.setStudent(ALICE, ALICE); UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); expectedUniqueStudentList.add(ALICE); assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPerson_editedPersonHasSameIdentity_success() { + public void setStudent_editedStudentHasSameIdentity_success() { uniqueStudentList.add(ALICE); - Student editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND) .build(); - uniqueStudentList.setPerson(ALICE, editedAlice); + uniqueStudentList.setStudent(ALICE, editedAlice); UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); expectedUniqueStudentList.add(editedAlice); assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPerson_editedPersonHasDifferentIdentity_success() { + public void setStudent_editedStudentHasDifferentIdentity_success() { uniqueStudentList.add(ALICE); - uniqueStudentList.setPerson(ALICE, BOB); + uniqueStudentList.setStudent(ALICE, BOB); UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); expectedUniqueStudentList.add(BOB); assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() { + public void setStudent_editedStudentHasNonUniqueIdentity_throwsDuplicateStudentException() { uniqueStudentList.add(ALICE); uniqueStudentList.add(BOB); - assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.setPerson(ALICE, BOB)); + assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.setStudent(ALICE, BOB)); } @Test - public void remove_nullPerson_throwsNullPointerException() { + public void remove_nullStudent_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueStudentList.remove(null)); } @Test - public void remove_personDoesNotExist_throwsPersonNotFoundException() { + public void remove_studentDoesNotExist_throwsStudentNotFoundException() { assertThrows(StudentNotFoundException.class, () -> uniqueStudentList.remove(ALICE)); } @Test - public void remove_existingPerson_removesPerson() { + public void remove_existingStudent_removesStudent() { uniqueStudentList.add(ALICE); uniqueStudentList.remove(ALICE); UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); @@ -127,38 +127,38 @@ public void remove_existingPerson_removesPerson() { } @Test - public void setPersons_nullUniquePersonList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniqueStudentList.setPersons((UniqueStudentList) null)); + public void setStudents_nullUniqueStudentList_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setStudents((UniqueStudentList) null)); } @Test - public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonList() { + public void setStudents_uniqueStudentList_replacesOwnListWithProvidedUniqueStudentList() { uniqueStudentList.add(ALICE); UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); expectedUniqueStudentList.add(BOB); - uniqueStudentList.setPersons(expectedUniqueStudentList); + uniqueStudentList.setStudents(expectedUniqueStudentList); assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPersons_nullList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniqueStudentList.setPersons((List) null)); + public void setStudents_nullList_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setStudents((List) null)); } @Test - public void setPersons_list_replacesOwnListWithProvidedList() { + public void setStudents_list_replacesOwnListWithProvidedList() { uniqueStudentList.add(ALICE); List studentList = Collections.singletonList(BOB); - uniqueStudentList.setPersons(studentList); + uniqueStudentList.setStudents(studentList); UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); expectedUniqueStudentList.add(BOB); assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() { + public void setStudents_listWithDuplicateStudents_throwsDuplicateStudentException() { List listWithDuplicateStudents = Arrays.asList(ALICE, ALICE); - assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.setPersons(listWithDuplicateStudents)); + assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.setStudents(listWithDuplicateStudents)); } @Test diff --git a/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java b/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java index 32205b1d5ec..9d82221837e 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java @@ -3,7 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static seedu.address.storage.JsonAdaptedStudent.MISSING_FIELD_MESSAGE_FORMAT; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.BENSON; +import static seedu.address.testutil.TypicalStudents.BENSON; import java.util.ArrayList; import java.util.List; @@ -30,63 +30,63 @@ public class JsonAdaptedStudentTest { .collect(Collectors.toList()); @Test - public void toModelType_validPersonDetails_returnsPerson() throws Exception { - JsonAdaptedStudent person = new JsonAdaptedStudent(BENSON); - assertEquals(BENSON, person.toModelType()); + public void toModelType_validStudentDetails_returnsStudent() throws Exception { + JsonAdaptedStudent student = new JsonAdaptedStudent(BENSON); + assertEquals(BENSON, student.toModelType()); } @Test public void toModelType_invalidName_throwsIllegalValueException() { - JsonAdaptedStudent person = + JsonAdaptedStudent student = new JsonAdaptedStudent(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_TAGS); String expectedMessage = Name.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_nullName_throwsIllegalValueException() { - JsonAdaptedStudent person = new JsonAdaptedStudent(null, VALID_PHONE, VALID_EMAIL, VALID_TAGS); + JsonAdaptedStudent student = new JsonAdaptedStudent(null, VALID_PHONE, VALID_EMAIL, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_invalidPhone_throwsIllegalValueException() { - JsonAdaptedStudent person = + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_TAGS); String expectedMessage = Phone.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_nullPhone_throwsIllegalValueException() { - JsonAdaptedStudent person = new JsonAdaptedStudent(VALID_NAME, null, VALID_EMAIL, VALID_TAGS); + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, null, VALID_EMAIL, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_invalidEmail_throwsIllegalValueException() { - JsonAdaptedStudent person = + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_TAGS); String expectedMessage = Email.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_nullEmail_throwsIllegalValueException() { - JsonAdaptedStudent person = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, null, VALID_TAGS); + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, null, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_invalidTags_throwsIllegalValueException() { List invalidTags = new ArrayList<>(VALID_TAGS); invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); - JsonAdaptedStudent person = + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, VALID_EMAIL, invalidTags); - assertThrows(IllegalValueException.class, person::toModelType); + assertThrows(IllegalValueException.class, student::toModelType); } } diff --git a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java index 4e5ce9200c8..3b9376be6d0 100644 --- a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java +++ b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java @@ -3,10 +3,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalPersons.ALICE; -import static seedu.address.testutil.TypicalPersons.HOON; -import static seedu.address.testutil.TypicalPersons.IDA; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalStudents.ALICE; +import static seedu.address.testutil.TypicalStudents.HOON; +import static seedu.address.testutil.TypicalStudents.IDA; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import java.io.IOException; import java.nio.file.Path; @@ -51,13 +51,13 @@ public void read_notJsonFormat_exceptionThrown() { } @Test - public void readAddressBook_invalidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidPersonAddressBook.json")); + public void readAddressBook_invalidStudentAddressBook_throwDataLoadingException() { + assertThrows(DataLoadingException.class, () -> readAddressBook("invalidStudentAddressBook.json")); } @Test - public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidPersonAddressBook.json")); + public void readAddressBook_invalidAndValidStudentAddressBook_throwDataLoadingException() { + assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidStudentAddressBook.json")); } @Test @@ -72,14 +72,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.addStudent(HOON); + original.removeStudent(ALICE); jsonAddressBookStorage.saveAddressBook(original, filePath); readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); assertEquals(original, new AddressBook(readBack)); // Save and read without specifying file path - original.addPerson(IDA); + original.addStudent(IDA); jsonAddressBookStorage.saveAddressBook(original); // file path not specified readBack = jsonAddressBookStorage.readAddressBook().get(); // file path not specified assertEquals(original, new AddressBook(readBack)); diff --git a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java b/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java index 188c9058d20..642d7cd7f9b 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java +++ b/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java @@ -11,36 +11,36 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.commons.util.JsonUtil; import seedu.address.model.AddressBook; -import seedu.address.testutil.TypicalPersons; +import seedu.address.testutil.TypicalStudents; public class JsonSerializableAddressBookTest { private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableAddressBookTest"); - private static final Path TYPICAL_PERSONS_FILE = TEST_DATA_FOLDER.resolve("typicalPersonsAddressBook.json"); - private static final Path INVALID_PERSON_FILE = TEST_DATA_FOLDER.resolve("invalidPersonAddressBook.json"); - private static final Path DUPLICATE_PERSON_FILE = TEST_DATA_FOLDER.resolve("duplicatePersonAddressBook.json"); + private static final Path TYPICAL_STUDENTS_FILE = TEST_DATA_FOLDER.resolve("typicalStudentsAddressBook.json"); + private static final Path INVALID_STUDENT_FILE = TEST_DATA_FOLDER.resolve("invalidStudentAddressBook.json"); + private static final Path DUPLICATE_STUDENT_FILE = TEST_DATA_FOLDER.resolve("duplicateStudentAddressBook.json"); @Test - public void toModelType_typicalPersonsFile_success() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, + public void toModelType_typicalStudentsFile_success() throws Exception { + JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_STUDENTS_FILE, JsonSerializableAddressBook.class).get(); AddressBook addressBookFromFile = dataFromFile.toModelType(); - AddressBook typicalPersonsAddressBook = TypicalPersons.getTypicalAddressBook(); - assertEquals(addressBookFromFile, typicalPersonsAddressBook); + AddressBook typicalStudentsAddressBook = TypicalStudents.getTypicalAddressBook(); + assertEquals(addressBookFromFile, typicalStudentsAddressBook); } @Test - public void toModelType_invalidPersonFile_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(INVALID_PERSON_FILE, + public void toModelType_invalidStudentFile_throwsIllegalValueException() throws Exception { + JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(INVALID_STUDENT_FILE, JsonSerializableAddressBook.class).get(); assertThrows(IllegalValueException.class, dataFromFile::toModelType); } @Test - public void toModelType_duplicatePersons_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PERSON_FILE, + public void toModelType_duplicateStudents_throwsIllegalValueException() throws Exception { + JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_STUDENT_FILE, JsonSerializableAddressBook.class).get(); - assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_PERSON, + assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_STUDENT, dataFromFile::toModelType); } diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 99a16548970..ad0db49f6d9 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -2,7 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import java.nio.file.Path; diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index e375a1b29e1..2005c4d3f42 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -6,7 +6,7 @@ /** * A utility class to help with building Addressbook objects. * Example usage:
- * {@code AddressBook ab = new AddressBookBuilder().withPerson("John", "Doe").build();} + * {@code AddressBook ab = new AddressBookBuilder().withStudent("John", "Doe").build();} */ public class AddressBookBuilder { @@ -23,8 +23,8 @@ public AddressBookBuilder(AddressBook addressBook) { /** * Adds a new {@code Student} to the {@code AddressBook} that we are building. */ - public AddressBookBuilder withPerson(Student student) { - addressBook.addPerson(student); + public AddressBookBuilder withStudent(Student student) { + addressBook.addStudent(student); return this; } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java similarity index 80% rename from src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java rename to src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java index 24a60b31dbb..86931dd9f22 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java @@ -15,22 +15,22 @@ /** * A utility class to help with building EditStudentDescriptor objects. */ -public class EditPersonDescriptorBuilder { +public class EditStudentDescriptorBuilder { private EditCommand.EditStudentDescriptor descriptor; - public EditPersonDescriptorBuilder() { + public EditStudentDescriptorBuilder() { descriptor = new EditCommand.EditStudentDescriptor(); } - public EditPersonDescriptorBuilder(EditCommand.EditStudentDescriptor descriptor) { + public EditStudentDescriptorBuilder(EditCommand.EditStudentDescriptor descriptor) { this.descriptor = new EditCommand.EditStudentDescriptor(descriptor); } /** * Returns an {@code EditStudentDescriptor} with fields containing {@code student}'s details */ - public EditPersonDescriptorBuilder(Student student) { + public EditStudentDescriptorBuilder(Student student) { descriptor = new EditStudentDescriptor(); descriptor.setName(student.getName()); descriptor.setPhone(student.getPhone()); @@ -41,7 +41,7 @@ public EditPersonDescriptorBuilder(Student student) { /** * Sets the {@code Name} of the {@code EditStudentDescriptor} that we are building. */ - public EditPersonDescriptorBuilder withName(String name) { + public EditStudentDescriptorBuilder withName(String name) { descriptor.setName(new Name(name)); return this; } @@ -49,7 +49,7 @@ public EditPersonDescriptorBuilder withName(String name) { /** * Sets the {@code Phone} of the {@code EditStudentDescriptor} that we are building. */ - public EditPersonDescriptorBuilder withPhone(String phone) { + public EditStudentDescriptorBuilder withPhone(String phone) { descriptor.setPhone(new Phone(phone)); return this; } @@ -57,7 +57,7 @@ public EditPersonDescriptorBuilder withPhone(String phone) { /** * Sets the {@code Email} of the {@code EditStudentDescriptor} that we are building. */ - public EditPersonDescriptorBuilder withEmail(String email) { + public EditStudentDescriptorBuilder withEmail(String email) { descriptor.setEmail(new Email(email)); return this; } @@ -66,7 +66,7 @@ public EditPersonDescriptorBuilder withEmail(String email) { * Parses the {@code tags} into a {@code Set} and set it to the {@code EditStudentDescriptor} * that we are building. */ - public EditPersonDescriptorBuilder withTags(String... tags) { + public EditStudentDescriptorBuilder withTags(String... tags) { Set tagSet = Stream.of(tags).map(Tag::new).collect(Collectors.toSet()); descriptor.setTags(tagSet); return this; diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/StudentBuilder.java similarity index 80% rename from src/test/java/seedu/address/testutil/PersonBuilder.java rename to src/test/java/seedu/address/testutil/StudentBuilder.java index eb957f95d15..e8ccbf049e4 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/StudentBuilder.java @@ -13,7 +13,7 @@ /** * A utility class to help with building Student objects. */ -public class PersonBuilder { +public class StudentBuilder { public static final String DEFAULT_NAME = "Amy Bee"; public static final String DEFAULT_PHONE = "85355255"; @@ -26,9 +26,9 @@ public class PersonBuilder { private Set tags; /** - * Creates a {@code PersonBuilder} with the default details. + * Creates a {@code StudentBuilder} with the default details. */ - public PersonBuilder() { + public StudentBuilder() { name = new Name(DEFAULT_NAME); phone = new Phone(DEFAULT_PHONE); email = new Email(DEFAULT_EMAIL); @@ -36,9 +36,9 @@ public PersonBuilder() { } /** - * Initializes the PersonBuilder with the data of {@code studentToCopy}. + * Initializes the StudentBuilder with the data of {@code studentToCopy}. */ - public PersonBuilder(Student studentToCopy) { + public StudentBuilder(Student studentToCopy) { name = studentToCopy.getName(); phone = studentToCopy.getPhone(); email = studentToCopy.getEmail(); @@ -48,7 +48,7 @@ public PersonBuilder(Student studentToCopy) { /** * Sets the {@code Name} of the {@code Student} that we are building. */ - public PersonBuilder withName(String name) { + public StudentBuilder withName(String name) { this.name = new Name(name); return this; } @@ -56,7 +56,7 @@ public PersonBuilder withName(String name) { /** * Parses the {@code tags} into a {@code Set} and set it to the {@code Student} that we are building. */ - public PersonBuilder withTags(String ... tags) { + public StudentBuilder withTags(String ... tags) { this.tags = SampleDataUtil.getTagSet(tags); return this; } @@ -64,7 +64,7 @@ public PersonBuilder withTags(String ... tags) { /** * Sets the {@code Phone} of the {@code Student} that we are building. */ - public PersonBuilder withPhone(String phone) { + public StudentBuilder withPhone(String phone) { this.phone = new Phone(phone); return this; } @@ -72,7 +72,7 @@ public PersonBuilder withPhone(String phone) { /** * Sets the {@code Email} of the {@code Student} that we are building. */ - public PersonBuilder withEmail(String email) { + public StudentBuilder withEmail(String email) { this.email = new Email(email); return this; } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/StudentUtil.java similarity index 88% rename from src/test/java/seedu/address/testutil/PersonUtil.java rename to src/test/java/seedu/address/testutil/StudentUtil.java index 0c2efb3c5ad..0e1a3ceb175 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/StudentUtil.java @@ -15,19 +15,19 @@ /** * A utility class for Student. */ -public class PersonUtil { +public class StudentUtil { /** * Returns an add command string for adding the {@code student}. */ public static String getAddCommand(Student student) { - return AddCommand.COMMAND_WORD + " " + getPersonDetails(student); + return AddCommand.COMMAND_WORD + " " + getStudentDetails(student); } /** * Returns the part of command string for the given {@code student}'s details. */ - public static String getPersonDetails(Student student) { + public static String getStudentDetails(Student student) { StringBuilder sb = new StringBuilder(); sb.append(PREFIX_NAME + student.getName().fullName + " "); sb.append(PREFIX_PHONE + student.getPhone().value + " "); @@ -41,7 +41,7 @@ public static String getPersonDetails(Student student) { /** * Returns the part of command string for the given {@code EditStudentDescriptor}'s details. */ - public static String getEditPersonDescriptorDetails(EditCommand.EditStudentDescriptor descriptor) { + public static String getEditStudentDescriptorDetails(EditCommand.EditStudentDescriptor descriptor) { StringBuilder sb = new StringBuilder(); descriptor.getName().ifPresent(name -> sb.append(PREFIX_NAME).append(name.fullName).append(" ")); descriptor.getPhone().ifPresent(phone -> sb.append(PREFIX_PHONE).append(phone.value).append(" ")); diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/seedu/address/testutil/TestUtil.java index 71617e9ad83..d9aac87d8c6 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/seedu/address/testutil/TestUtil.java @@ -36,20 +36,20 @@ public static Path getFilePathInSandboxFolder(String fileName) { * Returns the middle index of the student in the {@code model}'s student list. */ public static Index getMidIndex(Model model) { - return Index.fromOneBased(model.getFilteredPersonList().size() / 2); + return Index.fromOneBased(model.getFilteredStudentList().size() / 2); } /** * Returns the last index of the student in the {@code model}'s student list. */ public static Index getLastIndex(Model model) { - return Index.fromOneBased(model.getFilteredPersonList().size()); + return Index.fromOneBased(model.getFilteredStudentList().size()); } /** * Returns the student in the {@code model}'s student list at {@code index}. */ - public static Student getPerson(Model model, Index index) { - return model.getFilteredPersonList().get(index.getZeroBased()); + public static Student getStudent(Model model, Index index) { + return model.getFilteredStudentList().get(index.getZeroBased()); } } diff --git a/src/test/java/seedu/address/testutil/TypicalIndexes.java b/src/test/java/seedu/address/testutil/TypicalIndexes.java index 1e613937657..cfa8cf8b11c 100644 --- a/src/test/java/seedu/address/testutil/TypicalIndexes.java +++ b/src/test/java/seedu/address/testutil/TypicalIndexes.java @@ -6,7 +6,7 @@ * A utility class containing a list of {@code Index} objects to be used in tests. */ public class TypicalIndexes { - public static final Index INDEX_FIRST_PERSON = Index.fromOneBased(1); - public static final Index INDEX_SECOND_PERSON = Index.fromOneBased(2); - public static final Index INDEX_THIRD_PERSON = Index.fromOneBased(3); + public static final Index INDEX_FIRST_STUDENT = Index.fromOneBased(1); + public static final Index INDEX_SECOND_STUDENT = Index.fromOneBased(2); + public static final Index INDEX_THIRD_STUDENT = Index.fromOneBased(3); } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalStudents.java similarity index 60% rename from src/test/java/seedu/address/testutil/TypicalPersons.java rename to src/test/java/seedu/address/testutil/TypicalStudents.java index 52fd97e2a86..fc4213db721 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalStudents.java @@ -19,55 +19,55 @@ /** * A utility class containing a list of {@code Student} objects to be used in tests. */ -public class TypicalPersons { +public class TypicalStudents { - public static final Student ALICE = new PersonBuilder().withName("Alice Pauline") + public static final Student ALICE = new StudentBuilder().withName("Alice Pauline") .withEmail("alice@example.com") .withPhone("94351253") .withTags("friends").build(); - public static final Student BENSON = new PersonBuilder().withName("Benson Meier") + public static final Student BENSON = new StudentBuilder().withName("Benson Meier") .withEmail("johnd@example.com").withPhone("98765432") .withTags("owesMoney", "friends").build(); - public static final Student CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") + public static final Student CARL = new StudentBuilder().withName("Carl Kurz").withPhone("95352563") .withEmail("heinz@example.com").build(); - public static final Student DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") + public static final Student DANIEL = new StudentBuilder().withName("Daniel Meier").withPhone("87652533") .withEmail("cornelia@example.com").withTags("friends").build(); - public static final Student ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") + public static final Student ELLE = new StudentBuilder().withName("Elle Meyer").withPhone("9482224") .withEmail("werner@example.com").build(); - public static final Student FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") + public static final Student FIONA = new StudentBuilder().withName("Fiona Kunz").withPhone("9482427") .withEmail("lydia@example.com").build(); - public static final Student GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") + public static final Student GEORGE = new StudentBuilder().withName("George Best").withPhone("9482442") .withEmail("anna@example.com").build(); // Manually added - public static final Student HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") + public static final Student HOON = new StudentBuilder().withName("Hoon Meier").withPhone("8482424") .withEmail("stefan@example.com").build(); - public static final Student IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") + public static final Student IDA = new StudentBuilder().withName("Ida Mueller").withPhone("8482131") .withEmail("hans@example.com").build(); // Manually added - Student's details found in {@code CommandTestUtil} - public static final Student AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) + public static final Student AMY = new StudentBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withTags(VALID_TAG_FRIEND).build(); - public static final Student BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + public static final Student BOB = new StudentBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER - private TypicalPersons() {} // prevents instantiation + private TypicalStudents() {} // prevents instantiation /** - * Returns an {@code AddressBook} with all the typical persons. + * Returns an {@code AddressBook} with all the typical students. */ public static AddressBook getTypicalAddressBook() { AddressBook ab = new AddressBook(); - for (Student student : getTypicalPersons()) { - ab.addPerson(student); + for (Student student : getTypicalStudents()) { + ab.addStudent(student); } return ab; } - public static List getTypicalPersons() { + public static List getTypicalStudents() { return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); } } From 023c591a8e0fdabc6d7a8b5bd846517e092c1bf0 Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Thu, 10 Oct 2024 19:44:53 +0800 Subject: [PATCH 8/9] Fix inconsistencies of code for changing Person to Student --- .../address/logic/commands/CommandResult.java | 24 ++++++++++-------- .../logic/commands/ViewStudentCommand.java | 20 +++++++-------- .../address/model/assignment/Assignment.java | 6 ++--- .../seedu/address/ui/BlankDetailsPanel.java | 4 +-- .../java/seedu/address/ui/MainWindow.java | 20 +++++++-------- ...ilsPanel.java => StudentDetailsPanel.java} | 25 +++++++++---------- src/main/resources/view/MainWindow.fxml | 4 +-- 7 files changed, 52 insertions(+), 51 deletions(-) rename src/main/java/seedu/address/ui/{PersonDetailsPanel.java => StudentDetailsPanel.java} (65%) diff --git a/src/main/java/seedu/address/logic/commands/CommandResult.java b/src/main/java/seedu/address/logic/commands/CommandResult.java index d2970976bce..f9421b8f4bc 100644 --- a/src/main/java/seedu/address/logic/commands/CommandResult.java +++ b/src/main/java/seedu/address/logic/commands/CommandResult.java @@ -5,7 +5,7 @@ import java.util.Objects; import seedu.address.commons.util.ToStringBuilder; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * Represents the result of a command execution. @@ -20,19 +20,19 @@ public class CommandResult { /** The application should exit. */ private final boolean exit; - private final Person person; + private final Student student; - private final int personIndex; + private final int studentIndex; /** * Constructs a {@code CommandResult} with the specified fields. */ - public CommandResult(String feedbackToUser, boolean showHelp, boolean exit, Person person, int index) { + public CommandResult(String feedbackToUser, boolean showHelp, boolean exit, Student student, int index) { this.feedbackToUser = requireNonNull(feedbackToUser); this.showHelp = showHelp; this.exit = exit; - this.person = person; - this.personIndex = index; + this.student = student; + this.studentIndex = index; } public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) { @@ -59,14 +59,16 @@ public boolean isExit() { return exit; } - public boolean isPerson() { return person != null; } + public boolean getStudent() { + return student != null; + } - public Person getPerson() { - return person; + public Student getCurStudent() { + return student; } - public int getPersonIndex() { - return personIndex; + public int getStudentIndex() { + return studentIndex; } @Override diff --git a/src/main/java/seedu/address/logic/commands/ViewStudentCommand.java b/src/main/java/seedu/address/logic/commands/ViewStudentCommand.java index 2b7e267afad..21a1cb442b3 100644 --- a/src/main/java/seedu/address/logic/commands/ViewStudentCommand.java +++ b/src/main/java/seedu/address/logic/commands/ViewStudentCommand.java @@ -9,26 +9,26 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** - * Expands the details of a person identified using it's displayed index from the address book. + * Expands the details of a student identified using it's displayed index from the address book. */ public class ViewStudentCommand extends Command { public static final String COMMAND_WORD = "view_student"; public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Displays details of the person identified by the index number used in the displayed person list.\n" + + ": Displays details of the student identified by the index number used in the displayed student list.\n" + "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1"; - public static final String MESSAGE_VIEW_PERSON_SUCCESS = "Displayed Person: %1$s"; + public static final String MESSAGE_VIEW_STUDENT_SUCCESS = "Displayed Student: %1$s"; private final Index targetIndex; /** - * @param index index of the person to display the details of + * @param index index of the student to display the details of */ public ViewStudentCommand(Index index) { requireAllNonNull(index); @@ -39,16 +39,16 @@ public ViewStudentCommand(Index index) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredStudentList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { - throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + throw new CommandException(Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } - Person personToDisplay = lastShownList.get(targetIndex.getZeroBased()); + Student studentToDisplay = lastShownList.get(targetIndex.getZeroBased()); - return new CommandResult(String.format(MESSAGE_VIEW_PERSON_SUCCESS, targetIndex.getZeroBased() + 1), - false, false, personToDisplay, targetIndex.getZeroBased()); + return new CommandResult(String.format(MESSAGE_VIEW_STUDENT_SUCCESS, targetIndex.getZeroBased() + 1), + false, false, studentToDisplay, targetIndex.getZeroBased()); } @Override diff --git a/src/main/java/seedu/address/model/assignment/Assignment.java b/src/main/java/seedu/address/model/assignment/Assignment.java index 727e1c07458..e5fdde72c44 100644 --- a/src/main/java/seedu/address/model/assignment/Assignment.java +++ b/src/main/java/seedu/address/model/assignment/Assignment.java @@ -7,7 +7,7 @@ import seedu.address.commons.util.ToStringBuilder; import seedu.address.model.assignment.exceptions.AssignmentAlreadyAssignedStudentException; -import seedu.address.model.person.Person; +import seedu.address.model.student.Student; /** * Represents an Assignment in the address book. @@ -26,7 +26,7 @@ public class Assignment { private final int maxScore; private int score = 0; private boolean hasSubmitted = false; - private Person student; + private Student student; /** * Every field must be present and not null. @@ -41,7 +41,7 @@ public Assignment(AssignmentName name, int maxScore) { /** * Assigns assignment to student. */ - public void assignStudent(Person student) { + public void assignStudent(Student student) { requireNonNull(student); if (this.student == null) { this.student = student; diff --git a/src/main/java/seedu/address/ui/BlankDetailsPanel.java b/src/main/java/seedu/address/ui/BlankDetailsPanel.java index c65244fe78f..5f4ff4833c1 100644 --- a/src/main/java/seedu/address/ui/BlankDetailsPanel.java +++ b/src/main/java/seedu/address/ui/BlankDetailsPanel.java @@ -3,7 +3,7 @@ import javafx.scene.layout.Region; /** - * An UI component that displays information of a {@code Person}. + * An UI component that displays information of a {@code Student}. */ public class BlankDetailsPanel extends UiPart { @@ -11,7 +11,7 @@ public class BlankDetailsPanel extends UiPart { /** - * Creates a {@code PersonCode} with the given {@code Person} and index to display. + * Creates a {@code StudentCode} with the given {@code Student} and index to display. */ public BlankDetailsPanel() { super(FXML); diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 91a6b9346f4..ffa34b81037 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -16,7 +16,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.student.Student; /** * The Main Window. Provides the basic application layout containing @@ -46,7 +46,7 @@ public class MainWindow extends UiPart { private StackPane studentListPanelPlaceholder; @FXML - private StackPane personDetailsPanelPlaceholder; + private StackPane studentDetailsPanelPlaceholder; @FXML private StackPane resultDisplayPlaceholder; @@ -118,7 +118,7 @@ void fillInnerParts() { studentListPanelPlaceholder.getChildren().add(studentListPanel.getRoot()); BlankDetailsPanel blankDetailsPanel = new BlankDetailsPanel(); - personDetailsPanelPlaceholder.getChildren().add(blankDetailsPanel.getRoot()); + studentDetailsPanelPlaceholder.getChildren().add(blankDetailsPanel.getRoot()); resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); @@ -131,13 +131,13 @@ void fillInnerParts() { } /** - * Updates the details panel to the selected person. + * Updates the details panel to the selected student. */ - private void updateDetailsPanel(Person person, int index) { - personDetailsPanelPlaceholder.getChildren().clear(); + private void updateDetailsPanel(Student student, int index) { + studentDetailsPanelPlaceholder.getChildren().clear(); - PersonDetailsPanel personDetailsPanel = new PersonDetailsPanel(person, index + 1); - personDetailsPanelPlaceholder.getChildren().add(personDetailsPanel.getRoot()); + StudentDetailsPanel studentDetailsPanel = new StudentDetailsPanel(student, index + 1); + studentDetailsPanelPlaceholder.getChildren().add(studentDetailsPanel.getRoot()); } /** @@ -195,8 +195,8 @@ private CommandResult executeCommand(String commandText) throws CommandException logger.info("Result: " + commandResult.getFeedbackToUser()); resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser()); - if (commandResult.isPerson()) { - updateDetailsPanel(commandResult.getPerson(), commandResult.getPersonIndex()); + if (commandResult.getStudent()) { + updateDetailsPanel(commandResult.getCurStudent(), commandResult.getStudentIndex()); } if (commandResult.isShowHelp()) { diff --git a/src/main/java/seedu/address/ui/PersonDetailsPanel.java b/src/main/java/seedu/address/ui/StudentDetailsPanel.java similarity index 65% rename from src/main/java/seedu/address/ui/PersonDetailsPanel.java rename to src/main/java/seedu/address/ui/StudentDetailsPanel.java index 3707cfed84c..23e0adc4f82 100644 --- a/src/main/java/seedu/address/ui/PersonDetailsPanel.java +++ b/src/main/java/seedu/address/ui/StudentDetailsPanel.java @@ -7,14 +7,14 @@ 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.student.Student; /** - * A UI component that expands the information of a selected {@code Person}. + * A UI component that expands the information of a selected {@code Student}. */ -public class PersonDetailsPanel extends UiPart { +public class StudentDetailsPanel extends UiPart { - private static final String FXML = "PersonDetailsPanel.fxml"; + private static final String FXML = "StudentDetailsPanel.fxml"; /** * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. @@ -24,7 +24,7 @@ public class PersonDetailsPanel extends UiPart { * @see The issue on AddressBook level 4 */ - public final Person person; + public final Student student; @FXML private HBox cardPane; @@ -42,17 +42,16 @@ public class PersonDetailsPanel extends UiPart { private FlowPane detailsTags; /** - * Creates a {@code PersonCode} with the given {@code Person} and index to display. + * Creates a {@code StudentCode} with the given {@code Student} and index to display. */ - public PersonDetailsPanel(Person person, int displayedIndex) { + public StudentDetailsPanel(Student student, int displayedIndex) { super(FXML); - this.person = person; + this.student = student; 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().stream() + name.setText(student.getName().fullName); + phone.setText(student.getPhone().value); + email.setText(student.getEmail().value); + student.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> detailsTags.getChildren().add(new Label(tag.tagName))); } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 7778f666a0a..1832b2f96bf 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -46,11 +46,11 @@
- + - + From 5264193af6f9850aeb75d28a5b2ca052ecea6097 Mon Sep 17 00:00:00 2001 From: Jian Yi Date: Thu, 10 Oct 2024 19:48:14 +0800 Subject: [PATCH 9/9] AddCommand.java: fix checkstyle problem --- src/main/java/seedu/address/logic/commands/AddCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 4c79f4ce81d..a7be2db8ec9 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -2,11 +2,11 @@ import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GRADE; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_SUBJECT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_GRADE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages;