diff --git a/README.md b/README.md index 4502e769dda..0f2f5ab8c42 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,4 @@ CampusConnect not only provides basic contact information storage solutions, but sorting features for quicker and easier organisation and contact retrieval. # Acknowledgements -This project is based on the AddressBook-Level3 project created by the [SE-EDU initiative](https://se-education.org). +This project is based on the CampusConnect project created by the [SE-EDU initiative](https://se-education.org). diff --git a/build.gradle b/build.gradle index 0db3743584e..f19c2b49778 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,7 @@ dependencies { } shadowJar { - archiveFileName = 'addressbook.jar' + archiveFileName = 'CampusConnect.jar' } defaultTasks 'clean', 'test' diff --git a/docs/DevOps.md b/docs/DevOps.md index 8228c845e86..5f1cdd3e266 100644 --- a/docs/DevOps.md +++ b/docs/DevOps.md @@ -76,7 +76,7 @@ Any warnings or errors will be printed out to the console. Here are the steps to create a new release. -1. Update the version number in [`MainApp.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/MainApp.java). +1. Update the version number in [`MainApp.java`](https://github.com/se-edu/CampusConnect/tree/master/src/main/java/seedu/address/MainApp.java). 1. Generate a fat JAR file using Gradle (i.e., `gradlew shadowJar`). 1. Tag the repo with the version number. e.g. `v0.1` 1. [Create a new release using GitHub](https://help.github.com/articles/creating-releases/). Upload the JAR file you created. diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index a3ded733d7b..14afada2618 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -35,7 +35,7 @@ Given below is a quick overview of main components and how they interact with ea **Main components of the architecture** -**`Main`** (consisting of classes [`Main`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/Main.java) and [`MainApp`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/MainApp.java)) is in charge of the app launch and shut down. +**`Main`** (consisting of classes [`Main`](https://github.com/se-edu/CampusConnect/tree/master/src/main/java/seedu/address/Main.java) and [`MainApp`](https://github.com/se-edu/CampusConnect/tree/master/src/main/java/seedu/address/MainApp.java)) is in charge of the app launch and shut down. * At app launch, it initializes the other components in the correct sequence, and connects them up with each other. * At shut down, it shuts down the other components and invokes cleanup methods where necessary. @@ -67,13 +67,13 @@ The sections below give more details of each component. ### UI component -The **API** of this component is specified in [`Ui.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/ui/Ui.java) +The **API** of this component is specified in [`Ui.java`](https://github.com/se-edu/CampusConnect/tree/master/src/main/java/seedu/address/ui/Ui.java) The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `PersonListPanel`, `StatusBarFooter` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class which captures the commonalities between classes that represent parts of the visible GUI. -The `UI` component uses the JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that are in the `src/main/resources/view` folder. For example, the layout of the [`MainWindow`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/ui/MainWindow.java) is specified in [`MainWindow.fxml`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/resources/view/MainWindow.fxml) +The `UI` component uses the JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that are in the `src/main/resources/view` folder. For example, the layout of the [`MainWindow`](https://github.com/se-edu/CampusConnect/tree/master/src/main/java/seedu/address/ui/MainWindow.java) is specified in [`MainWindow.fxml`](https://github.com/se-edu/CampusConnect/tree/master/src/main/resources/view/MainWindow.fxml) The `UI` component, @@ -84,7 +84,7 @@ The `UI` component, ### Logic component -**API** : [`Logic.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/logic/Logic.java) +**API** : [`Logic.java`](https://github.com/se-edu/CampusConnect/tree/master/src/main/java/seedu/address/logic/Logic.java) Here's a (partial) class diagram of the `Logic` component: @@ -101,7 +101,7 @@ The sequence diagram below illustrates the interactions within the `Logic` compo 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. When `Logic` is called upon to execute a command, it is passed to an `CampusConnectParser` 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).
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. @@ -112,11 +112,11 @@ Here are the other classes in `Logic` (omitted from the class diagram above) tha How the parsing works: -* When called upon to parse a user command, the `AddressBookParser` class creates an `XYZCommandParser` (`XYZ` is a placeholder for the specific command name e.g., `AddCommandParser`) which uses the other classes shown above to parse the user command and create a `XYZCommand` object (e.g., `AddCommand`) which the `AddressBookParser` returns back as a `Command` object. +* When called upon to parse a user command, the `CampusConnectParser` class creates an `XYZCommandParser` (`XYZ` is a placeholder for the specific command name e.g., `AddCommandParser`) which uses the other classes shown above to parse the user command and create a `XYZCommand` object (e.g., `AddCommand`) which the `CampusConnectParser` returns back as a `Command` object. * All `XYZCommandParser` classes (e.g., `AddCommandParser`, `DeleteCommandParser`, ...) inherit from the `Parser` interface so that they can be treated similarly where possible e.g, during testing. ### Model component -**API** : [`Model.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/model/Model.java) +**API** : [`Model.java`](https://github.com/se-edu/CampusConnect/tree/master/src/main/java/seedu/address/model/Model.java) @@ -130,7 +130,7 @@ The `Model` component, -**Note:** An alternative (arguably, a more OOP) model is given below. It has a `Tag` list in the `AddressBook`, which `Person` references. This allows `AddressBook` to only require one `Tag` object per unique tag, instead of each `Person` needing their own `Tag` objects.
+**Note:** An alternative (arguably, a more OOP) model is given below. It has a `Tag` list in the `CampusConnect`, which `Person` references. This allows `CampusConnect` to only require one `Tag` object per unique tag, instead of each `Person` needing their own `Tag` objects.
@@ -139,13 +139,13 @@ The `Model` component, ### Storage component -**API** : [`Storage.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/storage/Storage.java) +**API** : [`Storage.java`](https://github.com/se-edu/CampusConnect/tree/master/src/main/java/seedu/address/storage/Storage.java) The `Storage` component, * can save both address book data and user preference data in JSON format, and read them back into corresponding objects. -* inherits from both `AddressBookStorage` and `UserPrefStorage`, which means it can be treated as either one (if only the functionality of only one is needed). +* inherits from both `CampusConnectStorage` and `UserPrefStorage`, which means it can be treated as either one (if only the functionality of only one is needed). * depends on some classes in the `Model` component (because the `Storage` component's job is to save/retrieve objects that belong to the `Model`) ### Common classes @@ -162,42 +162,42 @@ This section describes some noteworthy details on how certain features are imple #### Proposed Implementation -The proposed undo/redo mechanism is facilitated by `VersionedAddressBook`. It extends `AddressBook` with an undo/redo history, stored internally as an `addressBookStateList` and `currentStatePointer`. Additionally, it implements the following operations: +The proposed undo/redo mechanism is facilitated by `VersionedCampusConnect`. It extends `CampusConnect` with an undo/redo history, stored internally as an `CampusConnectStateList` and `currentStatePointer`. Additionally, it implements the following operations: -* `VersionedAddressBook#commit()` — Saves the current address book state in its history. -* `VersionedAddressBook#undo()` — Restores the previous address book state from its history. -* `VersionedAddressBook#redo()` — Restores a previously undone address book state from its history. +* `VersionedCampusConnect#commit()` — Saves the current address book state in its history. +* `VersionedCampusConnect#undo()` — Restores the previous address book state from its history. +* `VersionedCampusConnect#redo()` — Restores a previously undone address book state from its history. -These operations are exposed in the `Model` interface as `Model#commitAddressBook()`, `Model#undoAddressBook()` and `Model#redoAddressBook()` respectively. +These operations are exposed in the `Model` interface as `Model#commitCampusConnect()`, `Model#undoCampusConnect()` and `Model#redoCampusConnect()` respectively. Given below is an example usage scenario and how the undo/redo mechanism behaves at each step. -Step 1. The user launches the application for the first time. The `VersionedAddressBook` will be initialized with the initial address book state, and the `currentStatePointer` pointing to that single address book state. +Step 1. The user launches the application for the first time. The `VersionedCampusConnect` will be initialized with the initial CampusConnect state, and the `currentStatePointer` pointing to that single address book state. -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 person in the address book. The `delete` command calls `Model#commitCampusConnect()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `campusConnectStateList`, 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 person. The `add` command also calls `Model#commitCampusConnect()`, causing another modified address book state to be saved into the `campusConnectStateList`. -**Note:** If a command fails its execution, it will not call `Model#commitAddressBook()`, so the address book state will not be saved into the `addressBookStateList`. +**Note:** If a command fails its execution, it will not call `Model#commitCampusConnect()`, so the CampusConnect state will not be saved into the `campusConnectStateList`. -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 person was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoCampusConnect()`, 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. -**Note:** If the `currentStatePointer` is at index 0, pointing to the initial AddressBook state, then there are no previous AddressBook states to restore. The `undo` command uses `Model#canUndoAddressBook()` to check if this is the case. If so, it will return an error to the user rather +**Note:** If the `currentStatePointer` is at index 0, pointing to the initial CampusConnect state, then there are no previous CampusConnect states to restore. The `undo` command uses `Model#canUndoCampusConnect()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the undo. @@ -216,19 +216,19 @@ Similarly, how an undo operation goes through the `Model` component is shown bel -The `redo` command does the opposite — it calls `Model#redoAddressBook()`, which shifts the `currentStatePointer` once to the right, pointing to the previously undone state, and restores the address book to that state. +The `redo` command does the opposite — it calls `Model#redoCampusConnect()`, which shifts the `currentStatePointer` once to the right, pointing to the previously undone state, and restores the address book to that state. -**Note:** If the `currentStatePointer` is at index `addressBookStateList.size() - 1`, pointing to the latest address book state, then there are no undone AddressBook states to restore. The `redo` command uses `Model#canRedoAddressBook()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo. +**Note:** If the `currentStatePointer` is at index `campusConnectStateList.size() - 1`, pointing to the latest CampusConnect state, then there are no undone CampusConnect states to restore. The `redo` command uses `Model#canRedoCampusConnect()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo. -Step 5. The user then decides to execute the command `list`. Commands that do not modify the address book, such as `list`, will usually not call `Model#commitAddressBook()`, `Model#undoAddressBook()` or `Model#redoAddressBook()`. Thus, the `addressBookStateList` remains unchanged. +Step 5. The user then decides to execute the command `list`. Commands that do not modify the address book, such as `list`, will usually not call `Model#commitCampusConnect()`, `Model#undoCampusConnect()` or `Model#redoCampusConnect()`. Thus, the `campusConnectStateList` remains unchanged. -Step 6. The user executes `clear`, which calls `Model#commitAddressBook()`. Since the `currentStatePointer` is not pointing at the end of the `addressBookStateList`, all address book states after the `currentStatePointer` will be purged. Reason: It no longer makes sense to redo the `add n/David …​` command. This is the behavior that most modern desktop applications follow. +Step 6. The user executes `clear`, which calls `Model#commitCampusConnect()`. Since the `currentStatePointer` is not pointing at the end of the `campusConnectStateList`, all address book states after the `currentStatePointer` will be purged. Reason: It no longer makes sense to redo the `add n/David …​` command. This is the behavior that most modern desktop applications follow. diff --git a/docs/SettingUp.md b/docs/SettingUp.md index 9e30139d075..401e42ce34d 100644 --- a/docs/SettingUp.md +++ b/docs/SettingUp.md @@ -52,7 +52,7 @@ If you plan to use Intellij IDEA (highly recommended): 1. **Learn the design** - When you are ready to start coding, we recommend that you get some sense of the overall design by reading about [AddressBook’s architecture](DeveloperGuide.md#architecture). + When you are ready to start coding, we recommend that you get some sense of the overall design by reading about [CampusConnect’s architecture](DeveloperGuide.md#architecture). 1. **Do the tutorials** These tutorials will help you get acquainted with the codebase. diff --git a/docs/UserGuide.md b/docs/UserGuide.md index bceb5e3c26e..69a5b15b0a5 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -4,9 +4,9 @@ pageNav: 3 --- -# AB-3 User Guide +# CampusConnect User Guide -AddressBook Level 3 (AB3) is a **desktop app for managing contacts, optimized for use via a Line Interface** (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, AB3 can get your contact management tasks done faster than traditional GUI apps. +CampusConnect(CC) is a **desktop app for managing contacts, optimized for use via a Line Interface** (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, AB3 can get your contact management tasks done faster than traditional GUI apps. @@ -17,11 +17,11 @@ AddressBook Level 3 (AB3) is a **desktop app for managing contacts, optimized fo 1. Ensure you have Java `17` or above installed in your Computer. -1. Download the latest `.jar` file from [here](https://github.com/se-edu/addressbook-level3/releases). +1. Download the latest `.jar` file from [here](https://github.com/se-edu/CampusConnect/releases). -1. Copy the file to the folder you want to use as the _home folder_ for your AddressBook. +1. Copy the file to the folder you want to use as the _home folder_ for your CampusConnect. -1. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar addressbook.jar` command to run the application.
+1. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar CampusConnect.jar` command to run the application.
A GUI similar to the below should appear in a few seconds. Note how the app contains some sample data.
![Ui](images/Ui.png) @@ -159,17 +159,17 @@ Format: `exit` ### Saving the data -AddressBook data are saved in the hard disk automatically after any command that changes the data. There is no need to save manually. +CampusConnect data are saved in the hard disk automatically after any command that changes the data. There is no need to save manually. ### Editing the data file -AddressBook data are saved automatically as a JSON file `[JAR file location]/data/addressbook.json`. Advanced users are welcome to update data directly by editing that data file. +CampusConnect data are saved automatically as a JSON file `[JAR file location]/data/CampusConnect.json`. Advanced users are welcome to update data directly by editing that data file. **Caution:** -If your changes to the data file makes its format invalid, AddressBook will discard all data and start with an empty data file at the next run. Hence, it is recommended to take a backup of the file before editing it.
-Furthermore, certain edits can cause the AddressBook to behave in unexpected ways (e.g., if a value entered is outside the acceptable range). Therefore, edit the data file only if you are confident that you can update it correctly. +If your changes to the data file makes its format invalid, CampusConnect will discard all data and start with an empty data file at the next run. Hence, it is recommended to take a backup of the file before editing it.
+Furthermore, certain edits can cause the CampusConnect to behave in unexpected ways (e.g., if a value entered is outside the acceptable range). Therefore, edit the data file only if you are confident that you can update it correctly.
### Archiving data files `[coming in v2.0]` @@ -181,7 +181,7 @@ _Details coming soon ..._ ## FAQ **Q**: How do I transfer my data to another Computer?
-**A**: Install the app in the other computer and overwrite the empty data file it creates with the file that contains the data of your previous AddressBook home folder. +**A**: Install the app in the other computer and overwrite the empty data file it creates with the file that contains the data of your previous CampusConnect home folder. -------------------------------------------------------------------------------------------------------------------- diff --git a/docs/diagrams/ArchitectureSequenceDiagram.puml b/docs/diagrams/ArchitectureSequenceDiagram.puml index 48b6cc4333c..0ee4f7b76bc 100644 --- a/docs/diagrams/ArchitectureSequenceDiagram.puml +++ b/docs/diagrams/ArchitectureSequenceDiagram.puml @@ -20,7 +20,7 @@ activate model MODEL_COLOR model -[MODEL_COLOR]-> logic deactivate model -logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook) +logic -[LOGIC_COLOR]> storage : saveCampusConnect(campusConnect) activate storage STORAGE_COLOR storage -[STORAGE_COLOR]> storage : Save to file diff --git a/docs/diagrams/BetterModelClassDiagram.puml b/docs/diagrams/BetterModelClassDiagram.puml index 598474a5c82..eb630665c94 100644 --- a/docs/diagrams/BetterModelClassDiagram.puml +++ b/docs/diagrams/BetterModelClassDiagram.puml @@ -4,8 +4,8 @@ skinparam arrowThickness 1.1 skinparam arrowColor MODEL_COLOR skinparam classBackgroundColor MODEL_COLOR -AddressBook *-right-> "1" UniquePersonList -AddressBook *-right-> "1" UniqueTagList +CampusConnect *-right-> "1" UniquePersonList +CampusConnect *-right-> "1" UniqueTagList UniqueTagList -[hidden]down- UniquePersonList UniqueTagList -[hidden]down- UniquePersonList diff --git a/docs/diagrams/CommitActivityDiagram.puml b/docs/diagrams/CommitActivityDiagram.puml index 8c0892d6a70..3823313f3ae 100644 --- a/docs/diagrams/CommitActivityDiagram.puml +++ b/docs/diagrams/CommitActivityDiagram.puml @@ -8,10 +8,10 @@ start 'Since the beta syntax does not support placing the condition outside the 'diamond we place it as the true branch instead. -if () then ([command commits AddressBook]) +if () then ([command commits CampusConnect]) :Purge redundant states; - :Save AddressBook to - addressBookStateList; + :Save CampusConnect to + campusConnectStateList; else ([else]) endif stop diff --git a/docs/diagrams/DeleteSequenceDiagram.puml b/docs/diagrams/DeleteSequenceDiagram.puml index 5241e79d7da..324af59f0bf 100644 --- a/docs/diagrams/DeleteSequenceDiagram.puml +++ b/docs/diagrams/DeleteSequenceDiagram.puml @@ -4,7 +4,7 @@ skinparam ArrowFontStyle plain box Logic LOGIC_COLOR_T1 participant ":LogicManager" as LogicManager LOGIC_COLOR -participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR +participant ":CampusConnectParser" as CampusConnectParser LOGIC_COLOR participant ":DeleteCommandParser" as DeleteCommandParser LOGIC_COLOR participant "d:DeleteCommand" as DeleteCommand LOGIC_COLOR participant "r:CommandResult" as CommandResult LOGIC_COLOR @@ -17,17 +17,17 @@ end box [-> LogicManager : execute("delete 1") activate LogicManager -LogicManager -> AddressBookParser : parseCommand("delete 1") -activate AddressBookParser +LogicManager -> CampusConnectParser : parseCommand("delete 1") +activate CampusConnectParser create DeleteCommandParser -AddressBookParser -> DeleteCommandParser +CampusConnectParser -> DeleteCommandParser activate DeleteCommandParser -DeleteCommandParser --> AddressBookParser +DeleteCommandParser --> CampusConnectParser deactivate DeleteCommandParser -AddressBookParser -> DeleteCommandParser : parse("1") +CampusConnectParser -> DeleteCommandParser : parse("1") activate DeleteCommandParser create DeleteCommand @@ -37,14 +37,14 @@ activate DeleteCommand DeleteCommand --> DeleteCommandParser : deactivate DeleteCommand -DeleteCommandParser --> AddressBookParser : d +DeleteCommandParser --> CampusConnectParser : d deactivate DeleteCommandParser 'Hidden arrow to position the destroy marker below the end of the activation bar. -DeleteCommandParser -[hidden]-> AddressBookParser +DeleteCommandParser -[hidden]-> CampusConnectParser destroy DeleteCommandParser -AddressBookParser --> LogicManager : d -deactivate AddressBookParser +CampusConnectParser --> LogicManager : d +deactivate CampusConnectParser LogicManager -> DeleteCommand : execute(m) activate DeleteCommand diff --git a/docs/diagrams/ModelClassDiagram.puml b/docs/diagrams/ModelClassDiagram.puml index 0de5673070d..3f3bf579251 100644 --- a/docs/diagrams/ModelClassDiagram.puml +++ b/docs/diagrams/ModelClassDiagram.puml @@ -5,10 +5,10 @@ skinparam arrowColor MODEL_COLOR skinparam classBackgroundColor MODEL_COLOR Package Model as ModelPackage <>{ -Class "<>\nReadOnlyAddressBook" as ReadOnlyAddressBook +Class "<>\nReadOnlyCampusConnect" as ReadOnlyCampusConnect Class "<>\nReadOnlyUserPrefs" as ReadOnlyUserPrefs Class "<>\nModel" as Model -Class AddressBook +Class CampusConnect Class ModelManager Class UserPrefs @@ -26,16 +26,16 @@ Class I #FFFFFF Class HiddenOutside #FFFFFF HiddenOutside ..> Model -AddressBook .up.|> ReadOnlyAddressBook +CampusConnect .up.|> ReadOnlyCampusConnect ModelManager .up.|> Model Model .right.> ReadOnlyUserPrefs -Model .left.> ReadOnlyAddressBook -ModelManager -left-> "1" AddressBook +Model .left.> ReadOnlyCampusConnect +ModelManager -left-> "1" CampusConnect ModelManager -right-> "1" UserPrefs UserPrefs .up.|> ReadOnlyUserPrefs -AddressBook *--> "1" UniquePersonList +CampusConnect *--> "1" UniquePersonList UniquePersonList --> "~* all" Person Person *--> Name Person *--> Phone diff --git a/docs/diagrams/ParserClasses.puml b/docs/diagrams/ParserClasses.puml index ce4c5ce8c8d..4e756fe94c0 100644 --- a/docs/diagrams/ParserClasses.puml +++ b/docs/diagrams/ParserClasses.puml @@ -9,7 +9,7 @@ Class XYZCommand package "Parser classes"{ Class "<>\nParser" as Parser -Class AddressBookParser +Class CampusConnectParser Class XYZCommandParser Class CliSyntax Class ParserUtil @@ -19,12 +19,12 @@ Class Prefix } Class HiddenOutside #FFFFFF -HiddenOutside ..> AddressBookParser +HiddenOutside ..> CampusConnectParser -AddressBookParser .down.> XYZCommandParser: <> +CampusConnectParser .down.> XYZCommandParser: <> XYZCommandParser ..> XYZCommand : <> -AddressBookParser ..> Command : <> +CampusConnectParser ..> Command : <> XYZCommandParser .up.|> Parser XYZCommandParser ..> ArgumentMultimap XYZCommandParser ..> ArgumentTokenizer diff --git a/docs/diagrams/StorageClassDiagram.puml b/docs/diagrams/StorageClassDiagram.puml index a821e06458c..052c052b858 100644 --- a/docs/diagrams/StorageClassDiagram.puml +++ b/docs/diagrams/StorageClassDiagram.puml @@ -14,10 +14,10 @@ Class JsonUserPrefsStorage Class "<>\nStorage" as Storage Class StorageManager -package "AddressBook Storage" #F4F6F6{ -Class "<>\nAddressBookStorage" as AddressBookStorage -Class JsonAddressBookStorage -Class JsonSerializableAddressBook +package "CampusConnect Storage" #F4F6F6{ +Class "<>\nCampusConnectStorage" as CampusConnectStorage +Class JsonCampusConnectStorage +Class JsonSerializableCampusConnect Class JsonAdaptedPerson Class JsonAdaptedTag } @@ -29,15 +29,15 @@ HiddenOutside ..> Storage StorageManager .up.|> Storage StorageManager -up-> "1" UserPrefsStorage -StorageManager -up-> "1" AddressBookStorage +StorageManager -up-> "1" CampusConnectStorage Storage -left-|> UserPrefsStorage -Storage -right-|> AddressBookStorage +Storage -right-|> CampusConnectStorage JsonUserPrefsStorage .up.|> UserPrefsStorage -JsonAddressBookStorage .up.|> AddressBookStorage -JsonAddressBookStorage ..> JsonSerializableAddressBook -JsonSerializableAddressBook --> "*" JsonAdaptedPerson +JsonCampusConnectStorage .up.|> CampusConnectStorage +JsonCampusConnectStorage ..> JsonSerializableCampusConnect +JsonSerializableCampusConnect --> "*" JsonAdaptedPerson JsonAdaptedPerson --> "*" JsonAdaptedTag @enduml diff --git a/docs/diagrams/UndoRedoState0.puml b/docs/diagrams/UndoRedoState0.puml index 43a45903ac9..18e5aae77d0 100644 --- a/docs/diagrams/UndoRedoState0.puml +++ b/docs/diagrams/UndoRedoState0.puml @@ -7,9 +7,9 @@ skinparam ClassBackgroundColor #FFFFAA title Initial state package States { - class State1 as "ab0:AddressBook" - class State2 as "ab1:AddressBook" - class State3 as "ab2:AddressBook" + class State1 as "ab0:CampusConnect" + class State2 as "ab1:CampusConnect" + class State3 as "ab2:CampusConnect" } State1 -[hidden]right-> State2 State2 -[hidden]right-> State3 diff --git a/docs/diagrams/UndoRedoState1.puml b/docs/diagrams/UndoRedoState1.puml index 5a41e9e1651..560177304f8 100644 --- a/docs/diagrams/UndoRedoState1.puml +++ b/docs/diagrams/UndoRedoState1.puml @@ -7,9 +7,9 @@ skinparam ClassBackgroundColor #FFFFAA title After command "delete 5" package States <> { - class State1 as "ab0:AddressBook" - class State2 as "ab1:AddressBook" - class State3 as "ab2:AddressBook" + class State1 as "ab0:CampusConnect" + class State2 as "ab1:CampusConnect" + class State3 as "ab2:CampusConnect" } State1 -[hidden]right-> State2 diff --git a/docs/diagrams/UndoRedoState2.puml b/docs/diagrams/UndoRedoState2.puml index ad32fce1b0b..cfda350d855 100644 --- a/docs/diagrams/UndoRedoState2.puml +++ b/docs/diagrams/UndoRedoState2.puml @@ -7,9 +7,9 @@ skinparam ClassBackgroundColor #FFFFAA title After command "add n/David" package States <> { - class State1 as "ab0:AddressBook" - class State2 as "ab1:AddressBook" - class State3 as "ab2:AddressBook" + class State1 as "ab0:CampusConnect" + class State2 as "ab1:CampusConnect" + class State3 as "ab2:CampusConnect" } State1 -[hidden]right-> State2 diff --git a/docs/diagrams/UndoRedoState3.puml b/docs/diagrams/UndoRedoState3.puml index 9187a690036..d859d38827e 100644 --- a/docs/diagrams/UndoRedoState3.puml +++ b/docs/diagrams/UndoRedoState3.puml @@ -7,9 +7,9 @@ skinparam ClassBackgroundColor #FFFFAA title After command "undo" package States <> { - class State1 as "ab0:AddressBook" - class State2 as "ab1:AddressBook" - class State3 as "ab2:AddressBook" + class State1 as "ab0:CampusConnect" + class State2 as "ab1:CampusConnect" + class State3 as "ab2:CampusConnect" } State1 -[hidden]right-> State2 diff --git a/docs/diagrams/UndoRedoState4.puml b/docs/diagrams/UndoRedoState4.puml index 2bc631ffcd0..4e70042b776 100644 --- a/docs/diagrams/UndoRedoState4.puml +++ b/docs/diagrams/UndoRedoState4.puml @@ -7,9 +7,9 @@ skinparam ClassBackgroundColor #FFFFAA title After command "list" package States <> { - class State1 as "ab0:AddressBook" - class State2 as "ab1:AddressBook" - class State3 as "ab2:AddressBook" + class State1 as "ab0:CampusConnect" + class State2 as "ab1:CampusConnect" + class State3 as "ab2:CampusConnect" } State1 -[hidden]right-> State2 diff --git a/docs/diagrams/UndoRedoState5.puml b/docs/diagrams/UndoRedoState5.puml index e77b04104aa..503b638fb2a 100644 --- a/docs/diagrams/UndoRedoState5.puml +++ b/docs/diagrams/UndoRedoState5.puml @@ -7,9 +7,9 @@ skinparam ClassBackgroundColor #FFFFAA title After command "clear" package States <> { - class State1 as "ab0:AddressBook" - class State2 as "ab1:AddressBook" - class State3 as "ab3:AddressBook" + class State1 as "ab0:CampusConnect" + class State2 as "ab1:CampusConnect" + class State3 as "ab3:CampusConnect" } State1 -[hidden]right-> State2 diff --git a/docs/diagrams/UndoSequenceDiagram-Logic.puml b/docs/diagrams/UndoSequenceDiagram-Logic.puml index e57368c5159..56118fbb8a0 100644 --- a/docs/diagrams/UndoSequenceDiagram-Logic.puml +++ b/docs/diagrams/UndoSequenceDiagram-Logic.puml @@ -4,7 +4,7 @@ skinparam ArrowFontStyle plain box Logic LOGIC_COLOR_T1 participant ":LogicManager" as LogicManager LOGIC_COLOR -participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR +participant ":CampusConnectParser" as CampusConnectParser LOGIC_COLOR participant "u:UndoCommand" as UndoCommand LOGIC_COLOR end box @@ -14,23 +14,23 @@ end box [-> LogicManager : execute(undo) activate LogicManager -LogicManager -> AddressBookParser : parseCommand(undo) -activate AddressBookParser +LogicManager -> CampusConnectParser : parseCommand(undo) +activate CampusConnectParser create UndoCommand -AddressBookParser -> UndoCommand +CampusConnectParser -> UndoCommand activate UndoCommand -UndoCommand --> AddressBookParser +UndoCommand --> CampusConnectParser deactivate UndoCommand -AddressBookParser --> LogicManager : u -deactivate AddressBookParser +CampusConnectParser --> LogicManager : u +deactivate CampusConnectParser LogicManager -> UndoCommand : execute() activate UndoCommand -UndoCommand -> Model : undoAddressBook() +UndoCommand -> Model : undoCampusConnect() activate Model Model --> UndoCommand diff --git a/docs/diagrams/UndoSequenceDiagram-Model.puml b/docs/diagrams/UndoSequenceDiagram-Model.puml index 54d83208cb8..d354857777b 100644 --- a/docs/diagrams/UndoSequenceDiagram-Model.puml +++ b/docs/diagrams/UndoSequenceDiagram-Model.puml @@ -4,18 +4,18 @@ skinparam ArrowFontStyle plain box Model MODEL_COLOR_T1 participant ":Model" as Model MODEL_COLOR -participant ":VersionedAddressBook" as VersionedAddressBook MODEL_COLOR +participant ":VersionedCampusConnect" as VersionedCampusConnect MODEL_COLOR end box -[-> Model : undoAddressBook() +[-> Model : undoCampusConnect() activate Model -Model -> VersionedAddressBook : undo() -activate VersionedAddressBook +Model -> VersionedCampusConnect : undo() +activate VersionedCampusConnect -VersionedAddressBook -> VersionedAddressBook :resetData(ReadOnlyAddressBook) -VersionedAddressBook --> Model : -deactivate VersionedAddressBook +VersionedCampusConnect -> VersionedCampusConnect :resetData(ReadOnlyCampusConnect) +VersionedCampusConnect --> Model : +deactivate VersionedCampusConnect [<-- Model deactivate Model diff --git a/docs/diagrams/tracing/LogicSequenceDiagram.puml b/docs/diagrams/tracing/LogicSequenceDiagram.puml index 42bf46d3ce8..d5ab23bf551 100644 --- a/docs/diagrams/tracing/LogicSequenceDiagram.puml +++ b/docs/diagrams/tracing/LogicSequenceDiagram.puml @@ -3,7 +3,7 @@ skinparam ArrowFontStyle plain Participant ":LogicManager" as logic LOGIC_COLOR -Participant ":AddressBookParser" as abp LOGIC_COLOR +Participant ":CampusConnectParser" as abp LOGIC_COLOR Participant ":EditCommandParser" as ecp LOGIC_COLOR Participant "command:EditCommand" as ec LOGIC_COLOR diff --git a/docs/index.md b/docs/index.md index 8acbdd73507..62d79020a84 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,17 +3,17 @@ title: "" --- -# AddressBook Level-3 +# CampusConnect -[![CI Status](https://github.com/se-edu/addressbook-level3/workflows/Java%20CI/badge.svg)](https://github.com/se-edu/addressbook-level3/actions) -[![codecov](https://codecov.io/gh/se-edu/addressbook-level3/branch/master/graph/badge.svg)](https://codecov.io/gh/se-edu/addressbook-level3) +[![CI Status](https://github.com/se-edu/CampusConnect/workflows/Java%20CI/badge.svg)](https://github.com/se-edu/CampusConnect/actions) +[![codecov](https://codecov.io/gh/se-edu/CampusConnect/branch/master/graph/badge.svg)](https://codecov.io/gh/se-edu/CampusConnect) ![Ui](images/Ui.png) -**AddressBook is a desktop application for managing your contact details.** While it has a GUI, most of the user interactions happen using a CLI (Command Line Interface). +**CampusConnect is a desktop application for managing your contact details.** While it has a GUI, most of the user interactions happen using a CLI (Command Line Interface). -* If you are interested in using AddressBook, head over to the [_Quick Start_ section of the **User Guide**](UserGuide.html#quick-start). -* If you are interested about developing AddressBook, the [**Developer Guide**](DeveloperGuide.html) is a good place to start. +* If you are interested in using CampusConnect, head over to the [_Quick Start_ section of the **User Guide**](UserGuide.html#quick-start). +* If you are interested about developing CampusConnect, the [**Developer Guide**](DeveloperGuide.html) is a good place to start. **Acknowledgements** diff --git a/docs/site.json b/docs/site.json index 20ede81a684..d8c4b722752 100644 --- a/docs/site.json +++ b/docs/site.json @@ -1,7 +1,7 @@ { "baseUrl": "", "titlePrefix": "CampusConnect", - "titleSuffix": "AddressBook Level-3", + "titleSuffix": "CampusConnect Level-3", "faviconPath": "images/SeEduLogo.png", "style": { "codeTheme": "light" diff --git a/docs/team/blackpanther9229.md b/docs/team/blackpanther9229.md index ce9e5b06812..7f2ad055ea0 100644 --- a/docs/team/blackpanther9229.md +++ b/docs/team/blackpanther9229.md @@ -3,4 +3,4 @@ title: "Nguyen's Project Portfolio Page" --- -### Project: AddressBook Level 3 +### Project: CampusConnect diff --git a/docs/team/johndoe.md b/docs/team/johndoe.md deleted file mode 100644 index 86aa7ebfc34..00000000000 --- a/docs/team/johndoe.md +++ /dev/null @@ -1,46 +0,0 @@ ---- - layout: default.md - title: "John Doe's Project Portfolio Page" ---- - -### Project: AddressBook Level 3 - -AddressBook - Level 3 is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC. - -Given below are my contributions to the project. - -* **New Feature**: Added the ability to undo/redo previous commands. - * What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command. - * Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them. - * Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands. - * Credits: *{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}* - -* **New Feature**: Added a history command that allows the user to navigate to previous commands using up/down keys. - -* **Code contributed**: [RepoSense link]() - -* **Project management**: - * Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub - -* **Enhancements to existing features**: - * Updated the GUI color scheme (Pull requests [\#33](), [\#34]()) - * Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests [\#36](), [\#38]()) - -* **Documentation**: - * User Guide: - * Added documentation for the features `delete` and `find` [\#72]() - * Did cosmetic tweaks to existing documentation of features `clear`, `exit`: [\#74]() - * Developer Guide: - * Added implementation details of the `delete` feature. - -* **Community**: - * PRs reviewed (with non-trivial review comments): [\#12](), [\#32](), [\#19](), [\#42]() - * Contributed to forum discussions (examples: [1](), [2](), [3](), [4]()) - * Reported bugs and suggestions for other teams in the class (examples: [1](), [2](), [3]()) - * Some parts of the history feature I added was adopted by several other class mates ([1](), [2]()) - -* **Tools**: - * Integrated a third party library (Natty) to the project ([\#42]()) - * Integrated a new Github plugin (CircleCI) to the team repo - -* _{you can add/remove categories in the list above}_ diff --git a/docs/team/justin.md b/docs/team/justin.md index cda42af2688..1848d64ba20 100644 --- a/docs/team/justin.md +++ b/docs/team/justin.md @@ -3,4 +3,4 @@ title: "Justin's Project Portfolio Page" --- -### Project: AddressBook Level 3 +### Project: CampusConnect diff --git a/docs/team/krashkart.md b/docs/team/krashkart.md index 86aa7ebfc34..a5f61240fcb 100644 --- a/docs/team/krashkart.md +++ b/docs/team/krashkart.md @@ -3,9 +3,9 @@ title: "John Doe's Project Portfolio Page" --- -### Project: AddressBook Level 3 +### Project: CampusConnect -AddressBook - Level 3 is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC. +CampusConnect is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC. Given below are my contributions to the project. diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index e84ad2b9b43..173fa156ced 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -15,15 +15,15 @@ import seedu.address.commons.util.StringUtil; import seedu.address.logic.Logic; import seedu.address.logic.LogicManager; -import seedu.address.model.AddressBook; +import seedu.address.model.CampusConnect; import seedu.address.model.Model; import seedu.address.model.ModelManager; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.UserPrefs; import seedu.address.model.util.SampleDataUtil; -import seedu.address.storage.AddressBookStorage; -import seedu.address.storage.JsonAddressBookStorage; +import seedu.address.storage.CampusConnectStorage; +import seedu.address.storage.JsonCampusConnectStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.Storage; import seedu.address.storage.StorageManager; @@ -57,8 +57,8 @@ public void init() throws Exception { UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath()); UserPrefs userPrefs = initPrefs(userPrefsStorage); - AddressBookStorage addressBookStorage = new JsonAddressBookStorage(userPrefs.getAddressBookFilePath()); - storage = new StorageManager(addressBookStorage, userPrefsStorage); + CampusConnectStorage campusConnectStorage = new JsonCampusConnectStorage(userPrefs.getCampusConnectFilePath()); + storage = new StorageManager(campusConnectStorage, userPrefsStorage); model = initModelManager(storage, userPrefs); @@ -73,21 +73,21 @@ public void init() throws Exception { * or an empty address book will be used instead if errors occur when reading {@code storage}'s address book. */ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { - logger.info("Using data file : " + storage.getAddressBookFilePath()); + logger.info("Using data file : " + storage.getCampusConnectFilePath()); - Optional addressBookOptional; - ReadOnlyAddressBook initialData; + Optional campusConnectOptional; + ReadOnlyCampusConnect initialData; try { - addressBookOptional = storage.readAddressBook(); - if (!addressBookOptional.isPresent()) { - logger.info("Creating a new data file " + storage.getAddressBookFilePath() - + " populated with a sample AddressBook."); + campusConnectOptional = storage.readCampusConnect(); + if (!campusConnectOptional.isPresent()) { + logger.info("Creating a new data file " + storage.getCampusConnectFilePath() + + " populated with a sample CampusConnect."); } - initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); + initialData = campusConnectOptional.orElseGet(SampleDataUtil::getSampleCampusConnect); } catch (DataLoadingException e) { - logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded." - + " Will be starting with an empty AddressBook."); - initialData = new AddressBook(); + logger.warning("Data file at " + storage.getCampusConnectFilePath() + " could not be loaded." + + " Will be starting with an empty CampusConnect."); + initialData = new CampusConnect(); } return new ModelManager(initialData, userPrefs); diff --git a/src/main/java/seedu/address/commons/core/LogsCenter.java b/src/main/java/seedu/address/commons/core/LogsCenter.java index 8cf8e15a0f0..9bbce6ef998 100644 --- a/src/main/java/seedu/address/commons/core/LogsCenter.java +++ b/src/main/java/seedu/address/commons/core/LogsCenter.java @@ -20,7 +20,7 @@ public class LogsCenter { private static final int MAX_FILE_COUNT = 5; private static final int MAX_FILE_SIZE_IN_BYTES = (int) (Math.pow(2, 20) * 5); // 5MB - private static final String LOG_FILE = "addressbook.log"; + private static final String LOG_FILE = "CampusConnect.log"; private static final Logger logger; // logger for this class private static Logger baseLogger; // to be used as the parent of all other loggers created by this class. private static Level currentLogLevel = Level.INFO; diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 92cd8fa605a..90e675bc0d3 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -7,7 +7,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.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.person.Person; /** @@ -24,11 +24,11 @@ public interface Logic { CommandResult execute(String commandText) throws CommandException, ParseException; /** - * Returns the AddressBook. + * Returns the CampusConnect. * - * @see seedu.address.model.Model#getAddressBook() + * @see seedu.address.model.Model#getCampusConnect() */ - ReadOnlyAddressBook getAddressBook(); + ReadOnlyCampusConnect getCampusConnect(); /** Returns an unmodifiable view of the filtered list of persons */ ObservableList getFilteredPersonList(); @@ -36,7 +36,7 @@ public interface Logic { /** * Returns the user prefs' address book file path. */ - Path getAddressBookFilePath(); + Path getCampusConnectFilePath(); /** * Returns the user prefs' GUI settings. diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 5aa3b91c7d0..d2ef41f7731 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -11,10 +11,10 @@ import seedu.address.logic.commands.Command; import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; -import seedu.address.logic.parser.AddressBookParser; +import seedu.address.logic.parser.CampusConnectParser; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.person.Person; import seedu.address.storage.Storage; @@ -31,7 +31,7 @@ public class LogicManager implements Logic { private final Model model; private final Storage storage; - private final AddressBookParser addressBookParser; + private final CampusConnectParser campusConnectParser; /** * Constructs a {@code LogicManager} with the given {@code Model} and {@code Storage}. @@ -39,7 +39,7 @@ public class LogicManager implements Logic { public LogicManager(Model model, Storage storage) { this.model = model; this.storage = storage; - addressBookParser = new AddressBookParser(); + campusConnectParser = new CampusConnectParser(); } @Override @@ -47,11 +47,11 @@ public CommandResult execute(String commandText) throws CommandException, ParseE logger.info("----------------[USER COMMAND][" + commandText + "]"); CommandResult commandResult; - Command command = addressBookParser.parseCommand(commandText); + Command command = campusConnectParser.parseCommand(commandText); commandResult = command.execute(model); try { - storage.saveAddressBook(model.getAddressBook()); + storage.saveCampusConnect(model.getCampusConnect()); } catch (AccessDeniedException e) { throw new CommandException(String.format(FILE_OPS_PERMISSION_ERROR_FORMAT, e.getMessage()), e); } catch (IOException ioe) { @@ -62,8 +62,8 @@ public CommandResult execute(String commandText) throws CommandException, ParseE } @Override - public ReadOnlyAddressBook getAddressBook() { - return model.getAddressBook(); + public ReadOnlyCampusConnect getCampusConnect() { + return model.getCampusConnect(); } @Override @@ -72,8 +72,8 @@ public ObservableList getFilteredPersonList() { } @Override - public Path getAddressBookFilePath() { - return model.getAddressBookFilePath(); + public Path getCampusConnectFilePath() { + return model.getCampusConnectFilePath(); } @Override diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index 9c86b1fa6e4..b7377b53126 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -2,7 +2,7 @@ import static java.util.Objects.requireNonNull; -import seedu.address.model.AddressBook; +import seedu.address.model.CampusConnect; import seedu.address.model.Model; /** @@ -17,7 +17,7 @@ public class ClearCommand extends Command { @Override public CommandResult execute(Model model) { requireNonNull(model); - model.setAddressBook(new AddressBook()); + model.setCampusConnect(new CampusConnect()); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/CampusConnectParser.java similarity index 96% rename from src/main/java/seedu/address/logic/parser/AddressBookParser.java rename to src/main/java/seedu/address/logic/parser/CampusConnectParser.java index 95ceec836c1..9456387ecc1 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/CampusConnectParser.java @@ -22,13 +22,13 @@ /** * Parses user input. */ -public class AddressBookParser { +public class CampusConnectParser { /** * Used for initial separation of command word and args. */ private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?\\S+)(?.*)"); - private static final Logger logger = LogsCenter.getLogger(AddressBookParser.class); + private static final Logger logger = LogsCenter.getLogger(CampusConnectParser.class); /** * Parses user input into command for execution. diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/CampusConnect.java similarity index 83% rename from src/main/java/seedu/address/model/AddressBook.java rename to src/main/java/seedu/address/model/CampusConnect.java index 73397161e84..eac63c51638 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/CampusConnect.java @@ -13,7 +13,7 @@ * Wraps all data at the address-book level * Duplicates are not allowed (by .isSamePerson comparison) */ -public class AddressBook implements ReadOnlyAddressBook { +public class CampusConnect implements ReadOnlyCampusConnect { private final UniquePersonList persons; @@ -28,12 +28,12 @@ public class AddressBook implements ReadOnlyAddressBook { persons = new UniquePersonList(); } - public AddressBook() {} + public CampusConnect() {} /** - * Creates an AddressBook using the Persons in the {@code toBeCopied} + * Creates an CampusConnect using the Persons in the {@code toBeCopied} */ - public AddressBook(ReadOnlyAddressBook toBeCopied) { + public CampusConnect(ReadOnlyCampusConnect toBeCopied) { this(); resetData(toBeCopied); } @@ -49,9 +49,9 @@ public void setPersons(List persons) { } /** - * Resets the existing data of this {@code AddressBook} with {@code newData}. + * Resets the existing data of this {@code CampusConnect} with {@code newData}. */ - public void resetData(ReadOnlyAddressBook newData) { + public void resetData(ReadOnlyCampusConnect newData) { requireNonNull(newData); setPersons(newData.getPersonList()); @@ -87,7 +87,7 @@ public void setPerson(Person target, Person editedPerson) { } /** - * Removes {@code key} from this {@code AddressBook}. + * Removes {@code key} from this {@code CampusConnect}. * {@code key} must exist in the address book. */ public void removePerson(Person key) { @@ -115,12 +115,11 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof AddressBook)) { + if (!(other instanceof CampusConnect otherCampusConnect)) { return false; } - AddressBook otherAddressBook = (AddressBook) other; - return persons.equals(otherAddressBook.persons); + return persons.equals(otherCampusConnect.persons); } @Override diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index d54df471c1f..25ac2842022 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -37,20 +37,20 @@ public interface Model { /** * Returns the user prefs' address book file path. */ - Path getAddressBookFilePath(); + Path getCampusConnectFilePath(); /** * Sets the user prefs' address book file path. */ - void setAddressBookFilePath(Path addressBookFilePath); + void setCampusConnectFilePath(Path campusConnectFilePath); /** - * Replaces address book data with the data in {@code addressBook}. + * Replaces address book data with the data in {@code campusConnect}. */ - void setAddressBook(ReadOnlyAddressBook addressBook); + void setCampusConnect(ReadOnlyCampusConnect campusConnect); - /** Returns the AddressBook */ - ReadOnlyAddressBook getAddressBook(); + /** Returns the CampusConnect */ + ReadOnlyCampusConnect getCampusConnect(); /** * Returns true if a person with the same identity as {@code person} exists 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 57bc563fde6..214bf3e29a1 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -19,25 +19,25 @@ public class ModelManager implements Model { private static final Logger logger = LogsCenter.getLogger(ModelManager.class); - private final AddressBook addressBook; + private final CampusConnect campusConnect; private final UserPrefs userPrefs; private final FilteredList filteredPersons; /** - * Initializes a ModelManager with the given addressBook and userPrefs. + * Initializes a ModelManager with the given campusConnect and userPrefs. */ - public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs) { - requireAllNonNull(addressBook, userPrefs); + public ModelManager(ReadOnlyCampusConnect campusConnect, ReadOnlyUserPrefs userPrefs) { + requireAllNonNull(campusConnect, userPrefs); - logger.fine("Initializing with address book: " + addressBook + " and user prefs " + userPrefs); + logger.fine("Initializing with address book: " + campusConnect + " and user prefs " + userPrefs); - this.addressBook = new AddressBook(addressBook); + this.campusConnect = new CampusConnect(campusConnect); this.userPrefs = new UserPrefs(userPrefs); - filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); + filteredPersons = new FilteredList<>(this.campusConnect.getPersonList()); } public ModelManager() { - this(new AddressBook(), new UserPrefs()); + this(new CampusConnect(), new UserPrefs()); } //=========== UserPrefs ================================================================================== @@ -65,42 +65,42 @@ public void setGuiSettings(GuiSettings guiSettings) { } @Override - public Path getAddressBookFilePath() { - return userPrefs.getAddressBookFilePath(); + public Path getCampusConnectFilePath() { + return userPrefs.getCampusConnectFilePath(); } @Override - public void setAddressBookFilePath(Path addressBookFilePath) { - requireNonNull(addressBookFilePath); - userPrefs.setAddressBookFilePath(addressBookFilePath); + public void setCampusConnectFilePath(Path campusConnectFilePath) { + requireNonNull(campusConnectFilePath); + userPrefs.setCampusConnectFilePath(campusConnectFilePath); } - //=========== AddressBook ================================================================================ + //=========== CampusConnect ================================================================================ @Override - public void setAddressBook(ReadOnlyAddressBook addressBook) { - this.addressBook.resetData(addressBook); + public void setCampusConnect(ReadOnlyCampusConnect campusConnect) { + this.campusConnect.resetData(campusConnect); } @Override - public ReadOnlyAddressBook getAddressBook() { - return addressBook; + public ReadOnlyCampusConnect getCampusConnect() { + return campusConnect; } @Override public boolean hasPerson(Person person) { requireNonNull(person); - return addressBook.hasPerson(person); + return campusConnect.hasPerson(person); } @Override public void deletePerson(Person target) { - addressBook.removePerson(target); + campusConnect.removePerson(target); } @Override public void addPerson(Person person) { - addressBook.addPerson(person); + campusConnect.addPerson(person); updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); } @@ -108,14 +108,14 @@ public void addPerson(Person person) { public void setPerson(Person target, Person editedPerson) { requireAllNonNull(target, editedPerson); - addressBook.setPerson(target, editedPerson); + campusConnect.setPerson(target, editedPerson); } //=========== Filtered Person List Accessors ============================================================= /** * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of - * {@code versionedAddressBook} + * {@code versionedCampusConnect} */ @Override public ObservableList getFilteredPersonList() { @@ -140,7 +140,7 @@ public boolean equals(Object other) { } ModelManager otherModelManager = (ModelManager) other; - return addressBook.equals(otherModelManager.addressBook) + return campusConnect.equals(otherModelManager.campusConnect) && userPrefs.equals(otherModelManager.userPrefs) && filteredPersons.equals(otherModelManager.filteredPersons); } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyCampusConnect.java similarity index 89% rename from src/main/java/seedu/address/model/ReadOnlyAddressBook.java rename to src/main/java/seedu/address/model/ReadOnlyCampusConnect.java index 6ddc2cd9a29..b4ee592bbb9 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyCampusConnect.java @@ -6,7 +6,7 @@ /** * Unmodifiable view of an address book */ -public interface ReadOnlyAddressBook { +public interface ReadOnlyCampusConnect { /** * Returns an unmodifiable view of the persons list. diff --git a/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java b/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java index befd58a4c73..8537a520993 100644 --- a/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java +++ b/src/main/java/seedu/address/model/ReadOnlyUserPrefs.java @@ -11,6 +11,6 @@ public interface ReadOnlyUserPrefs { GuiSettings getGuiSettings(); - Path getAddressBookFilePath(); + Path getCampusConnectFilePath(); } diff --git a/src/main/java/seedu/address/model/UserPrefs.java b/src/main/java/seedu/address/model/UserPrefs.java index 6be655fb4c7..1bb5a267439 100644 --- a/src/main/java/seedu/address/model/UserPrefs.java +++ b/src/main/java/seedu/address/model/UserPrefs.java @@ -14,7 +14,7 @@ public class UserPrefs implements ReadOnlyUserPrefs { private GuiSettings guiSettings = new GuiSettings(); - private Path addressBookFilePath = Paths.get("data" , "addressbook.json"); + private Path campusConnectFilePath = Paths.get("data" , "campusConnect.json"); /** * Creates a {@code UserPrefs} with default values. @@ -35,7 +35,7 @@ public UserPrefs(ReadOnlyUserPrefs userPrefs) { public void resetData(ReadOnlyUserPrefs newUserPrefs) { requireNonNull(newUserPrefs); setGuiSettings(newUserPrefs.getGuiSettings()); - setAddressBookFilePath(newUserPrefs.getAddressBookFilePath()); + setCampusConnectFilePath(newUserPrefs.getCampusConnectFilePath()); } public GuiSettings getGuiSettings() { @@ -47,13 +47,13 @@ public void setGuiSettings(GuiSettings guiSettings) { this.guiSettings = guiSettings; } - public Path getAddressBookFilePath() { - return addressBookFilePath; + public Path getCampusConnectFilePath() { + return campusConnectFilePath; } - public void setAddressBookFilePath(Path addressBookFilePath) { - requireNonNull(addressBookFilePath); - this.addressBookFilePath = addressBookFilePath; + public void setCampusConnectFilePath(Path campusConnectFilePath) { + requireNonNull(campusConnectFilePath); + this.campusConnectFilePath = campusConnectFilePath; } @Override @@ -69,19 +69,19 @@ public boolean equals(Object other) { UserPrefs otherUserPrefs = (UserPrefs) other; return guiSettings.equals(otherUserPrefs.guiSettings) - && addressBookFilePath.equals(otherUserPrefs.addressBookFilePath); + && campusConnectFilePath.equals(otherUserPrefs.campusConnectFilePath); } @Override public int hashCode() { - return Objects.hash(guiSettings, addressBookFilePath); + return Objects.hash(guiSettings, campusConnectFilePath); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Gui Settings : " + guiSettings); - sb.append("\nLocal data file location : " + addressBookFilePath); + sb.append("\nLocal data file location : " + campusConnectFilePath); return sb.toString(); } diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 1806da4facf..88dd6a97abf 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -4,8 +4,8 @@ import java.util.Set; import java.util.stream.Collectors; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.CampusConnect; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -14,7 +14,7 @@ import seedu.address.model.tag.Tag; /** - * Contains utility methods for populating {@code AddressBook} with sample data. + * Contains utility methods for populating {@code CampusConnect} with sample data. */ public class SampleDataUtil { public static Person[] getSamplePersons() { @@ -40,8 +40,8 @@ public static Person[] getSamplePersons() { }; } - public static ReadOnlyAddressBook getSampleAddressBook() { - AddressBook sampleAb = new AddressBook(); + public static ReadOnlyCampusConnect getSampleCampusConnect() { + CampusConnect sampleAb = new CampusConnect(); for (Person samplePerson : getSamplePersons()) { sampleAb.addPerson(samplePerson); } diff --git a/src/main/java/seedu/address/storage/AddressBookStorage.java b/src/main/java/seedu/address/storage/AddressBookStorage.java deleted file mode 100644 index f2e015105ae..00000000000 --- a/src/main/java/seedu/address/storage/AddressBookStorage.java +++ /dev/null @@ -1,45 +0,0 @@ -package seedu.address.storage; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; - -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyAddressBook; - -/** - * Represents a storage for {@link seedu.address.model.AddressBook}. - */ -public interface AddressBookStorage { - - /** - * Returns the file path of the data file. - */ - Path getAddressBookFilePath(); - - /** - * Returns AddressBook data as a {@link ReadOnlyAddressBook}. - * Returns {@code Optional.empty()} if storage file is not found. - * - * @throws DataLoadingException if loading the data from storage failed. - */ - Optional readAddressBook() throws DataLoadingException; - - /** - * @see #getAddressBookFilePath() - */ - Optional readAddressBook(Path filePath) throws DataLoadingException; - - /** - * Saves the given {@link ReadOnlyAddressBook} to the storage. - * @param addressBook cannot be null. - * @throws IOException if there was any problem writing to the file. - */ - void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; - - /** - * @see #saveAddressBook(ReadOnlyAddressBook) - */ - void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException; - -} diff --git a/src/main/java/seedu/address/storage/CampusConnectStorage.java b/src/main/java/seedu/address/storage/CampusConnectStorage.java new file mode 100644 index 00000000000..b1ef0b62c2d --- /dev/null +++ b/src/main/java/seedu/address/storage/CampusConnectStorage.java @@ -0,0 +1,46 @@ +package seedu.address.storage; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; + +import seedu.address.commons.exceptions.DataLoadingException; +import seedu.address.model.CampusConnect; +import seedu.address.model.ReadOnlyCampusConnect; + +/** + * Represents a storage for {@link CampusConnect}. + */ +public interface CampusConnectStorage { + + /** + * Returns the file path of the data file. + */ + Path getCampusConnectFilePath(); + + /** + * Returns CampusConnect data as a {@link ReadOnlyCampusConnect}. + * Returns {@code Optional.empty()} if storage file is not found. + * + * @throws DataLoadingException if loading the data from storage failed. + */ + Optional readCampusConnect() throws DataLoadingException; + + /** + * @see #getCampusConnectFilePath() + */ + Optional readCampusConnect(Path filePath) throws DataLoadingException; + + /** + * Saves the given {@link ReadOnlyCampusConnect} to the storage. + * @param campusConnect cannot be null. + * @throws IOException if there was any problem writing to the file. + */ + void saveCampusConnect(ReadOnlyCampusConnect campusConnect) throws IOException; + + /** + * @see #saveCampusConnect(ReadOnlyCampusConnect) + */ + void saveCampusConnect(ReadOnlyCampusConnect campusConnect, Path filePath) throws IOException; + +} diff --git a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java b/src/main/java/seedu/address/storage/JsonAddressBookStorage.java deleted file mode 100644 index 41e06f264e1..00000000000 --- a/src/main/java/seedu/address/storage/JsonAddressBookStorage.java +++ /dev/null @@ -1,80 +0,0 @@ -package seedu.address.storage; - -import static java.util.Objects.requireNonNull; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; -import java.util.logging.Logger; - -import seedu.address.commons.core.LogsCenter; -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.commons.util.FileUtil; -import seedu.address.commons.util.JsonUtil; -import seedu.address.model.ReadOnlyAddressBook; - -/** - * A class to access AddressBook data stored as a json file on the hard disk. - */ -public class JsonAddressBookStorage implements AddressBookStorage { - - private static final Logger logger = LogsCenter.getLogger(JsonAddressBookStorage.class); - - private Path filePath; - - public JsonAddressBookStorage(Path filePath) { - this.filePath = filePath; - } - - public Path getAddressBookFilePath() { - return filePath; - } - - @Override - public Optional readAddressBook() throws DataLoadingException { - return readAddressBook(filePath); - } - - /** - * Similar to {@link #readAddressBook()}. - * - * @param filePath location of the data. Cannot be null. - * @throws DataLoadingException if loading the data from storage failed. - */ - public Optional readAddressBook(Path filePath) throws DataLoadingException { - requireNonNull(filePath); - - Optional jsonAddressBook = JsonUtil.readJsonFile( - filePath, JsonSerializableAddressBook.class); - if (!jsonAddressBook.isPresent()) { - return Optional.empty(); - } - - try { - return Optional.of(jsonAddressBook.get().toModelType()); - } catch (IllegalValueException ive) { - logger.info("Illegal values found in " + filePath + ": " + ive.getMessage()); - throw new DataLoadingException(ive); - } - } - - @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { - saveAddressBook(addressBook, filePath); - } - - /** - * Similar to {@link #saveAddressBook(ReadOnlyAddressBook)}. - * - * @param filePath location of the data. Cannot be null. - */ - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { - requireNonNull(addressBook); - requireNonNull(filePath); - - FileUtil.createIfMissing(filePath); - JsonUtil.saveJsonFile(new JsonSerializableAddressBook(addressBook), filePath); - } - -} diff --git a/src/main/java/seedu/address/storage/JsonCampusConnectStorage.java b/src/main/java/seedu/address/storage/JsonCampusConnectStorage.java new file mode 100644 index 00000000000..6613f95135a --- /dev/null +++ b/src/main/java/seedu/address/storage/JsonCampusConnectStorage.java @@ -0,0 +1,80 @@ +package seedu.address.storage; + +import static java.util.Objects.requireNonNull; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; +import seedu.address.commons.exceptions.DataLoadingException; +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.commons.util.FileUtil; +import seedu.address.commons.util.JsonUtil; +import seedu.address.model.ReadOnlyCampusConnect; + +/** + * A class to access CampusConnect data stored as a json file on the hard disk. + */ +public class JsonCampusConnectStorage implements CampusConnectStorage { + + private static final Logger logger = LogsCenter.getLogger(JsonCampusConnectStorage.class); + + private Path filePath; + + public JsonCampusConnectStorage(Path filePath) { + this.filePath = filePath; + } + + public Path getCampusConnectFilePath() { + return filePath; + } + + @Override + public Optional readCampusConnect() throws DataLoadingException { + return readCampusConnect(filePath); + } + + /** + * Similar to {@link #readCampusConnect()}. + * + * @param filePath location of the data. Cannot be null. + * @throws DataLoadingException if loading the data from storage failed. + */ + public Optional readCampusConnect(Path filePath) throws DataLoadingException { + requireNonNull(filePath); + + Optional jsonCampusConnect = JsonUtil.readJsonFile( + filePath, JsonSerializableCampusConnect.class); + if (!jsonCampusConnect.isPresent()) { + return Optional.empty(); + } + + try { + return Optional.of(jsonCampusConnect.get().toModelType()); + } catch (IllegalValueException ive) { + logger.info("Illegal values found in " + filePath + ": " + ive.getMessage()); + throw new DataLoadingException(ive); + } + } + + @Override + public void saveCampusConnect(ReadOnlyCampusConnect campusConnect) throws IOException { + saveCampusConnect(campusConnect, filePath); + } + + /** + * Similar to {@link #saveCampusConnect(ReadOnlyCampusConnect)}. + * + * @param filePath location of the data. Cannot be null. + */ + public void saveCampusConnect(ReadOnlyCampusConnect campusConnect, Path filePath) throws IOException { + requireNonNull(campusConnect); + requireNonNull(filePath); + + FileUtil.createIfMissing(filePath); + JsonUtil.saveJsonFile(new JsonSerializableCampusConnect(campusConnect), filePath); + } + +} diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableCampusConnect.java similarity index 55% rename from src/main/java/seedu/address/storage/JsonSerializableAddressBook.java rename to src/main/java/seedu/address/storage/JsonSerializableCampusConnect.java index 5efd834091d..30c442859d6 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableCampusConnect.java @@ -9,52 +9,52 @@ import com.fasterxml.jackson.annotation.JsonRootName; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.CampusConnect; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.person.Person; /** - * An Immutable AddressBook that is serializable to JSON format. + * An Immutable CampusConnect that is serializable to JSON format. */ -@JsonRootName(value = "addressbook") -class JsonSerializableAddressBook { +@JsonRootName(value = "CampusConnect") +class JsonSerializableCampusConnect { public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; private final List persons = new ArrayList<>(); /** - * Constructs a {@code JsonSerializableAddressBook} with the given persons. + * Constructs a {@code JsonSerializableCampusConnect} with the given persons. */ @JsonCreator - public JsonSerializableAddressBook(@JsonProperty("persons") List persons) { + public JsonSerializableCampusConnect(@JsonProperty("persons") List persons) { this.persons.addAll(persons); } /** - * Converts a given {@code ReadOnlyAddressBook} into this class for Jackson use. + * Converts a given {@code ReadOnlyCampusConnect} into this class for Jackson use. * - * @param source future changes to this will not affect the created {@code JsonSerializableAddressBook}. + * @param source future changes to this will not affect the created {@code JsonSerializableCampusConnect}. */ - public JsonSerializableAddressBook(ReadOnlyAddressBook source) { + public JsonSerializableCampusConnect(ReadOnlyCampusConnect source) { persons.addAll(source.getPersonList().stream().map(JsonAdaptedPerson::new).collect(Collectors.toList())); } /** - * Converts this address book into the model's {@code AddressBook} object. + * Converts this address book into the model's {@code CampusConnect} object. * * @throws IllegalValueException if there were any data constraints violated. */ - public AddressBook toModelType() throws IllegalValueException { - AddressBook addressBook = new AddressBook(); + public CampusConnect toModelType() throws IllegalValueException { + CampusConnect campusConnect = new CampusConnect(); for (JsonAdaptedPerson jsonAdaptedPerson : persons) { Person person = jsonAdaptedPerson.toModelType(); - if (addressBook.hasPerson(person)) { + if (campusConnect.hasPerson(person)) { throw new IllegalValueException(MESSAGE_DUPLICATE_PERSON); } - addressBook.addPerson(person); + campusConnect.addPerson(person); } - return addressBook; + return campusConnect; } } diff --git a/src/main/java/seedu/address/storage/Storage.java b/src/main/java/seedu/address/storage/Storage.java index 9fba0c7a1d6..42c6f3d20ed 100644 --- a/src/main/java/seedu/address/storage/Storage.java +++ b/src/main/java/seedu/address/storage/Storage.java @@ -5,14 +5,14 @@ import java.util.Optional; import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.UserPrefs; /** * API of the Storage component */ -public interface Storage extends AddressBookStorage, UserPrefsStorage { +public interface Storage extends CampusConnectStorage, UserPrefsStorage { @Override Optional readUserPrefs() throws DataLoadingException; @@ -21,12 +21,12 @@ public interface Storage extends AddressBookStorage, UserPrefsStorage { void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException; @Override - Path getAddressBookFilePath(); + Path getCampusConnectFilePath(); @Override - Optional readAddressBook() throws DataLoadingException; + Optional readCampusConnect() throws DataLoadingException; @Override - void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException; + void saveCampusConnect(ReadOnlyCampusConnect campusConnect) throws IOException; } diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index 8b84a9024d5..2fbf279de10 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -7,24 +7,24 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.UserPrefs; /** - * Manages storage of AddressBook data in local storage. + * Manages storage of CampusConnect data in local storage. */ public class StorageManager implements Storage { private static final Logger logger = LogsCenter.getLogger(StorageManager.class); - private AddressBookStorage addressBookStorage; + private CampusConnectStorage campusConnectStorage; private UserPrefsStorage userPrefsStorage; /** - * Creates a {@code StorageManager} with the given {@code AddressBookStorage} and {@code UserPrefStorage}. + * Creates a {@code StorageManager} with the given {@code CampusConnectStorage} and {@code UserPrefStorage}. */ - public StorageManager(AddressBookStorage addressBookStorage, UserPrefsStorage userPrefsStorage) { - this.addressBookStorage = addressBookStorage; + public StorageManager(CampusConnectStorage campusConnectStorage, UserPrefsStorage userPrefsStorage) { + this.campusConnectStorage = campusConnectStorage; this.userPrefsStorage = userPrefsStorage; } @@ -46,33 +46,33 @@ public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException { } - // ================ AddressBook methods ============================== + // ================ CampusConnect methods ============================== @Override - public Path getAddressBookFilePath() { - return addressBookStorage.getAddressBookFilePath(); + public Path getCampusConnectFilePath() { + return campusConnectStorage.getCampusConnectFilePath(); } @Override - public Optional readAddressBook() throws DataLoadingException { - return readAddressBook(addressBookStorage.getAddressBookFilePath()); + public Optional readCampusConnect() throws DataLoadingException { + return readCampusConnect(campusConnectStorage.getCampusConnectFilePath()); } @Override - public Optional readAddressBook(Path filePath) throws DataLoadingException { + public Optional readCampusConnect(Path filePath) throws DataLoadingException { logger.fine("Attempting to read data from file: " + filePath); - return addressBookStorage.readAddressBook(filePath); + return campusConnectStorage.readCampusConnect(filePath); } @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { - saveAddressBook(addressBook, addressBookStorage.getAddressBookFilePath()); + public void saveCampusConnect(ReadOnlyCampusConnect campusConnect) throws IOException { + saveCampusConnect(campusConnect, campusConnectStorage.getCampusConnectFilePath()); } @Override - public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException { + public void saveCampusConnect(ReadOnlyCampusConnect campusConnect, Path filePath) throws IOException { logger.fine("Attempting to write to data file: " + filePath); - addressBookStorage.saveAddressBook(addressBook, filePath); + campusConnectStorage.saveCampusConnect(campusConnect, filePath); } } diff --git a/src/main/java/seedu/address/ui/HelpWindow.java b/src/main/java/seedu/address/ui/HelpWindow.java index 3f16b2fcf26..46b698215fa 100644 --- a/src/main/java/seedu/address/ui/HelpWindow.java +++ b/src/main/java/seedu/address/ui/HelpWindow.java @@ -15,7 +15,7 @@ */ public class HelpWindow extends UiPart { - public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html"; + public static final String USERGUIDE_URL = "https://se-education.org/campusconnect-level3/UserGuide.html"; public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL; private static final Logger logger = LogsCenter.getLogger(HelpWindow.class); diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 79e74ef37c0..a61d11cd688 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -116,7 +116,7 @@ void fillInnerParts() { resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); - StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getAddressBookFilePath()); + StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getCampusConnectFilePath()); statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot()); CommandBox commandBox = new CommandBox(this::executeCommand); diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index f52f463690e..3f0c67770d8 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -21,7 +21,7 @@ public class PersonCard extends UiPart { * As a consequence, UI elements' variable names cannot be set to such keywords * or an exception will be thrown by JavaFX during runtime. * - * @see The issue on AddressBook level 4 + * @see The issue on CampusConnect level 4 */ public final Person person; diff --git a/src/main/resources/images/address_book_32.png b/src/main/resources/images/campusConnect.png similarity index 100% rename from src/main/resources/images/address_book_32.png rename to src/main/resources/images/campusConnect.png diff --git a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonCampusConnectStorageTest/invalidAndValidPersonCampusConnect.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json rename to src/test/data/JsonCampusConnectStorageTest/invalidAndValidPersonCampusConnect.json diff --git a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json b/src/test/data/JsonCampusConnectStorageTest/invalidPersonCampusConnect.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json rename to src/test/data/JsonCampusConnectStorageTest/invalidPersonCampusConnect.json diff --git a/src/test/data/JsonAddressBookStorageTest/notJsonFormatAddressBook.json b/src/test/data/JsonCampusConnectStorageTest/notJsonFormatCampusConnect.json similarity index 100% rename from src/test/data/JsonAddressBookStorageTest/notJsonFormatAddressBook.json rename to src/test/data/JsonCampusConnectStorageTest/notJsonFormatCampusConnect.json diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableCampusConnectTest/duplicatePersonCampusConnect.json similarity index 100% rename from src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json rename to src/test/data/JsonSerializableCampusConnectTest/duplicatePersonCampusConnect.json diff --git a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json b/src/test/data/JsonSerializableCampusConnectTest/invalidPersonCampusConnect.json similarity index 100% rename from src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json rename to src/test/data/JsonSerializableCampusConnectTest/invalidPersonCampusConnect.json diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableCampusConnectTest/typicalPersonsCampusConnect.json similarity index 89% rename from src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json rename to src/test/data/JsonSerializableCampusConnectTest/typicalPersonsCampusConnect.json index 72262099d35..ffd0a48c0e4 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableCampusConnectTest/typicalPersonsCampusConnect.json @@ -1,5 +1,5 @@ { - "_comment": "AddressBook save file which contains the same Person values as in TypicalPersons#getTypicalAddressBook()", + "_comment": "CampusConnect save file which contains the same Person values as in TypicalPersons#getTypicalCampusConnect()", "persons" : [ { "name" : "Alice Pauline", "phone" : "94351253", diff --git a/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json b/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json index 1037548a9cd..91aa79e40ba 100644 --- a/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json +++ b/src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json @@ -9,5 +9,5 @@ "z" : 99 } }, - "addressBookFilePath" : "addressbook.json" + "campusConnectFilePath" : "CampusConnect.json" } diff --git a/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json b/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json index b819bed900a..d326cf455be 100644 --- a/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json +++ b/src/test/data/JsonUserPrefsStorageTest/TypicalUserPref.json @@ -7,5 +7,5 @@ "y" : 100 } }, - "addressBookFilePath" : "addressbook.json" + "campusConnectFilePath" : "CampusConnect.json" } diff --git a/src/test/java/seedu/address/commons/util/AppUtilTest.java b/src/test/java/seedu/address/commons/util/AppUtilTest.java index 594de1e6365..a341ff54b94 100644 --- a/src/test/java/seedu/address/commons/util/AppUtilTest.java +++ b/src/test/java/seedu/address/commons/util/AppUtilTest.java @@ -9,7 +9,7 @@ public class AppUtilTest { @Test public void getImage_exitingImage() { - assertNotNull(AppUtil.getImage("/images/address_book_32.png")); + assertNotNull(AppUtil.getImage("/images/campusConnect.png")); } @Test diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index baf8ce336a2..c810c71e8bf 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -25,10 +25,10 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; import seedu.address.model.ModelManager; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.UserPrefs; import seedu.address.model.person.Person; -import seedu.address.storage.JsonAddressBookStorage; +import seedu.address.storage.JsonCampusConnectStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.StorageManager; import seedu.address.testutil.PersonBuilder; @@ -45,10 +45,10 @@ public class LogicManagerTest { @BeforeEach public void setUp() { - JsonAddressBookStorage addressBookStorage = - new JsonAddressBookStorage(temporaryFolder.resolve("addressBook.json")); + JsonCampusConnectStorage campusConnectStorage = + new JsonCampusConnectStorage(temporaryFolder.resolve("CampusConnect.json")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json")); - StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage); + StorageManager storage = new StorageManager(campusConnectStorage, userPrefsStorage); logic = new LogicManager(model, storage); } @@ -123,7 +123,7 @@ private void assertCommandException(String inputCommand, String expectedMessage) */ private void assertCommandFailure(String inputCommand, Class expectedException, String expectedMessage) { - Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getCampusConnect(), new UserPrefs()); assertCommandFailure(inputCommand, expectedException, expectedMessage, expectedModel); } @@ -149,10 +149,10 @@ private void assertCommandFailure(String inputCommand, Class expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); - assertEquals(expectedAddressBook, actualModel.getAddressBook()); + assertEquals(expectedCampusConnect, actualModel.getCampusConnect()); assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); } /** diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index b6f332eabca..8988440ed0e 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -8,7 +8,7 @@ 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.testutil.TypicalPersons.getTypicalCampusConnect; import org.junit.jupiter.api.Test; @@ -25,7 +25,7 @@ */ public class DeleteCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); @Test public void execute_validIndexUnfilteredList_success() { @@ -35,7 +35,7 @@ public void execute_validIndexUnfilteredList_success() { String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)); - ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + ModelManager expectedModel = new ModelManager(model.getCampusConnect(), new UserPrefs()); expectedModel.deletePerson(personToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); @@ -59,7 +59,7 @@ public void execute_validIndexFilteredList_success() { String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)); - Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + Model expectedModel = new ModelManager(model.getCampusConnect(), new UserPrefs()); expectedModel.deletePerson(personToDelete); showNoPerson(expectedModel); @@ -72,7 +72,7 @@ public void execute_invalidIndexFilteredList_throwsCommandException() { Index outOfBoundIndex = INDEX_SECOND_PERSON; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getCampusConnect().getPersonList().size()); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndex); diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 4a8bd0e160b..1184d7f2e56 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -14,14 +14,14 @@ 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.testutil.TypicalPersons.getTypicalCampusConnect; import org.junit.jupiter.api.Test; import seedu.address.commons.core.index.Index; import seedu.address.logic.Messages; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.AddressBook; +import seedu.address.model.CampusConnect; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; @@ -34,7 +34,7 @@ */ public class EditCommandTest { - private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private Model model = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { @@ -44,7 +44,7 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new CampusConnect(model.getCampusConnect()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -65,7 +65,7 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new CampusConnect(model.getCampusConnect()), new UserPrefs()); expectedModel.setPerson(lastPerson, editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -78,7 +78,7 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new CampusConnect(model.getCampusConnect()), new UserPrefs()); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -103,7 +103,7 @@ public void execute_filteredList_success() { String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); - Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + Model expectedModel = new ModelManager(new CampusConnect(model.getCampusConnect()), new UserPrefs()); expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); @@ -123,7 +123,7 @@ 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()); + Person personInList = model.getCampusConnect().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptorBuilder(personInList).build()); @@ -148,7 +148,7 @@ public void execute_invalidPersonIndexFilteredList_failure() { showPersonAtIndex(model, INDEX_FIRST_PERSON); Index outOfBoundIndex = INDEX_SECOND_PERSON; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getCampusConnect().getPersonList().size()); EditCommand editCommand = new EditCommand(outOfBoundIndex, new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); diff --git a/src/test/java/seedu/address/logic/commands/FindByContactCommandTest.java b/src/test/java/seedu/address/logic/commands/FindByContactCommandTest.java index 588beb964a8..de8ec19947e 100644 --- a/src/test/java/seedu/address/logic/commands/FindByContactCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindByContactCommandTest.java @@ -8,7 +8,7 @@ import static seedu.address.testutil.TypicalPersons.ELLE; import static seedu.address.testutil.TypicalPersons.FIONA; import static seedu.address.testutil.TypicalPersons.GEORGE; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPersons.getTypicalCampusConnect; import java.util.Arrays; import java.util.Collections; @@ -25,8 +25,8 @@ * Contains integration tests (interaction with the Model) for {@code FindByContactCommand}. */ public class FindByContactCommandTest { - private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model expectedModel = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); + private final Model model = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); @Test public void equals() { diff --git a/src/test/java/seedu/address/logic/commands/FindByEmailCommandTest.java b/src/test/java/seedu/address/logic/commands/FindByEmailCommandTest.java index 75eb90a91c8..27df0b523f9 100644 --- a/src/test/java/seedu/address/logic/commands/FindByEmailCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindByEmailCommandTest.java @@ -6,7 +6,7 @@ import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.testutil.TypicalPersons.DANIEL; import static seedu.address.testutil.TypicalPersons.ELLE; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPersons.getTypicalCampusConnect; import java.util.Arrays; import java.util.Collections; @@ -20,8 +20,8 @@ public class FindByEmailCommandTest { - private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model expectedModel = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); + private final Model model = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); @Test public void equals() { diff --git a/src/test/java/seedu/address/logic/commands/FindByNameCommandTest.java b/src/test/java/seedu/address/logic/commands/FindByNameCommandTest.java index 6dc96f27e9d..56ea054c7be 100644 --- a/src/test/java/seedu/address/logic/commands/FindByNameCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindByNameCommandTest.java @@ -11,7 +11,7 @@ import static seedu.address.testutil.TypicalPersons.DANIEL; 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.TypicalPersons.getTypicalCampusConnect; import java.util.Arrays; import java.util.Collections; @@ -27,8 +27,8 @@ * Contains integration tests (interaction with the Model) for {@code FindByNameCommand}. */ public class FindByNameCommandTest { - private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model model = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); + private final Model expectedModel = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); @Test public void equals() { diff --git a/src/test/java/seedu/address/logic/commands/FindByTagCommandTest.java b/src/test/java/seedu/address/logic/commands/FindByTagCommandTest.java index 258bf9b777c..16aaa1e8554 100644 --- a/src/test/java/seedu/address/logic/commands/FindByTagCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindByTagCommandTest.java @@ -7,7 +7,7 @@ import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.BENSON; import static seedu.address.testutil.TypicalPersons.DANIEL; -import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import static seedu.address.testutil.TypicalPersons.getTypicalCampusConnect; import java.util.Arrays; import java.util.Collections; @@ -22,8 +22,8 @@ public class FindByTagCommandTest { - private final Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - private final Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final Model expectedModel = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); + private final Model model = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); @Test public void equals() { @@ -64,7 +64,7 @@ public void execute_zeroKeywords_noPersonFound() { @Test public void execute_resultsWithPartialMatch_multiplePersonsFound() { - System.out.println(expectedModel.getAddressBook().toString()); + System.out.println(expectedModel.getCampusConnect().toString()); String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 3); TagContainsKeywordsPredicate predicate = preparePredicate("en"); FindByTagCommand command = new FindByTagCommand(predicate); diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java index 435ff1f7275..6119ce9c9b5 100644 --- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java @@ -3,7 +3,7 @@ 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.testutil.TypicalPersons.getTypicalCampusConnect; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,8 +22,8 @@ public class ListCommandTest { @BeforeEach public void setUp() { - model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); + model = new ModelManager(getTypicalCampusConnect(), new UserPrefs()); + expectedModel = new ModelManager(model.getCampusConnect(), new UserPrefs()); } @Test diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/CampusConnectParserTest.java similarity index 97% rename from src/test/java/seedu/address/logic/parser/AddressBookParserTest.java rename to src/test/java/seedu/address/logic/parser/CampusConnectParserTest.java index c13e70bb4d6..045aae8da36 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/CampusConnectParserTest.java @@ -31,9 +31,9 @@ import seedu.address.testutil.PersonBuilder; import seedu.address.testutil.PersonUtil; -public class AddressBookParserTest { +public class CampusConnectParserTest { - private final AddressBookParser parser = new AddressBookParser(); + private final CampusConnectParser parser = new CampusConnectParser(); @Test public void parseCommand_add() throws Exception { diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/CampusConnectTest.java similarity index 55% rename from src/test/java/seedu/address/model/AddressBookTest.java rename to src/test/java/seedu/address/model/CampusConnectTest.java index 68c8c5ba4d5..fc297babe91 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/CampusConnectTest.java @@ -7,7 +7,7 @@ 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.TypicalPersons.getTypicalCampusConnect; import java.util.Arrays; import java.util.Collection; @@ -22,25 +22,25 @@ import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.testutil.PersonBuilder; -public class AddressBookTest { +public class CampusConnectTest { - private final AddressBook addressBook = new AddressBook(); + private final CampusConnect campusConnect = new CampusConnect(); @Test public void constructor() { - assertEquals(Collections.emptyList(), addressBook.getPersonList()); + assertEquals(Collections.emptyList(), campusConnect.getPersonList()); } @Test public void resetData_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> addressBook.resetData(null)); + assertThrows(NullPointerException.class, () -> campusConnect.resetData(null)); } @Test - public void resetData_withValidReadOnlyAddressBook_replacesData() { - AddressBook newData = getTypicalAddressBook(); - addressBook.resetData(newData); - assertEquals(newData, addressBook); + public void resetData_withValidReadOnlyCampusConnect_replacesData() { + CampusConnect newData = getTypicalCampusConnect(); + campusConnect.resetData(newData); + assertEquals(newData, campusConnect); } @Test @@ -49,53 +49,53 @@ public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); List newPersons = Arrays.asList(ALICE, editedAlice); - AddressBookStub newData = new AddressBookStub(newPersons); + CampusConnectStub newData = new CampusConnectStub(newPersons); - assertThrows(DuplicatePersonException.class, () -> addressBook.resetData(newData)); + assertThrows(DuplicatePersonException.class, () -> campusConnect.resetData(newData)); } @Test public void hasPerson_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> addressBook.hasPerson(null)); + assertThrows(NullPointerException.class, () -> campusConnect.hasPerson(null)); } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { - assertFalse(addressBook.hasPerson(ALICE)); + public void hasPerson_personNotInCampusConnect_returnsFalse() { + assertFalse(campusConnect.hasPerson(ALICE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { - addressBook.addPerson(ALICE); - assertTrue(addressBook.hasPerson(ALICE)); + public void hasPerson_personInCampusConnect_returnsTrue() { + campusConnect.addPerson(ALICE); + assertTrue(campusConnect.hasPerson(ALICE)); } @Test - public void hasPerson_personWithSameIdentityFieldsInAddressBook_returnsTrue() { - addressBook.addPerson(ALICE); + public void hasPerson_personWithSameIdentityFieldsInCampusConnect_returnsTrue() { + campusConnect.addPerson(ALICE); Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); - assertTrue(addressBook.hasPerson(editedAlice)); + assertTrue(campusConnect.hasPerson(editedAlice)); } @Test public void getPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> addressBook.getPersonList().remove(0)); + assertThrows(UnsupportedOperationException.class, () -> campusConnect.getPersonList().remove(0)); } @Test public void toStringMethod() { - String expected = AddressBook.class.getCanonicalName() + "{persons=" + addressBook.getPersonList() + "}"; - assertEquals(expected, addressBook.toString()); + String expected = CampusConnect.class.getCanonicalName() + "{persons=" + campusConnect.getPersonList() + "}"; + assertEquals(expected, campusConnect.toString()); } /** - * A stub ReadOnlyAddressBook whose persons list can violate interface constraints. + * A stub ReadOnlyCampusConnect whose persons list can violate interface constraints. */ - private static class AddressBookStub implements ReadOnlyAddressBook { + private static class CampusConnectStub implements ReadOnlyCampusConnect { private final ObservableList persons = FXCollections.observableArrayList(); - AddressBookStub(Collection persons) { + CampusConnectStub(Collection persons) { this.persons.setAll(persons); } diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 2cf1418d116..37af1af1dfa 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -16,7 +16,7 @@ import seedu.address.commons.core.GuiSettings; import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.testutil.AddressBookBuilder; +import seedu.address.testutil.CampusConnectBuilder; public class ModelManagerTest { @@ -26,7 +26,7 @@ public class ModelManagerTest { public void constructor() { assertEquals(new UserPrefs(), modelManager.getUserPrefs()); assertEquals(new GuiSettings(), modelManager.getGuiSettings()); - assertEquals(new AddressBook(), new AddressBook(modelManager.getAddressBook())); + assertEquals(new CampusConnect(), new CampusConnect(modelManager.getCampusConnect())); } @Test @@ -37,14 +37,14 @@ public void setUserPrefs_nullUserPrefs_throwsNullPointerException() { @Test public void setUserPrefs_validUserPrefs_copiesUserPrefs() { UserPrefs userPrefs = new UserPrefs(); - userPrefs.setAddressBookFilePath(Paths.get("address/book/file/path")); + userPrefs.setCampusConnectFilePath(Paths.get("address/book/file/path")); userPrefs.setGuiSettings(new GuiSettings(1, 2, 3, 4)); modelManager.setUserPrefs(userPrefs); assertEquals(userPrefs, modelManager.getUserPrefs()); // Modifying userPrefs should not modify modelManager's userPrefs UserPrefs oldUserPrefs = new UserPrefs(userPrefs); - userPrefs.setAddressBookFilePath(Paths.get("new/address/book/file/path")); + userPrefs.setCampusConnectFilePath(Paths.get("new/address/book/file/path")); assertEquals(oldUserPrefs, modelManager.getUserPrefs()); } @@ -61,15 +61,15 @@ public void setGuiSettings_validGuiSettings_setsGuiSettings() { } @Test - public void setAddressBookFilePath_nullPath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.setAddressBookFilePath(null)); + public void setCampusConnectFilePath_nullPath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> modelManager.setCampusConnectFilePath(null)); } @Test - public void setAddressBookFilePath_validPath_setsAddressBookFilePath() { + public void setCampusConnectFilePath_validPath_setsCampusConnectFilePath() { Path path = Paths.get("address/book/file/path"); - modelManager.setAddressBookFilePath(path); - assertEquals(path, modelManager.getAddressBookFilePath()); + modelManager.setCampusConnectFilePath(path); + assertEquals(path, modelManager.getCampusConnectFilePath()); } @Test @@ -78,12 +78,12 @@ public void hasPerson_nullPerson_throwsNullPointerException() { } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { + public void hasPerson_personNotInCampusConnect_returnsFalse() { assertFalse(modelManager.hasPerson(ALICE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { + public void hasPerson_personInCampusConnect_returnsTrue() { modelManager.addPerson(ALICE); assertTrue(modelManager.hasPerson(ALICE)); } @@ -95,13 +95,13 @@ public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException @Test public void equals() { - AddressBook addressBook = new AddressBookBuilder().withPerson(ALICE).withPerson(BENSON).build(); - AddressBook differentAddressBook = new AddressBook(); + CampusConnect campusConnect = new CampusConnectBuilder().withPerson(ALICE).withPerson(BENSON).build(); + CampusConnect differentCampusConnect = new CampusConnect(); UserPrefs userPrefs = new UserPrefs(); // same values -> returns true - modelManager = new ModelManager(addressBook, userPrefs); - ModelManager modelManagerCopy = new ModelManager(addressBook, userPrefs); + modelManager = new ModelManager(campusConnect, userPrefs); + ModelManager modelManagerCopy = new ModelManager(campusConnect, userPrefs); assertTrue(modelManager.equals(modelManagerCopy)); // same object -> returns true @@ -113,20 +113,20 @@ public void equals() { // different types -> returns false assertFalse(modelManager.equals(5)); - // different addressBook -> returns false - assertFalse(modelManager.equals(new ModelManager(differentAddressBook, userPrefs))); + // different campusConnect -> returns false + assertFalse(modelManager.equals(new ModelManager(differentCampusConnect, userPrefs))); // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); modelManager.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); - assertFalse(modelManager.equals(new ModelManager(addressBook, userPrefs))); + assertFalse(modelManager.equals(new ModelManager(campusConnect, userPrefs))); // resets modelManager to initial state for upcoming tests modelManager.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); - differentUserPrefs.setAddressBookFilePath(Paths.get("differentFilePath")); - assertFalse(modelManager.equals(new ModelManager(addressBook, differentUserPrefs))); + differentUserPrefs.setCampusConnectFilePath(Paths.get("differentFilePath")); + assertFalse(modelManager.equals(new ModelManager(campusConnect, differentUserPrefs))); } } diff --git a/src/test/java/seedu/address/model/UserPrefsTest.java b/src/test/java/seedu/address/model/UserPrefsTest.java index b1307a70d52..ea16e87a32b 100644 --- a/src/test/java/seedu/address/model/UserPrefsTest.java +++ b/src/test/java/seedu/address/model/UserPrefsTest.java @@ -13,9 +13,9 @@ public void setGuiSettings_nullGuiSettings_throwsNullPointerException() { } @Test - public void setAddressBookFilePath_nullPath_throwsNullPointerException() { + public void setCampusConnectFilePath_nullPath_throwsNullPointerException() { UserPrefs userPrefs = new UserPrefs(); - assertThrows(NullPointerException.class, () -> userPrefs.setAddressBookFilePath(null)); + assertThrows(NullPointerException.class, () -> userPrefs.setCampusConnectFilePath(null)); } } diff --git a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java deleted file mode 100644 index 4e5ce9200c8..00000000000 --- a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package seedu.address.storage; - -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 java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import seedu.address.commons.exceptions.DataLoadingException; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; - -public class JsonAddressBookStorageTest { - private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonAddressBookStorageTest"); - - @TempDir - public Path testFolder; - - @Test - public void readAddressBook_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> readAddressBook(null)); - } - - private java.util.Optional readAddressBook(String filePath) throws Exception { - return new JsonAddressBookStorage(Paths.get(filePath)).readAddressBook(addToTestDataPathIfNotNull(filePath)); - } - - private Path addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) { - return prefsFileInTestDataFolder != null - ? TEST_DATA_FOLDER.resolve(prefsFileInTestDataFolder) - : null; - } - - @Test - public void read_missingFile_emptyResult() throws Exception { - assertFalse(readAddressBook("NonExistentFile.json").isPresent()); - } - - @Test - public void read_notJsonFormat_exceptionThrown() { - assertThrows(DataLoadingException.class, () -> readAddressBook("notJsonFormatAddressBook.json")); - } - - @Test - public void readAddressBook_invalidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidPersonAddressBook.json")); - } - - @Test - public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidPersonAddressBook.json")); - } - - @Test - public void readAndSaveAddressBook_allInOrder_success() throws Exception { - Path filePath = testFolder.resolve("TempAddressBook.json"); - AddressBook original = getTypicalAddressBook(); - JsonAddressBookStorage jsonAddressBookStorage = new JsonAddressBookStorage(filePath); - - // Save in new file and read back - jsonAddressBookStorage.saveAddressBook(original, filePath); - ReadOnlyAddressBook readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); - assertEquals(original, new AddressBook(readBack)); - - // Modify data, overwrite exiting file, and read back - original.addPerson(HOON); - original.removePerson(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); - jsonAddressBookStorage.saveAddressBook(original); // file path not specified - readBack = jsonAddressBookStorage.readAddressBook().get(); // file path not specified - assertEquals(original, new AddressBook(readBack)); - - } - - @Test - public void saveAddressBook_nullAddressBook_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveAddressBook(null, "SomeFile.json")); - } - - /** - * Saves {@code addressBook} at the specified {@code filePath}. - */ - private void saveAddressBook(ReadOnlyAddressBook addressBook, String filePath) { - try { - new JsonAddressBookStorage(Paths.get(filePath)) - .saveAddressBook(addressBook, addToTestDataPathIfNotNull(filePath)); - } catch (IOException ioe) { - throw new AssertionError("There should not be an error writing to the file.", ioe); - } - } - - @Test - public void saveAddressBook_nullFilePath_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> saveAddressBook(new AddressBook(), null)); - } -} diff --git a/src/test/java/seedu/address/storage/JsonCampusConnectStorageTest.java b/src/test/java/seedu/address/storage/JsonCampusConnectStorageTest.java new file mode 100644 index 00000000000..504bf5464c2 --- /dev/null +++ b/src/test/java/seedu/address/storage/JsonCampusConnectStorageTest.java @@ -0,0 +1,111 @@ +package seedu.address.storage; + +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.getTypicalCampusConnect; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import seedu.address.commons.exceptions.DataLoadingException; +import seedu.address.model.CampusConnect; +import seedu.address.model.ReadOnlyCampusConnect; + +public class JsonCampusConnectStorageTest { + private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonCampusConnectStorageTest"); + + @TempDir + public Path testFolder; + + @Test + public void readCampusConnect_nullFilePath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> readCampusConnect(null)); + } + + private java.util.Optional readCampusConnect(String filePath) throws Exception { + return new JsonCampusConnectStorage(Paths.get(filePath)) + .readCampusConnect(addToTestDataPathIfNotNull(filePath)); + } + + private Path addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) { + return prefsFileInTestDataFolder != null + ? TEST_DATA_FOLDER.resolve(prefsFileInTestDataFolder) + : null; + } + + @Test + public void read_missingFile_emptyResult() throws Exception { + assertFalse(readCampusConnect("NonExistentFile.json").isPresent()); + } + + @Test + public void read_notJsonFormat_exceptionThrown() { + assertThrows(DataLoadingException.class, () -> readCampusConnect("notJsonFormatCampusConnect.json")); + } + + @Test + public void readCampusConnect_invalidPersonCampusConnect_throwDataLoadingException() { + assertThrows(DataLoadingException.class, () -> readCampusConnect("invalidPersonCampusConnect.json")); + } + + @Test + public void readCampusConnect_invalidAndValidPersonCampusConnect_throwDataLoadingException() { + assertThrows(DataLoadingException.class, () -> readCampusConnect("invalidAndValidPersonCampusConnect.json")); + } + + @Test + public void readAndSaveCampusConnect_allInOrder_success() throws Exception { + Path filePath = testFolder.resolve("TempCampusConnect.json"); + CampusConnect original = getTypicalCampusConnect(); + JsonCampusConnectStorage jsonCampusConnectStorage = new JsonCampusConnectStorage(filePath); + + // Save in new file and read back + jsonCampusConnectStorage.saveCampusConnect(original, filePath); + ReadOnlyCampusConnect readBack = jsonCampusConnectStorage.readCampusConnect(filePath).get(); + assertEquals(original, new CampusConnect(readBack)); + + // Modify data, overwrite exiting file, and read back + original.addPerson(HOON); + original.removePerson(ALICE); + jsonCampusConnectStorage.saveCampusConnect(original, filePath); + readBack = jsonCampusConnectStorage.readCampusConnect(filePath).get(); + assertEquals(original, new CampusConnect(readBack)); + + // Save and read without specifying file path + original.addPerson(IDA); + jsonCampusConnectStorage.saveCampusConnect(original); // file path not specified + readBack = jsonCampusConnectStorage.readCampusConnect().get(); // file path not specified + assertEquals(original, new CampusConnect(readBack)); + + } + + @Test + public void saveCampusConnect_nullCampusConnect_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> saveCampusConnect(null, "SomeFile.json")); + } + + /** + * Saves {@code campusConnect} at the specified {@code filePath}. + */ + private void saveCampusConnect(ReadOnlyCampusConnect campusConnect, String filePath) { + try { + new JsonCampusConnectStorage(Paths.get(filePath)) + .saveCampusConnect(campusConnect, addToTestDataPathIfNotNull(filePath)); + } catch (IOException ioe) { + throw new AssertionError("There should not be an error writing to the file.", ioe); + } + } + + @Test + public void saveCampusConnect_nullFilePath_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> saveCampusConnect(new CampusConnect(), null)); + } +} diff --git a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java b/src/test/java/seedu/address/storage/JsonSerializableCampusConnectTest.java similarity index 52% rename from src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java rename to src/test/java/seedu/address/storage/JsonSerializableCampusConnectTest.java index 188c9058d20..dcc38edbffb 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java +++ b/src/test/java/seedu/address/storage/JsonSerializableCampusConnectTest.java @@ -10,37 +10,37 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.commons.util.JsonUtil; -import seedu.address.model.AddressBook; +import seedu.address.model.CampusConnect; import seedu.address.testutil.TypicalPersons; -public class JsonSerializableAddressBookTest { +public class JsonSerializableCampusConnectTest { - 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 TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableCampusConnectTest"); + private static final Path TYPICAL_PERSONS_FILE = TEST_DATA_FOLDER.resolve("typicalPersonsCampusConnect.json"); + private static final Path INVALID_PERSON_FILE = TEST_DATA_FOLDER.resolve("invalidPersonCampusConnect.json"); + private static final Path DUPLICATE_PERSON_FILE = TEST_DATA_FOLDER.resolve("duplicatePersonCampusConnect.json"); @Test public void toModelType_typicalPersonsFile_success() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, - JsonSerializableAddressBook.class).get(); - AddressBook addressBookFromFile = dataFromFile.toModelType(); - AddressBook typicalPersonsAddressBook = TypicalPersons.getTypicalAddressBook(); - assertEquals(addressBookFromFile, typicalPersonsAddressBook); + JsonSerializableCampusConnect dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, + JsonSerializableCampusConnect.class).get(); + CampusConnect campusConnectFromFile = dataFromFile.toModelType(); + CampusConnect typicalPersonsCampusConnect = TypicalPersons.getTypicalCampusConnect(); + assertEquals(campusConnectFromFile, typicalPersonsCampusConnect); } @Test public void toModelType_invalidPersonFile_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(INVALID_PERSON_FILE, - JsonSerializableAddressBook.class).get(); + JsonSerializableCampusConnect dataFromFile = JsonUtil.readJsonFile(INVALID_PERSON_FILE, + JsonSerializableCampusConnect.class).get(); assertThrows(IllegalValueException.class, dataFromFile::toModelType); } @Test public void toModelType_duplicatePersons_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PERSON_FILE, - JsonSerializableAddressBook.class).get(); - assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_PERSON, + JsonSerializableCampusConnect dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PERSON_FILE, + JsonSerializableCampusConnect.class).get(); + assertThrows(IllegalValueException.class, JsonSerializableCampusConnect.MESSAGE_DUPLICATE_PERSON, dataFromFile::toModelType); } diff --git a/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java b/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java index ed0a413526a..9babc06103f 100644 --- a/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java +++ b/src/test/java/seedu/address/storage/JsonUserPrefsStorageTest.java @@ -73,7 +73,7 @@ public void readUserPrefs_extraValuesInFile_extraValuesIgnored() throws DataLoad private UserPrefs getTypicalUserPrefs() { UserPrefs userPrefs = new UserPrefs(); userPrefs.setGuiSettings(new GuiSettings(1000, 500, 300, 100)); - userPrefs.setAddressBookFilePath(Paths.get("addressbook.json")); + userPrefs.setCampusConnectFilePath(Paths.get("CampusConnect.json")); return userPrefs; } diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 99a16548970..78d69a57b44 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.TypicalPersons.getTypicalCampusConnect; import java.nio.file.Path; @@ -11,8 +11,8 @@ import org.junit.jupiter.api.io.TempDir; import seedu.address.commons.core.GuiSettings; -import seedu.address.model.AddressBook; -import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.CampusConnect; +import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.UserPrefs; public class StorageManagerTest { @@ -24,9 +24,9 @@ public class StorageManagerTest { @BeforeEach public void setUp() { - JsonAddressBookStorage addressBookStorage = new JsonAddressBookStorage(getTempFilePath("ab")); + JsonCampusConnectStorage campusConnectStorage = new JsonCampusConnectStorage(getTempFilePath("ab")); JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(getTempFilePath("prefs")); - storageManager = new StorageManager(addressBookStorage, userPrefsStorage); + storageManager = new StorageManager(campusConnectStorage, userPrefsStorage); } private Path getTempFilePath(String fileName) { @@ -48,21 +48,21 @@ public void prefsReadSave() throws Exception { } @Test - public void addressBookReadSave() throws Exception { + public void campusConnectReadSave() throws Exception { /* * Note: This is an integration test that verifies the StorageManager is properly wired to the - * {@link JsonAddressBookStorage} class. - * More extensive testing of UserPref saving/reading is done in {@link JsonAddressBookStorageTest} class. + * {@link JsonCampusConnectStorage} class. + * More extensive testing of UserPref saving/reading is done in {@link JsonCampusConnectStorageTest} class. */ - AddressBook original = getTypicalAddressBook(); - storageManager.saveAddressBook(original); - ReadOnlyAddressBook retrieved = storageManager.readAddressBook().get(); - assertEquals(original, new AddressBook(retrieved)); + CampusConnect original = getTypicalCampusConnect(); + storageManager.saveCampusConnect(original); + ReadOnlyCampusConnect retrieved = storageManager.readCampusConnect().get(); + assertEquals(original, new CampusConnect(retrieved)); } @Test - public void getAddressBookFilePath() { - assertNotNull(storageManager.getAddressBookFilePath()); + public void getCampusConnectFilePath() { + assertNotNull(storageManager.getCampusConnectFilePath()); } } diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java deleted file mode 100644 index d53799fd110..00000000000 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -package seedu.address.testutil; - -import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; - -/** - * A utility class to help with building Addressbook objects. - * Example usage:
- * {@code AddressBook ab = new AddressBookBuilder().withPerson("John", "Doe").build();} - */ -public class AddressBookBuilder { - - private AddressBook addressBook; - - public AddressBookBuilder() { - addressBook = new AddressBook(); - } - - public AddressBookBuilder(AddressBook addressBook) { - this.addressBook = addressBook; - } - - /** - * Adds a new {@code Person} to the {@code AddressBook} that we are building. - */ - public AddressBookBuilder withPerson(Person person) { - addressBook.addPerson(person); - return this; - } - - public AddressBook build() { - return addressBook; - } -} diff --git a/src/test/java/seedu/address/testutil/CampusConnectBuilder.java b/src/test/java/seedu/address/testutil/CampusConnectBuilder.java new file mode 100644 index 00000000000..638257e5140 --- /dev/null +++ b/src/test/java/seedu/address/testutil/CampusConnectBuilder.java @@ -0,0 +1,34 @@ +package seedu.address.testutil; + +import seedu.address.model.CampusConnect; +import seedu.address.model.person.Person; + +/** + * A utility class to help with building CampusConnect objects. + * Example usage:
+ * {@code CampusConnect ab = new CampusConnectBuilder().withPerson("John", "Doe").build();} + */ +public class CampusConnectBuilder { + + private CampusConnect campusConnect; + + public CampusConnectBuilder() { + campusConnect = new CampusConnect(); + } + + public CampusConnectBuilder(CampusConnect campusConnect) { + this.campusConnect = campusConnect; + } + + /** + * Adds a new {@code Person} to the {@code CampusConnect} that we are building. + */ + public CampusConnectBuilder withPerson(Person person) { + campusConnect.addPerson(person); + return this; + } + + public CampusConnect build() { + return campusConnect; + } +} diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index fec76fb7129..0e0c3a1538e 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -15,7 +15,7 @@ import java.util.Arrays; import java.util.List; -import seedu.address.model.AddressBook; +import seedu.address.model.CampusConnect; import seedu.address.model.person.Person; /** @@ -60,10 +60,10 @@ public class TypicalPersons { private TypicalPersons() {} // prevents instantiation /** - * Returns an {@code AddressBook} with all the typical persons. + * Returns an {@code CampusConnect} with all the typical persons. */ - public static AddressBook getTypicalAddressBook() { - AddressBook ab = new AddressBook(); + public static CampusConnect getTypicalCampusConnect() { + CampusConnect ab = new CampusConnect(); for (Person person : getTypicalPersons()) { ab.addPerson(person); }