diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index cce613f8a03..8bc4e868107 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -82,6 +82,8 @@ implementation of a component), as illustrated in the (partial) class diagram be The sections below give more details of each component. +
+ ### UI component The **API** of this component is specified @@ -110,6 +112,8 @@ The `UI` component, and `Delivery` objects residing in the `Model`. +
+ ### Logic component **API** : @@ -133,9 +137,9 @@ PlantUML, the lifeline reaches the end of diagram. How the `Logic` component works: 1. When `Logic` is called upon to execute a command, it is passed to an `AddressBookParser` object which in turn creates - a parser that matches the command (e.g., `DeleteCommandParser`) and uses it to parse the command. -1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeleteCommand`) which - is executed by the `LogicManager`. + a parser that matches the command (e.g., `CustomerDeleteCommandParser`) 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., `CustomerDeleteCommand`) + which is executed by the `LogicManager`. 1. The command can communicate with the `Model` when it is executed (e.g. to delete a customer). 1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`. @@ -146,11 +150,13 @@ 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. -- 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. + placeholder for the specific command name e.g., `CustomerAddCommandParser`) which uses the other classes shown above + to parse the user command and create a `XYZCommand` object (e.g., `CustomerAddCommand`) which the `AddressBookParser` + returns back as a `Command` object. +- All `XYZCommandParser` classes (e.g., `CustomerAddCommandParser`, `DeliveryDeleteCommandParser`, ...) inherit from + the `Parser` interface so that they can be treated similarly where possible e.g, during testing. + +
### Model component @@ -158,13 +164,13 @@ How the parsing works: [`Model.java`](https://github.com/AY2324S1-CS2103T-T13-3/tp/tree/master/src/main/java/seedu/address/model/Model.java) - + The `Model` component, -* stores the address book data i.e., all `Customer` objects. (See the [ReadOnlyBook Model](#ReadOnlyBook-Model) section +* stores the address book data i.e., all `Customer` objects. (See the [ReadOnlyBook Model](#readonlybook-model) section below for more details) -* stores the delivery book data i.e., all `Delivery` objects. (See the [ReadOnlyBook Model](#ReadOnlyBook-Model) section +* stores the delivery book data i.e., all `Delivery` objects. (See the [ReadOnlyBook Model](#readonlybook-model) section below for more details) * stores the currently filtered `Customer` objects (See the [Customer Model](#customer-model)) as a separate _filteredCustomers_ list. (e.g., results of a `customer list` command) @@ -181,11 +187,14 @@ The `Model` component, * does not depend on any of the other three components (as the `Model` represents data entities of the domain, they should make sense on their own without depending on other components) + +
+ #### ReadOnlyBook Model -The `ReadOnlyBook` model, + - +The `ReadOnlyBook` model, * exposes the `AddressBook` and `DeliveryBook` to the outside. * The `AddressBook` class stores the address book data i.e., all `Customer` that are contained through @@ -193,31 +202,39 @@ The `ReadOnlyBook` model, * The `DeliveryBook` class stores the delivery book data i.e., all `Delivery` that are contained through the `UniqueDeliveryList`. +
+ #### User Model - + The `User` model, * stores the user data i.e, the username, password, secret question and secret answer of the user. +
+ #### Delivery Model - + The `Delivery` model, * stores the delivery data i.e, the delivery ID, delivery name, customer, delivery status, order date, expected delivery date and note for the delivery. +
+ #### Customer Model - + The `Customer` model, * stores the customer data i.e, the customer ID, customer address, phone, email and address. +
+ ### Storage component **API** : @@ -237,6 +254,8 @@ The concrete implementation of storage is done through `StorageManger`, which ho `BookStorage` and `BookStorageWithReference`. Which represents the User Preference Data, Address Book and Delivery Book respectively. +
+ ### Common classes Classes used by multiple components are in the `seedu.addressbook.commons` package. @@ -247,16 +266,16 @@ Classes used by multiple components are in the `seedu.addressbook.commons` packa This section describes some noteworthy details on how certain features are implemented. -* [Update Delivery Status Feature](#update-delivery-status-feature) -* [Create Note for Delivery Feature](#create-note-for-delivery-feature) -* [User Register Account Command](#user-register-account-command) -* [List Delivery Feature](#list-delivery-feature) -* [View Delivery Feature](#view-delivery-feature) -* [User Login Command](#user-login-command) -* [User Logout Command](#user-logout-command) -* [Add Customer Command](#add-customer-command) -* [Customer Edit Command](#customer-edit-command) -* [Delivery Add Command](#delivery-add-command) +- [Update Delivery Status](#update-delivery-status-feature) +- [Create Delivery Note](#create-note-for-delivery-feature) +- [User Register Account Command](#user-register-account-command) +- [Delivery List Command](#list-delivery-feature) +- [Deliver View Command](#view-delivery-feature) +- [User Login](#user-login-command) +- [User Logout](#user-logout-command) +- [Add Customer](#add-customer-command) +- [Customer Edit Command](#customer-edit-command) +- [Delivery Add Command](#delivery-add-command) ### Update Delivery Status Feature @@ -303,7 +322,10 @@ The sequence of the `delivery status` command is as follows: The following sequence diagram illustrates the `delivery status` command sequence: - + + + +
### Create Note for Delivery Feature @@ -354,7 +376,9 @@ command executes successfully The following diagram illustrates the `delivery note` command sequence: - + + +
###
User Register Account Command @@ -404,8 +428,10 @@ The following sequence diagram shows how the `register` command works: +
+ ### List Delivery Feature ### Overview @@ -440,7 +466,7 @@ The format of the `delivery list` command can be found The following activity diagram illustrates the logic for listing `Delivery`. Some ParseExceptions are omitted for better readability. - + The sequence of the `delivery list` command is as follows: @@ -475,6 +501,8 @@ The following sequence diagram illustrates the `delivery list` command sequence: +
+ ### View Delivery Feature #### Overview @@ -500,7 +528,7 @@ The format of the `delivery view` command can be found The following activity diagram illustrates the logic of viewing a `Delivery`. - + The sequence of the `delivery view` command is as follows: @@ -519,7 +547,9 @@ The sequence of the `delivery view` command is as follows: The following sequence diagram illustrates the `delivery view` command sequence: - + + +
### User Login Command @@ -535,10 +565,11 @@ The format for the `login` command can be found [here](UserGuide.md#login). 1. The user specifies the `Username` and `Password` in the `login` command. 2. If any of the fields is not provided, an error message with the correct command usage will be shown. 3. If invalid command parameters are provided, an error message with the correct parameter format will be shown. -4. If the user is currently logged in, an error message will be shown. -5. The `User` is then cross-referenced with the stored user in `Model` to check if the credentials match. +4. If there is no registered account found, an error message will be shown. +5. If the user is currently logged in, an error message will be shown. +6. The `User` is then cross-referenced with the stored user in `Model` to check if the credentials match. If incorrect credentials are provided, an error message regarding wrong credentials will be shown. -6. If all the previous steps are completed without exceptions, the user will be logged in and the +7. If all the previous steps are completed without exceptions, the user will be logged in and the `isLoggedIn` status in `Model` will be updated to `true`. The following activity diagram shows the logic of a user logging in: @@ -552,16 +583,19 @@ The sequence of the `login` command is as follows: 2. The user inputs the `login` command with the username and password. 3. The `userLoginCommandParser` checks whether all the required fields are present. If all fields are present, it creates a new `userLoginCommand`. -4. The `userLoginCommand` checks whether the user is currently logged in by calling `Model#getUserLoginStatus()`. -5. The `userLoginCommand` then checks if the user credentials match the stored user by calling `Model#userMatches()`. -6. If the user is not logged in and the credentials match, the `userLoginCommand` calls `Model#setLoginSuccess()`, - changing the login status to true and enabling the user access to all commands. -7. The `userLoginCommand` also calls `Model#updateFilteredPersonList()` to display the list of customers. +4. The `userLoginCommand` checks whether there is a registered account stored by calling `Model#getStoredUser`. +5. The `userLoginCommand` then checks whether the user is currently logged in by calling `Model#getUserLoginStatus`. +6. The `userLoginCommand` then checks if the user credentials match the stored user by calling `Model#userMatches`. +7. If the user is not logged in and the credentials match, the `userLoginCommand` calls `Model#setLoginSuccess`, + changing the login status to true and giving the user access to all commands. +8. The `userLoginCommand` also calls `Model#showAllFilteredCustomerList` to display the list of customers. The following sequence diagram shows how the `login` command works: +
+ ### User Logout Command **Overview:** @@ -588,16 +622,19 @@ The sequence of the `logout` command is as follows: 1. The user inputs the `logout` command. 2. A new `userLogoutCommand` is created and checks whether the user is currently logged out - by calling `Model#getUserLoginStatus()`. -3. If the user is currently logged in, the `userLogoutCommand` calls `Model#setLogoutSuccess()`, + by calling `Model#getUserLoginStatus`. +3. If the user is currently logged in, the `userLogoutCommand` calls `Model#setLogoutSuccess`, changing the login status to false and restricting the user access to most commands. -4. The `userLoginCommand` also calls `Model#updateFilteredPersonList()` to hide the list of customers. +4. The `userLogoutCommand` also calls `Model#clearFilteredDeliveryList` and `Model#clearFilteredCustomerList` + to hide the list of deliveries and customers. -The following sequence diagram shows how the `login` command works: +The following sequence diagram shows how the `logout` command works: - + -### Add Customer Command +
+ +### Customer Add Command **Overview:** @@ -612,8 +649,8 @@ The format for the `customer add` command can be found [here](UserGuide.md#add-a 2. If any of the fields is not provided, an error message with the correct command usage will be shown. 3. If invalid command parameters are provided, an error message with the correct parameter format will be shown. 4. If the user is currently not logged in, an error message will be shown. -5. The `Customer` is then cross-referenced in the `Model` to check if a customer with the same `Name` already exists. - If a customer with the same `Name` exists, an error message will be shown. +5. The `Customer` is then cross-referenced in the `Model` to check if a customer with the same `Phone` already exists. + If a customer with the same `Phone` exists, an error message will be shown. 6. If all the previous steps are completed without exceptions, the new `Customer` will be successfully added to the database. @@ -623,22 +660,24 @@ The following activity diagram shows the logic of adding a `Customer` into the d The sequence of the `customer add` command is as follows: -1. The user inputs the `customer add ARG` command (e.g. `customer add --name Gabriel --phone 87654321 +1. The user inputs the `customer add` command (e.g. `customer add --name Gabriel --phone 87654321 --email gabrielrocks@gmail.com --address RVRC Block B`). -2. The `LogicManager` calls the `AddressBookParser#parseCommand` with `ARG` to parse the command. +2. The `LogicManager` calls the `AddressBookParser#parseCommand` with the user input to parse the command. 3. The `AddressBookParser` then creates a new `CustomerAddCommandParser` to parse the fields provided by the user. 4. A corresponding `Customer` is created by the `CustomerAddCommandParser`, which is used to create a new `CustomerAddCommand`. -5. The `CustomerAddCommand` checks whether the user is currently logged in by calling `Model#getUserLoginStatus()`. -6. The `CustomerAddCommand` then checks if the `Model` contains a customer with the same `Name` - by calling `Model#hasPerson`. -7. If the user is logged in and the `Model` does not contain a customer with the same `Name`, the `CustomerAddCommand` - calls `Model#addPerson` to add the new `Customer` to the database. +5. The `CustomerAddCommand` checks whether the user is currently logged in by calling `Model#getUserLoginStatus`. +6. The `CustomerAddCommand` then checks if the `Model` contains a customer with the same `Phone` + by calling `Model#hasCustomer`. +7. If the user is logged in and the `Model` does not contain a customer with the same `Phone`, the `CustomerAddCommand` + calls `Model#addCustomer` to add the new `Customer` to the database. -The following sequence diagram shows how the `login` command works: +The following sequence diagram shows how the `customer add` command works: +
+ ### Customer Edit Command **Overview:** @@ -687,6 +726,8 @@ The following sequence diagram shows how the `customer edit` command works: +
+ ### Delivery Add Command **Overview:** @@ -734,6 +775,8 @@ The following sequence diagram shows how the `delivery add` command works: +
+ ### \[Proposed\] Undo/redo feature #### Proposed Implementation @@ -885,29 +928,29 @@ thereby improving efficiency for business owners. Priorities: High (must have) - `***`, Medium (nice to have) - `**`, Low (unlikely to have) - `*` -| Priority | As a …​ | I want to …​ | So that I can…​ | +| Priority | As …​ | I want to …​ | So that …​ | |----------|--------------------|--------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `***` | an owner | create a local account | I can personalise and secure my account. | +| `***` | an owner | create a local account | I can personalise my account and secure my data. | | `***` | a registered owner | log in to my local account | I can access my data. | -| `***` | a forgetful owner | retrieve my account | I can still recover my data. | +| `***` | a forgetful owner | retrieve my account | I can still recover my data if I forget my password. | | `***` | a logged-in owner | log out of my account | I can keep my data secure. | -| `***` | a registered owner | delete my account | I can have greater control over my data and account removal for privacy reasons. | +| `***` | a registered owner | delete my account | I can clear all personal information or data from HomeBoss for privacy and security reasons. | | `***` | a registered owner | update my details | I can change my personalisation. | | `***` | a registered owner | create a customer | I can tie deliveries to customers’ information. | | `***` | a registered owner | view a customer | I can see their detailed information. | | `***` | a registered owner | see a customer's list of deliveries | I can easily see all the deliveries of a certain customer. | | `***` | a registered owner | quickly search for the details of a client | I can monitor the progress of an order efficiently and effectively. | -| `***` | a registered owner | update a customer | I can change details if keyed in wrongly. | +| `***` | a registered owner | update a customer's details | I can change details if keyed in wrongly. | | `***` | a registered owner | delete a customer | I can remove redundant or incorrect customer records, especially when unforeseen errors occur. | | `***` | a registered owner | view a list of customers | I can have a comprehensive overview of my customer base. | | `***` | a registered owner | create a delivery | I can efficiently organise and access delivery information. | | `***` | a registered owner | create notes about deliveries | I can add additional information about deliveries. | | `***` | a registered owner | view a list of deliveries | I can see a comprehensive overview of my deliveries. | | `***` | a registered owner | see the list of deliveries that would be delivered for the day | I can prioritise particular orders. | -| `***` | a registered owner | add a customer to a delivery | I know who the delivery is for. | +| `***` | a registered owner | add a customer to a delivery | I can know who the delivery is for. | | `***` | a registered owner | quickly search for the name of a delivery | I can monitor the progress of delivery. | -| `***` | a registered owner | see a list of deliveries sorted by their expected date of delivery | It more organised and easier for me to get an overview of all orders. | -| `***` | a registered owner | view the details of a delivery | I know what the order is and where to deliver it to. | +| `***` | a registered owner | see a list of deliveries sorted by their expected date of delivery | I can see a more organised list and easier for me to get an overview of all orders. | +| `***` | a registered owner | view the details of a delivery | I can know what the order is and where to deliver it to. | | `***` | a registered owner | update the status of the delivery | I can keep track of the delivery progress and notify my client. | | `***` | a registered owner | update delivery details | I can change any information if there was an error from user/me. | | `***` | a registered owner | delete a delivery | I can get rid of deliveries that are redundant. | @@ -970,8 +1013,8 @@ Priorities: High (must have) - `***`, Medium (nice to have) - `**`, Low (unlikel ### Use cases -(For all use cases below, the **System** is the `HomeBoss` and the **Actor** is the `user`, unless specified -otherwise) +For all use cases below, the **System** is `HomeBoss` and the **Actor** is the `user`, unless specified +otherwise. #### Use Case: UC01 - Register an Account @@ -990,21 +1033,22 @@ otherwise) 1. Unregistered owner opens HomeBoss application. 2. Unregistered owner enters register command with his username, password, confirm password, a "forget password" - question and answer. -3. US creates an account and shows a welcome message with the newly created username. + secret question and answer. +3. US creates an account and shows a welcome message. The GUI footer is updated with the username. + Use case ends. **Extensions:** * 2a. Unregistered owner does not enter one of the fields. - * 2a1. US requests unregistered owner to fill up all the required fields. + * 2a1. US requests unregistered owner to fill up all the required fields by showing expected command format. Use case ends. * 2b. Unregistered owner types incorrect confirm password. - * 2b1. US requests unregistered owner to retype their confirm password. + * 2b1. US points out password mismatch and requests unregistered owner to try again. Use case ends. @@ -1031,16 +1075,30 @@ otherwise) **Extensions:** -* 2a. Registered owner does not enter one of the fields - * 2a1. US requests registered owner to fill up all the required fields +* 2a. Registered Owner does not enter one of the fields. + + * 2a1. US displays an error to Registered Owner to fill up all the required fields. + + Use case ends. + +* 2b. Registered Owner types incorrect username or password. + + * 2b1. US displays an error to Registered Owner that the username or password is incorrect. Use case ends. -* 2b. Registered owner types incorrect password or username - * 2b1. US requests registered owner to retype their username or password +* 2c. Registered Owner types duplicated fields. + + * 2c1. US displays an error to Registered Owner that the field is duplicated. Use case ends. +* 2d. Registered Owner specifies values that do not match the field constraint. + + * 2d1. US displays an error to Registered Owner that the value is invalid and shows the constraint. + + Use Case ends. + --- #### Use Case: UC03 - Account Recovery @@ -1049,31 +1107,33 @@ otherwise) **Actor:** Registered owner -**Preconditions:** Registered owner is logged out. +**Preconditions:** An owner is registered with HomeBoss. **Guarantees:** -- Password would be changed. +- Password will be changed. **MSS:** 1. Registered owner opens the HomeBoss application. -2. Registered owner enters the account recovery command without any command flags (i.e., `--answer`). -3. US displays the forget password question that the user set during account registration. +2. Registered owner enters the account recovery command without any command flags (i.e., no `--answer`). +3. US displays the "forget password" secret question that the user set during account registration, together with the + command format for account recovery. 4. Registered owner enters the account recovery command, this time with the answer, new password and confirm password fields. -5. US logins and shows a success message. +5. US logs in and shows a success message confirming account recovery. + Use case ends. **Extensions:** * 4a. Registered owner does not enter the answer field. - * 4a1. US requests registered owner to fill up the answer field. + * 4a1. US requests registered owner to fill up all the required fields, and shows the expected command format. Use case ends. -* 4b. Registered owner types incorrect answer - * 4b1. US requests registered owner to retype their answer. +* 4b. Registered owner types incorrect answer. + * 4b1. US says that the answer is incorrect and requests registered owner to try again. Use case ends. @@ -1082,8 +1142,8 @@ otherwise) Use case ends. -* 4d. Registered owner types incorrect confirm password. - * 4d1. US requests registered owner to retype their confirm password. +* 4d. Registered owner types a password and confirm password that do not match. + * 4d1. US says that the passwords do not match and requests registered owner to try again. Use case ends. @@ -1113,7 +1173,7 @@ otherwise) **System:** User System (US) -**Actor:** Logged-in owner. +**Actor:** Registered owner. **Preconditions:** Account is present. @@ -1123,7 +1183,7 @@ otherwise) **MSS:** -1. Logged-in owner types command to delete his account. +1. Registered owner types command to delete his account. 2. User system shows a success message. Use case ends. @@ -1153,7 +1213,7 @@ otherwise) * 1a. Logged-in Owner does not specify at least one updated field(s). - * 1a1. US requests Logged-in Owner to specify at least one updated field. + * 1a1. US requests Logged-in Owner to specify at least one updated field by showing the expected command format. Use Case ends. @@ -1187,6 +1247,12 @@ otherwise) Use Case ends. +* 1c. Logged-in Owner specifies values that do not match the field constraint. + + * 1c1. US displays an error to Logged-in Owner that the value is invalid and shows the constraint. + + Use Case ends. + --- #### **Use Case: UC07 - Create Customer** @@ -1211,12 +1277,24 @@ otherwise) **Extensions:** -- 1a. Logged-in Owner does not specify the required field(s) +- 1a. Logged-in Owner does not specify the required field(s). + + - 1a1. CMS displays an error to Logged-in Owner to key in all the fields required to create a customer. + + Use Case ends. + +- 1b. Logged-in Owner specifies duplicated fields. - - 1a1. CMS requests Logged-in Owner to key in all the fields required to create a customer. + - 1b1. CMS displays an error to Logged-in Owner that the field is entered more than once. Use Case ends. +- 1c. Logged-in Owner specifies values that do not match the field constraint. + + - 1c1. CMS displays an error to Logged-in Owner that the value is invalid and shows the constraint. + + Use Case ends. + --- #### **Use Case: UC08 - View customer’s details** @@ -1254,25 +1332,6 @@ otherwise) --- -#### **Use Case: UC09 - Sort customers** - -**System:** Customer Management System (CMS) - -**Actor:** Logged-in owner - -**Preconditions:** Owner is logged in - -**Guarantees** - -* A list of deliveries of a customer is shown if the command is executed successfully. - -**MSS:** - -1. Logged-in Owner types in command to view what deliveries a particular customer has. -2. CMS shows the list of deliveries of that specific customer. - ---- - #### **Use Case: UC09 - Search for a Customer** **System:** Customer Management System (CMS) @@ -1296,19 +1355,19 @@ otherwise) - 1a. Logged-in Owner does not include any keyword. - - 1a1. CMS requests Logged-in Owner to specify a keyword. + - 1a1. CMS displays an error to Logged-in Owner to specify a keyword. Use Case ends. - 1b. No customer with specified keyword is found. - - 1b1. CMS displays a message where no customers with the specified keyword is found. + - 1b1. CMS displays a message where there are no customers found. Use Case ends. - 1c. There are no customers. - - 1c1. CMS displays a message where there are no customers at all. + - 1c1. CMS displays a message where there are no customers found. Use Case ends. @@ -1335,21 +1394,21 @@ otherwise) **Extensions:** -- 1a. Logged-in Owner does not specify at least one updated field(s). +- 1a. Logged-in owner did not specify at least one field to update. - - 1a1. CMS displays an error to Logged-in Owner to specify at least one field to update. + - 1a1. CMS informs the Logged-in Owner to specify at least one field to update. Use Case Ends. -- 1b. Logged-in Owner specifies invalid customer. +- 1b. Logged-in Owner specified a Customer ID that does not exist. - - 1b1. CMS displays an error to Logged-in Owner that the specified customer does not exist. + - 1b1. CMS informs the Logged-in Owner of invalid Customer ID being entered. Use Case Ends. -- 1c. Logged-in Owner does not specify customer. +- 1c. Logged-in Owner did not specify a Customer ID. - - 1c1. CMS displays an error to Logged-in Owner to specify a customer to update. + - 1c1. CMS informs the Logged-in Owner to specify a Customer to update. Use Case Ends. @@ -1365,7 +1424,7 @@ otherwise) **Guarantees:** -- Selected customer is deleted only if the command is executed successfully. +- Selected customer is deleted if the command is executed successfully. **MSS:** @@ -1376,15 +1435,21 @@ otherwise) **Extensions:** -- 1a. Logged-in Owner specifies invalid customer. +- 1a. Logged-in Owner specifies a customer ID that does not exist is a positive integer. - - 1a1. CMS displays an error to Logged-in Owner that the specified customer does not exist. + - 1a1. CMS displays an error to Logged-in Owner that the specified customer ID is invalid. Use Case Ends. -- 1b. Logged-in Owner does not specify customer. +- 1b. Logged-in Owner specifies a non-positive integer as customer ID. + + - 1b1. CMS displays an error to Logged-in Owner that the command format used is invalid, and shows the expected + command format. - - 1b1. CMS displays an error to Logged-in Owner to specify a customer to update. +- 1c. Logged-in Owner does not specify customer ID. + + - 1c1. CMS displays an error to Logged-in Owner that the command format used is invalid, and shows the expected + command format. Use Case Ends. @@ -1432,21 +1497,27 @@ otherwise) **Extensions:** -- 1a. Command has missing fields. +- 1a. Logged-in Owner did not specify all required fields. - - 1a1. DMS displays an error to Logged-in Owner to specify all required fields. + - 1a1. DMS informs the Logged-in Owner to specify all required fields. Use Case Ends. -- 1b. Command has invalid date. +- 1b. Logged-in Owner specified an invalid Expected Delivery date. - - 1b1. DMS displays an error to Logged-in Owner that an invalid date was given. + - 1b1. DMS informs the Logged-in Owner that an Invalid date was given. Use Case Ends. -- 1c. Command has invalid date format. +- 1c. Logged-in Owner specified an invalid date format. - - 1c1. DMS displays an error to Logged-in Owner to specify the date in a valid format. + - 1c1. DMS informs the Logged-in Owner to specify the date in a valid format. + + Use Case Ends. + +- 1d. Logged-in Owner specfied a Customer ID that does not exist. + + - 1d1. DMS informs the Logged-in Owner of invalid Customer ID being entered. Use Case Ends. @@ -1507,188 +1578,80 @@ otherwise) **MSS:** 1. Logged-in Owner types command to view a list of deliveries. -2. DMS displays a list of all deliveries sorted in descending expected delivery date (newest to oldest). +2. DMS displays a list of all deliveries sorted in descending expected delivery date (latest to earliest). Use Case Ends. **Extensions:** -* 1a. User specifies status field in command. - * 1a1. DMS display a list of deliveries filtered by the specified status. - - Use Case Ends. +- 1a. User specifies status field in command. -* 1b. User specifies customer field in command. - * 1b1. DMS displays a list of deliveries filtered by the specified customer. + - 1a1. DMS displays a list of deliveries filtered with the specified status. Use Case Ends. -* 1c. User specifies expected delivery date field in command. - * 1c1. DMS displays a list of deliveries filtered by the specified expected delivery date. +- 1b. User specifies customer field in command. - Use Case Ends. - -* 1d. User specifies both status and customer fields. - * 1c1. DMS displays a list of deliveries filtered by the specified status and customer. - - Use Case Ends. - -* 1e. User specifies both status and expected delivery date fields. - * 1e1. DMS displays a list of deliveries filtered by the specified status and expected delivery date. + - 1b1. DMS displays a list of deliveries filtered by the specified customer id. Use Case Ends. -* 1f. User specifies both customer and expected delivery date fields. - * 1f1. DMS displays a list of deliveries filtered by the specified customer and expected delivery date. +- 1c. User specifies expected delivery date field in command. - Use Case Ends. -* 1g. User specifies customer, expected delivery date and status fields. - * 1g1. DMS displays a list of deliveries filtered by the specified customer, expected delivery date and status. + - 1c1. DMS displays a list of deliveries filtered by the specified expected delivery date. Use Case Ends. -* 1g. User specifies sort field in command. - * 1b1. DMS displays a list of all deliveries sorted by the specified sort order. - - Use Case Ends. +- 1d. User specifies expected delivery date field as "TODAY" in command. -* 1h. User Specifies both filter fields and sort fields. - * 1c1. DMS displays a list of deliveries filtered by the specified filters and then expected delivery date sorted - by the specified sort order. + - 1d1. DMS displays a list of deliveries filtered by the expected delivery date that is today's date. Use Case Ends. -#### **Use case:** UC16 - Delivery List for the Day - -**System:** Delivery Management System (DMS) -**Actor:** Logged-in owner. - -**Preconditions:** Owner is logged in. - -**Guarantees:** - -- A list of deliveries for the day is displayed only if the command is executed successfully. - -**MSS:** +- 1e. User specifies a sort field in command. -1. Logged-in Owner types command to view a list of deliveries for the day. -2. DMS displays a list of deliveries for the day. - - Use Case Ends. - -**Extensions:** - -- 1a. Command has missing fields. - - - 1a1. DMS displays an error to Logged-in Owner. + - 1e1. DMS displays a list of all deliveries sorted by the specified sort order. Use Case Ends. ---- - -#### **Use case:** UC17 - Add Customer to Delivery +- 1f. User specifies a combination of the filter fields and sort field. -**System:** Delivery Management System (DMS) -**Actor:** Logged-in owner. - -**Preconditions:** Owner is logged in. - -**Guarantees:** - -- A customer is added to a delivery only if the command is executed successfully. - -**MSS:** - -1. Logged-in Owner types command to add a customer to a delivery. -2. DMS shows success message. - - Use Case Ends. - -**Extensions:** - -- 1a. Command has missing fields. - - - 1a1. DMS displays an error to Logged-in Owner to specify all required fields. + - 1f1. DMS displays a list of deliveries filtered by the specified filters and sorted by the specified sort + order. Use Case Ends. -- 1b. Command has invalid customer details. - - - 1b1. DMS displays an error to Logged-in Owner that the specified customer details is invalid. - - Use Case Ends. - ---- - -#### **Use case:** UC18 - Remove Customer from Delivery - -**System:** Delivery Management System (DMS) -**Actor:** Logged-in owner. - -**Preconditions:** Owner is logged in. - -**Guarantees:** - -- A customer is removed from a delivery only if the command is executed successfully. +- 1g. User specifies duplicate fields -**MSS:** - -1. Logged-in Owner types command to remove a customer from a delivery. -2. DMS shows success message. - - Use Case Ends. - -**Extensions:** - -- 1a. Command has missing fields. - - - 1a1. DMS displays an error to Logged-in Owner to specify all required fields. + - 1g1. DMS displays a list of deliveries filtered by the last occurrence of each specified filters and sorted by the + last specified sort Use Case Ends. -- 1b. Command has invalid customer details. +- 1h. Logged-in Owner specifies invalid status. - - 1b1. DMS displays an error to Logged-in Owner that the specified customer cannot be found. + - 1h1. DMS displays an error to Logged-in Owner that the specified status is invalid and state the possible accepted + status values. Use Case Ends. ---- - -#### **Use case:** UC19 - Specify Delivery Method - -**System:** Delivery Management System (DMS) -**Actor:** Logged-in owner. - -**Preconditions:** Owner is logged in. - -**Guarantees:** +- 1i. Logged-in Owner specifies an invalid date. -- A delivery method is specified only if the command is executed successfully. - -**MSS:** - -1. Logged-in Owner types command to specify a delivery method. -2. DMS shows success message. - - Use Case Ends. - -**Extensions:** - -- 1a. Command has missing fields. - - - 1a1. DMS displays an error to Logged-in Owner to specify all required fields. + - 1i1. DMS displays an error to Logged-in Owner that the specified date is in an invalid format and states what + format it should be in. Use Case Ends. -- 1b. Command has invalid delivery options. +- 1j. Logged-in Owner specifies an invalid sort. - - 1b1. DMS displays an error to Logged-in Owner that the specified delivery method is invalid. + - 1j1. DMS displays an error to Logged-in Owner that the specified sort is invalid and state the possible accepted + values. Use Case Ends. --- -#### **Use case:** UC20 - Search for Delivery +#### **Use case:** UC17 - Search for Delivery **System:** Delivery Management System (DMS) **Actor:** Logged-in owner. @@ -1716,46 +1679,11 @@ otherwise) --- -#### Use Case: UC21 - View location of delivery - -**System:** Delivery Management System (DMS) - -**Actor:** Logged-in owner. - -**Preconditions:** Owner is logged-in. - -**Guarantees:** - -- Delivery location is shown only if the command is executed successfully. - -**MSS:** - -1. Logged-in owner types command to view location of delivery. -2. DMS displays the address of the customer associated with the delivery. - - Use case ends. - -**Extensions** - -- 1a. Logged-in owner did not specify the delivery id. - - - 1a1. DMS informs the logged-in owner of the missing field. - - Use case ends. - -- 1b. Logged-in owner specified a delivery id that does not exist. - - - 1b1. DMS informs the logged-in owner of invalid delivery id being entered. - - Use case ends. - ---- - -#### Use Case: UC22 - View details of delivery +#### Use Case: UC18 - View details of delivery **System:** Delivery Management System (DMS) -**Actor:** Logged-in owner. +**Actor:** Logged-in Owner. **Preconditions:** Owner is logged-in. @@ -1774,19 +1702,19 @@ otherwise) - 1a. Logged-in owner did not specify the delivery id. - - 1a1. DMS informs the logged-in owner of the missing field. + - 1a1. DMS displays an error to Logged-in Owner to specify all required fields. Use case ends. - 1b. Logged-in owner specified a delivery id that does not exist. - - 1b1. DMS informs the logged-in owner of invalid delivery id being entered. + - 1b1. DMS displays an error to Logged-in Owner of invalid delivery id being entered. Use case ends. --- -#### Use Case: UC23 - Update delivery status +#### Use Case: UC19 - Update delivery status **System:** Delivery Management System (DMS) @@ -1827,7 +1755,7 @@ otherwise) --- -#### Use Case: UC24 - Update delivery details +#### Use Case: UC20 - Update delivery details **System:** Delivery Management System (DMS) @@ -1848,27 +1776,27 @@ otherwise) **Extensions** -- 1a. Logged-in owner did not specify all the fields. +- 1a. Logged-in owner did not specify at least one field to update. - - 1a1. DMS informs the logged-in owner to specify all the fields. + - 1a1. DMS informs the Logged-in Owner to specify at least one field to update. Use case ends. -- 1b. Logged-in owner specified a delivery id that does not exist. +- 1b. Logged-in owner specified a Delivery ID that does not exist. - - 1b1. DMS informs the logged-in owner of invalid delivery id being entered. + - 1b1. DMS informs the logged-in owner of Invalid delivery id being entered. Use case ends. -- 1c. Logged-in owner entered date in the wrong format. +- 1c. Logged-in owner did not specifiy a Delivery ID. - - 1c1. DMS informs the logged-in owner of invalid format and shows the correct format. + - 1c1. DMS informs the logged-in Owner to specify a Delivery to update. Use case ends --- -#### Use Case: UC25 - Delete delivery +#### Use Case: UC21 - Delete delivery **System:** Delivery Management System (DMS) @@ -1889,23 +1817,18 @@ otherwise) **Extensions** -- 1a. Logged-in owner did not specify the delivery id. +- 1a. Logged-in owner did not specify the Delivery ID. - - 1a1. DMS informs the logged-in owner of the missing field. + - 1a1. DMS informs the Logged-in Owner to specify a Delivery to delete. Use case ends. -- 1b. Logged-in owner specified a delivery id that does not exist. +- 1b. Logged-in owner specified a Delivery ID that does not exist. - - 1b1. DMS informs the logged-in owner of invalid delivery id being entered. + - 1b1. DMS informs the logged-in owner of Invalid Delivery ID being entered. Use case ends. -- 1c. Logged-in owner specified a delivery that is in-progress. - - - 1c1. DMS informs the logged-in owner of the status of the delivery and does not delete it. - - Use case ends --- @@ -1928,7 +1851,7 @@ otherwise) 1. Perform Inventory Management 2. Perform Route Planning -_{More to be added}_ +
### Glossary @@ -1950,7 +1873,7 @@ _{More to be added}_ Given below are instructions to test the app manually. - + **Note:** These instructions only provide a starting point for testers to work on; testers are expected to do more _exploratory_ testing. @@ -1987,6 +1910,8 @@ testers are expected to do more _exploratory_ testing. 2. Using the `login`{.swift} command, log in into HomeBoss with the same user details entered earlier. Expected: User is able to log in successfully and see the HomeBoss homepage. +
+ ### Register 1. Registering for an account. @@ -2017,6 +1942,8 @@ testers are expected to do more _exploratory_ testing. Expected: No new user is registered. Error indicating existing account is shown in the feedback message. +
+ ### Login 1. Login to an account. @@ -2046,6 +1973,7 @@ testers are expected to do more _exploratory_ testing. Expected: The user does not get logged-in. Error indicating invalid command format is shown in the feedback message. +
### Update Account Details @@ -2087,6 +2015,8 @@ testers are expected to do more _exploratory_ testing. Expected: No user details are updated. Error indicating that secret question and answer must be both present or both absent is shown in the feedback message. +
+ ### Logout 1. Logging out of the application. @@ -2100,6 +2030,8 @@ testers are expected to do more _exploratory_ testing. 3. Test Case: `logout extra`{.swift} or other extra arguments.
Expected: Similar to previous. +
+ ### Recover Account 1. Recovering user account. @@ -2128,6 +2060,8 @@ testers are expected to do more _exploratory_ testing. Expected: No user details are updated. Error indicating invalid command format is shown in the feedback message. +
+ ### Delete Account 1. Delete currently stored user account. @@ -2140,6 +2074,8 @@ testers are expected to do more _exploratory_ testing. 3. Test Case: `delete account extra`{.swift} or other extra arguments.
Expected: Similar to previous. +
+ ### Add Customer 1. Adding a Customer to the application. @@ -2176,6 +2112,8 @@ testers are expected to do more _exploratory_ testing. Expected: No new Customer is added. Error indicating invalid command format is shown in the feedback message. +
+ ### View Details of Customer 1. View the details of a Customer. @@ -2201,6 +2139,8 @@ testers are expected to do more _exploratory_ testing. Expected: No new Customer details are shown. Error indicating invalid customer ID is shown in the feedback message. +
+ ### List Customers 1. List the Customers stored in the application. @@ -2215,6 +2155,8 @@ testers are expected to do more _exploratory_ testing. 3. Test Case: `customer list extra`{.swift}.
Expected: Similar to previous. +
+ ### Find Customers 1. Find a Customers matching query. @@ -2241,6 +2183,8 @@ testers are expected to do more _exploratory_ testing. Expected: No customers are shown. A message indicating the number of Customers listed is shown in the result message. +
+ ### Update Customer Details 1. Update the details of a specific Customer. @@ -2276,6 +2220,8 @@ testers are expected to do more _exploratory_ testing. Expected: No Customer details are updated. An error indicating invalid command format is shown in the feedback message. +
+ ### Delete Customers 1. Delete a specified Customer. @@ -2301,6 +2247,8 @@ testers are expected to do more _exploratory_ testing. Expected: No Customer is deleted. Error indicating invalid Customer ID is shown in the feedback message. +
+ ### Add Delivery 1. Adding a Delivery to the application. @@ -2341,6 +2289,8 @@ testers are expected to do more _exploratory_ testing. Expected: No new Delivery is added. An Error indicating invalid command format is shown in the feedback message. +
+ ### View Details of a Delivery 1. View the details of a Delivery. @@ -2366,6 +2316,8 @@ testers are expected to do more _exploratory_ testing. Expected: No new Delivery details are shown. Error indicating invalid delivery ID is shown in the feedback message. +
+ ### List Deliveries 1. List the Deliveries stored in the application. @@ -2420,6 +2372,8 @@ testers are expected to do more _exploratory_ testing. Expected: No Deliveries are listed. An Error indicating sort constraints is shown in the feedback message. +
+ ### Find Deliveries 1. Find Deliveries matching query. @@ -2447,6 +2401,8 @@ testers are expected to do more _exploratory_ testing. Expected: No Deliveries are shown. A message indicating the number of Deliveries listed is shown in the result message. +
+ ### Update details of a Delivery 1. Update the details of a specific Delivery. @@ -2517,6 +2473,8 @@ testers are expected to do more _exploratory_ testing. Expected: No Delivery details are updated. An error indicating invalid command format is shown in the feedback message. +
+ ### Update delivery status 1. Update the status of a specific Delivery. @@ -2545,6 +2503,8 @@ testers are expected to do more _exploratory_ testing. Expected: No delivery statuses are updated. An error indicating invalid command format is shown in the feedback message. +
+ ### Create a note for a Delivery 1. Create a note for a specific delivery. @@ -2575,6 +2535,8 @@ testers are expected to do more _exploratory_ testing. Expected: No delivery notes are updated. An error indicating invalid delivery ID is shown in the feedback message. +
+ ### Delete Delivery 1. Delete a specific delivery. @@ -2601,6 +2563,8 @@ testers are expected to do more _exploratory_ testing. Expected: No Delivery is deleted. An Error indicating invalid Delivery ID is shown in the feedback message. +
+ ### Help 1. Shows the help information to the user. @@ -2613,6 +2577,8 @@ testers are expected to do more _exploratory_ testing. 3. Test Case: `help extra`{.swift}.
Expected: Similar to previous. +
+ ### Exit 1. Exits the application. @@ -2625,6 +2591,8 @@ testers are expected to do more _exploratory_ testing. 3. Test Case: `exit extra`{.swift}.
Expected: Similar to previous. +
+ ### Clear 1. Clears all Customer and Delivery data. @@ -2638,6 +2606,8 @@ testers are expected to do more _exploratory_ testing. 3. Test Case: `clear extra`{.swift}.
Expected: Similar to previous. +
+ ### Saving data 1. Dealing with missing/corrupted data files. diff --git a/docs/diagrams/CustomerAddSequenceDiagram.puml b/docs/diagrams/CustomerAddSequenceDiagram.puml index 73b6c903597..023bb0d3bcf 100644 --- a/docs/diagrams/CustomerAddSequenceDiagram.puml +++ b/docs/diagrams/CustomerAddSequenceDiagram.puml @@ -62,13 +62,13 @@ activate Model Model --> CustomerAddCommand : isLoggedIn deactivate Model -CustomerAddCommand -> Model : hasPerson(c) +CustomerAddCommand -> Model : hasCustomer(c) activate Model Model --> CustomerAddCommand deactivate Model -CustomerAddCommand -> Model : addPerson(c) +CustomerAddCommand -> Model : addCustomer(c) activate Model Model --> CustomerAddCommand diff --git a/docs/diagrams/DeleteSequenceDiagram.puml b/docs/diagrams/DeleteSequenceDiagram.puml index 40ea6c9dc4c..df7f9b04b22 100644 --- a/docs/diagrams/DeleteSequenceDiagram.puml +++ b/docs/diagrams/DeleteSequenceDiagram.puml @@ -5,8 +5,8 @@ skinparam ArrowFontStyle plain box Logic LOGIC_COLOR_T1 participant ":LogicManager" as LogicManager LOGIC_COLOR participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR -participant ":DeleteCommandParser" as DeleteCommandParser LOGIC_COLOR -participant "d:DeleteCommand" as DeleteCommand LOGIC_COLOR +participant ":CustomerDeleteCommandParser" as CustomerDeleteCommandParser LOGIC_COLOR +participant "d:CustomerDeleteCommand" as CustomerDeleteCommand LOGIC_COLOR participant ":CommandResult" as CommandResult LOGIC_COLOR end box @@ -14,56 +14,56 @@ box Model MODEL_COLOR_T1 participant ":Model" as Model MODEL_COLOR end box -[-> LogicManager : execute("delete 1") +[-> LogicManager : execute("customer delete 1") activate LogicManager -LogicManager -> AddressBookParser : parseCommand("delete 1") +LogicManager -> AddressBookParser : parseCommand("customer delete 1") activate AddressBookParser -create DeleteCommandParser -AddressBookParser -> DeleteCommandParser -activate DeleteCommandParser +create CustomerDeleteCommandParser +AddressBookParser -> CustomerDeleteCommandParser +activate CustomerDeleteCommandParser -DeleteCommandParser --> AddressBookParser -deactivate DeleteCommandParser +CustomerDeleteCommandParser --> AddressBookParser +deactivate CustomerDeleteCommandParser -AddressBookParser -> DeleteCommandParser : parse("1") -activate DeleteCommandParser +AddressBookParser -> CustomerDeleteCommandParser : parse("1") +activate CustomerDeleteCommandParser -create DeleteCommand -DeleteCommandParser -> DeleteCommand -activate DeleteCommand +create CustomerDeleteCommand +CustomerDeleteCommandParser -> CustomerDeleteCommand +activate CustomerDeleteCommand -DeleteCommand --> DeleteCommandParser : d -deactivate DeleteCommand +CustomerDeleteCommand --> CustomerDeleteCommandParser : d +deactivate CustomerDeleteCommand -DeleteCommandParser --> AddressBookParser : d -deactivate DeleteCommandParser +CustomerDeleteCommandParser --> AddressBookParser : d +deactivate CustomerDeleteCommandParser 'Hidden arrow to position the destroy marker below the end of the activation bar. -DeleteCommandParser -[hidden]-> AddressBookParser -destroy DeleteCommandParser +CustomerDeleteCommandParser -[hidden]-> AddressBookParser +destroy CustomerDeleteCommandParser AddressBookParser --> LogicManager : d deactivate AddressBookParser -LogicManager -> DeleteCommand : execute() -activate DeleteCommand +LogicManager -> CustomerDeleteCommand : execute() +activate CustomerDeleteCommand -DeleteCommand -> Model : deletePerson(1) +CustomerDeleteCommand -> Model : deleteCustomer(1) activate Model -Model --> DeleteCommand +Model --> CustomerDeleteCommand deactivate Model create CommandResult -DeleteCommand -> CommandResult +CustomerDeleteCommand -> CommandResult activate CommandResult -CommandResult --> DeleteCommand +CommandResult --> CustomerDeleteCommand deactivate CommandResult -DeleteCommand --> LogicManager : result -deactivate DeleteCommand +CustomerDeleteCommand --> LogicManager : result +deactivate CustomerDeleteCommand [<--LogicManager deactivate LogicManager diff --git a/docs/diagrams/UserLoginActivityDiagram.puml b/docs/diagrams/UserLoginActivityDiagram.puml index 9f7d0513d8b..55709dcd160 100644 --- a/docs/diagrams/UserLoginActivityDiagram.puml +++ b/docs/diagrams/UserLoginActivityDiagram.puml @@ -10,19 +10,18 @@ start if () then ([else]) :ParseException: Invalid Command Format; stop -([all fields are filled]) elseif () then ([user is already logged in]) +( [all fields are filled]) elseif () then ([user is already logged in]) :CommandException: Already Logged In; stop -([else]) elseif () then ([else]) +( [else]) elseif () then ([else]) :CommandException: Wrong Credentials; stop -else ([fields matches +else ( [fields matches stored user]) endif :User login command is executed successfully. User is now logged in.; -:Show full Customer List; stop @enduml diff --git a/docs/diagrams/UserLoginSequenceDiagram.puml b/docs/diagrams/UserLoginSequenceDiagram.puml index 5664adde9e5..599f4f8af56 100644 --- a/docs/diagrams/UserLoginSequenceDiagram.puml +++ b/docs/diagrams/UserLoginSequenceDiagram.puml @@ -31,7 +31,7 @@ AddressBookParser -> UserLoginCommandParser : parse(arg) activate UserLoginCommandParser create User -UserLoginCommandParser -> User : new User(username, password) +UserLoginCommandParser -> User : new User(username, password, true) activate User User --> UserLoginCommandParser @@ -56,6 +56,12 @@ deactivate AddressBookParser LogicManager -> UserLoginCommand : execute(model) activate UserLoginCommand +UserLoginCommand -> Model : getStoredUser() +activate Model + +Model --> UserLoginCommand : storedUser +deactivate Model + UserLoginCommand -> Model : getUserLoginStatus() activate Model @@ -74,7 +80,7 @@ activate Model Model --> UserLoginCommand deactivate Model -UserLoginCommand -> Model : updateFilteredPersonList(PREDICATE_SHOW_ALL_CUSTOMERS) +UserLoginCommand -> Model : showAllFilteredCustomerList() activate Model Model --> UserLoginCommand diff --git a/docs/diagrams/UserLogoutActivityDiagram.puml b/docs/diagrams/UserLogoutActivityDiagram.puml index f6bc3f06b7b..e53d4926883 100644 --- a/docs/diagrams/UserLogoutActivityDiagram.puml +++ b/docs/diagrams/UserLogoutActivityDiagram.puml @@ -13,7 +13,6 @@ if () then ([user is already logged out]) else ([else]) :User logout command is executed successfully. User is now logged out.; - :Hide Customer and Delivery List; endif stop diff --git a/docs/diagrams/UserLogoutSequenceDiagram.puml b/docs/diagrams/UserLogoutSequenceDiagram.puml index 933c0186597..c1121ec0ae2 100644 --- a/docs/diagrams/UserLogoutSequenceDiagram.puml +++ b/docs/diagrams/UserLogoutSequenceDiagram.puml @@ -43,13 +43,13 @@ activate Model Model --> UserLogoutCommand deactivate Model -UserLogoutCommand -> Model : updateFilteredPersonList(PREDICATE_SHOW_NO_CUSTOMERS) +UserLogoutCommand -> Model : clearFilteredDeliveryList() activate Model Model --> UserLogoutCommand deactivate Model -UserLogoutCommand -> Model : updateFilteredDeliveryList(PREDICATE_SHOW_NO_DELIVERIES) +UserLogoutCommand -> Model : clearFilteredCustomerList() activate Model Model --> UserLogoutCommand diff --git a/src/main/java/seedu/address/logic/commands/customer/CustomerDeleteCommand.java b/src/main/java/seedu/address/logic/commands/customer/CustomerDeleteCommand.java index 6c0f22f61a8..300d9f06899 100644 --- a/src/main/java/seedu/address/logic/commands/customer/CustomerDeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/customer/CustomerDeleteCommand.java @@ -29,9 +29,9 @@ public class CustomerDeleteCommand extends CustomerCommand { * The message usage of the delete customer command. */ public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Deletes the customer identified by the customer ID used in the displayed customer list.\n\n" - + "Parameters: CUSTOMER_ID (must be a positive integer)\n\n" - + "Example: " + COMMAND_WORD + " 1"; + + ": Deletes the customer identified by the customer ID used in the displayed customer list.\n\n" + + "Parameters: CUSTOMER_ID (must be a positive integer and less than 2147483648)\n\n" + + "Example: " + COMMAND_WORD + " 1"; /** * The pre-text to the message displayed when the customer is deleted successfully. @@ -69,7 +69,7 @@ public CommandResult execute(Model model) throws CommandException { requireNonNull(model); logger.info("Executing CustomerDeleteCommand:" - + " customerID: " + customerID.getOneBased() + "\n"); + + " customerID: " + customerID.getOneBased() + "\n"); // User cannot perform this operation before logging in if (!model.getUserLoginStatus()) { @@ -90,7 +90,7 @@ public CommandResult execute(Model model) throws CommandException { model.deleteCustomer(customerToDelete.get()); return new CommandResult(String.format(MESSAGE_DELETE_CUSTOMER_SUCCESS, - Messages.format(customerToDelete.get())), true); + Messages.format(customerToDelete.get())), true); } /** @@ -122,7 +122,7 @@ public boolean equals(Object other) { @Override public String toString() { return new ToStringBuilder(this) - .add("customerID", customerID) - .toString(); + .add("customerID", customerID) + .toString(); } } diff --git a/src/main/java/seedu/address/logic/commands/customer/CustomerEditCommand.java b/src/main/java/seedu/address/logic/commands/customer/CustomerEditCommand.java index 323da048050..42187332067 100644 --- a/src/main/java/seedu/address/logic/commands/customer/CustomerEditCommand.java +++ b/src/main/java/seedu/address/logic/commands/customer/CustomerEditCommand.java @@ -42,19 +42,19 @@ public class CustomerEditCommand extends CustomerCommand { public static final String COMMAND_WORD = CustomerCommand.COMMAND_WORD + " " + "edit"; /** - * The text displayed to show what the command does and how to use it. + * The text displayed to show what the command does and how to use it. */ public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " - + "by the customer ID used in the displayed person list. " - + "Existing values will be overwritten by the input values.\n\n" - + "Parameters: CUSTOMER_ID (must be a positive integer) " - + "[" + PREFIX_NAME + " NAME] " - + "[" + PREFIX_PHONE + " PHONE] " - + "[" + PREFIX_EMAIL + " EMAIL] " - + "[" + PREFIX_ADDRESS + " ADDRESS]\n\n" - + "Example: " + COMMAND_WORD + " 1 " - + PREFIX_PHONE + " 91234567 " - + PREFIX_EMAIL + " johndoe@example.com"; + + "by the customer ID used in the displayed person list. " + + "Existing values will be overwritten by the input values.\n\n" + + "Parameters: CUSTOMER_ID (must be a positive integer and less than 2147483648) " + + "[" + PREFIX_NAME + " NAME] " + + "[" + PREFIX_PHONE + " PHONE] " + + "[" + PREFIX_EMAIL + " EMAIL] " + + "[" + PREFIX_ADDRESS + " ADDRESS]\n\n" + + "Example: " + COMMAND_WORD + " 1 " + + PREFIX_PHONE + " 91234567 " + + PREFIX_EMAIL + " johndoe@example.com"; /** * The text to the message displayed when the Customer is edited successfuly. @@ -73,6 +73,7 @@ public class CustomerEditCommand extends CustomerCommand { /** * Creates a CustomerEditCommand to edit the customers. + * * @param targetIndex of the person in the filtered person list to edit * @param customerEditDescriptor details to edit the person with */ @@ -86,6 +87,7 @@ public CustomerEditCommand(Index targetIndex, CustomerEditDescriptor customerEdi /** * Executes the CustomerEditCommand. + * * @param model {@code Model} which the command should operate on. * @return The command result along with the message to be displayed to the user. * @throws CommandException If the user is not logged in or if the customer does not exist or if the edited diff --git a/src/main/java/seedu/address/logic/commands/delivery/DeliveryDeleteCommand.java b/src/main/java/seedu/address/logic/commands/delivery/DeliveryDeleteCommand.java index 71130837673..3e2380559ba 100644 --- a/src/main/java/seedu/address/logic/commands/delivery/DeliveryDeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/delivery/DeliveryDeleteCommand.java @@ -26,9 +26,9 @@ public class DeliveryDeleteCommand extends DeliveryCommand { public static final String COMMAND_WORD = DeliveryCommand.COMMAND_WORD + " " + "delete"; public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Deletes the delivery identified by the delivery ID used in the displayed delivery list.\n\n" - + "Parameters: DELIVERY_ID (must be a positive integer)\n\n" - + "Example: " + COMMAND_WORD + " 1"; + + ": Deletes the delivery identified by the delivery ID used in the displayed delivery list.\n\n" + + "Parameters: DELIVERY_ID (must be a positive integer and less than 2147483648)\n\n" + + "Example: " + COMMAND_WORD + " 1"; /** * The text to the message displayed when the Delivery is delete successfuly. @@ -44,6 +44,7 @@ public class DeliveryDeleteCommand extends DeliveryCommand { /** * Creates a DeliveryDeleteCommand to delete the specified {@code Delivery} + * * @param targetIndex */ public DeliveryDeleteCommand(Index targetIndex) { @@ -52,6 +53,7 @@ public DeliveryDeleteCommand(Index targetIndex) { /** * Executes the DeliveryDeleteCommand. + * * @param model {@code Model} which the command should operate on. * @return The command result along with the message to be displayed to the user. * @throws CommandException If the delivery to be deleted does not exist or the user is not logged in. diff --git a/src/main/java/seedu/address/logic/commands/delivery/DeliveryEditCommand.java b/src/main/java/seedu/address/logic/commands/delivery/DeliveryEditCommand.java index 529fc155fd3..72d96f68fb5 100644 --- a/src/main/java/seedu/address/logic/commands/delivery/DeliveryEditCommand.java +++ b/src/main/java/seedu/address/logic/commands/delivery/DeliveryEditCommand.java @@ -44,21 +44,21 @@ public class DeliveryEditCommand extends DeliveryCommand { * The text displayed to show what the command does and how to use it. */ public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the delivery identified " - + "by the DELIVERY_ID used in the displayed delivery list. " - + "Existing values will be overwritten by the input values.\n\n" - + "Parameters: DELIVERY_ID (must be a positive integer)\n\n" - + "At least one field must be specified." - + "[" + PREFIX_NAME + " DELIVERY_NAME] " - + "[" + PREFIX_CUSTOMER_ID + " CUSTOMER_ID] " - + "[" + PREFIX_DATE + " DELIVERY_DATE] " - + "[" + PREFIX_STATUS + " STATUS] " - + "[" + PREFIX_NOTE + " NOTE]...\n\n" - + "Example: " + COMMAND_WORD + " 1 " - + PREFIX_NAME + " 10 Chocolate Cakes " - + PREFIX_DATE + " 2025-12-12"; + + "by the DELIVERY_ID used in the displayed delivery list. " + + "Existing values will be overwritten by the input values.\n\n" + + "Parameters: DELIVERY_ID (must be a positive integer and less than 2147483648)\n\n" + + "At least one field must be specified." + + "[" + PREFIX_NAME + " DELIVERY_NAME] " + + "[" + PREFIX_CUSTOMER_ID + " CUSTOMER_ID] " + + "[" + PREFIX_DATE + " DELIVERY_DATE] " + + "[" + PREFIX_STATUS + " STATUS] " + + "[" + PREFIX_NOTE + " NOTE]...\n\n" + + "Example: " + COMMAND_WORD + " 1 " + + PREFIX_NAME + " 10 Chocolate Cakes " + + PREFIX_DATE + " 2025-12-12"; /** - * The text to the message displayed when the Delivery is edited successfuly. + * The text to the message displayed when the Delivery is edited successfuly. */ public static final String MESSAGE_EDIT_DELIVERY_SUCCESS = "Edited Delivery:\n\n%1$s"; public static final String MESSAGE_NOT_EDITED = "At least one field must be provided!"; @@ -70,6 +70,7 @@ public class DeliveryEditCommand extends DeliveryCommand { /** * Creates a DeliveryEditCommand to edit the specified {@code Delivery} + * * @param targetIndex of the delivery in the delivery list to edit * @param deliveryEditDescriptor details to edit the delivery with */ @@ -115,7 +116,7 @@ public CommandResult execute(Model model) throws CommandException { model.showAllFilteredDeliveryList(); return new CommandResult(String.format(MESSAGE_EDIT_DELIVERY_SUCCESS, - Messages.format(editedDelivery)), true); + Messages.format(editedDelivery)), true); } diff --git a/src/main/java/seedu/address/logic/commands/delivery/DeliveryViewCommand.java b/src/main/java/seedu/address/logic/commands/delivery/DeliveryViewCommand.java index e952977ab2c..a597f26ec86 100644 --- a/src/main/java/seedu/address/logic/commands/delivery/DeliveryViewCommand.java +++ b/src/main/java/seedu/address/logic/commands/delivery/DeliveryViewCommand.java @@ -20,7 +20,7 @@ public class DeliveryViewCommand extends DeliveryCommand { public static final String COMMAND_WORD = DeliveryCommand.COMMAND_WORD + " view"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Displays a single delivery order.\n\n" + "Parameters: " - + "DELIVERY_ID (Must be a positive integer)\n\n" + + "DELIVERY_ID (Must be a positive integer and less than 2147483648)\n\n" + "Example: " + COMMAND_WORD + " " + "1"; diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index cf9b2f2ef73..6ab0f5fc1e8 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -26,7 +26,7 @@ */ public class ParserUtil { - public static final String MESSAGE_INVALID_INDEX = "ID must be an integer more than 0."; + public static final String MESSAGE_INVALID_INDEX = "ID must be an integer more than 0 and less than 2147483648."; /** diff --git a/src/main/java/seedu/address/model/delivery/Delivery.java b/src/main/java/seedu/address/model/delivery/Delivery.java index b4445604113..b93d72b8d91 100644 --- a/src/main/java/seedu/address/model/delivery/Delivery.java +++ b/src/main/java/seedu/address/model/delivery/Delivery.java @@ -48,29 +48,6 @@ public Delivery(DeliveryName name, Customer customer, OrderDate orderDate, this.note = note; } - - /** - * Constructor for Delivery. - * - * @param deliveryId The ID of the delivery. - * @param name The name of the delivery. - * @param customer The customer who ordered the delivery. - * @param orderDate The date the delivery was ordered. - * @param deliveryDate The date the delivery will be delivered. - * @param status The status of the delivery. - */ - public Delivery(int deliveryId, DeliveryName name, Customer customer, OrderDate orderDate, - DeliveryDate deliveryDate, - DeliveryStatus status) { - Delivery.deliveryCount = Math.max(deliveryCount, deliveryId + 1); - this.deliveryId = deliveryId; - this.name = name; - this.customer = customer; - this.orderDate = orderDate; - this.deliveryDate = deliveryDate; - this.status = status; - } - /** * Constructor for Delivery. * Every field must be present and not null. @@ -199,10 +176,24 @@ public Note getNote() { return note; } + /** + * Sets the delivery count to the specified value. + * + * @param deliveryCount The value to set the delivery count to. + */ public static void setDeliveryCount(int deliveryCount) { Delivery.deliveryCount = deliveryCount; } + /** + * Returns the current delivery count. + * + * @return The current delivery count. + */ + public static int getDeliveryCount() { + return deliveryCount; + } + /** * Returns true if both deliveries have the same identity and data fields. * @@ -238,13 +229,13 @@ public boolean equals(Object other) { Delivery otherDelivery = (Delivery) other; return otherDelivery.deliveryId == deliveryId - && otherDelivery.deliveryDate.equals(deliveryDate) - && otherDelivery.name.equals(name) - && otherDelivery.customer.equals(customer) - && Objects.equals(otherDelivery.note, note) - && otherDelivery.orderDate.equals(orderDate) - && otherDelivery.status.equals(status) - && otherDelivery.getAddress().equals(customer.getAddress()); + && otherDelivery.deliveryDate.equals(deliveryDate) + && otherDelivery.name.equals(name) + && otherDelivery.customer.equals(customer) + && Objects.equals(otherDelivery.note, note) + && otherDelivery.orderDate.equals(orderDate) + && otherDelivery.status.equals(status) + && otherDelivery.getAddress().equals(customer.getAddress()); } @Override @@ -255,13 +246,13 @@ public int hashCode() { @Override public String toString() { return new ToStringBuilder(this).add("deliveryId", deliveryId) - .add("name", name) - .add("customer", customer) - .add("orderedAt", orderDate) - .add("deliveredAt", deliveryDate) - .add("address:", customer.getAddress()) - .add("note:", Optional.ofNullable(note) - .map(n -> String.format("\n Note:%s", n)).orElse("")) - .toString(); + .add("name", name) + .add("customer", customer) + .add("orderedAt", orderDate) + .add("deliveredAt", deliveryDate) + .add("address:", customer.getAddress()) + .add("note:", Optional.ofNullable(note) + .map(n -> String.format("\n Note:%s", n)).orElse("")) + .toString(); } } diff --git a/src/test/java/seedu/address/logic/commands/delivery/DeliveryListCommandTest.java b/src/test/java/seedu/address/logic/commands/delivery/DeliveryListCommandTest.java index 3f55f40e7b7..83a75d90b1b 100644 --- a/src/test/java/seedu/address/logic/commands/delivery/DeliveryListCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/delivery/DeliveryListCommandTest.java @@ -28,123 +28,128 @@ public class DeliveryListCommandTest { @Test public void execute_listIsNotFiltered_showsSameList() { assertCommandListSuccess(new DeliveryListCommand(null, null, null, null), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); } + @Test public void execute_listIsFiltered_showsEverything() { + + assertCommandListSuccess(new DeliveryListCommand(null, null, null, null), + model, DeliveryListCommand.MESSAGE_SUCCESS, model); + assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.CREATED, null, null, null), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.SHIPPED, null, null, null), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.COMPLETED, null, null, null), model, - DeliveryListCommand.MESSAGE_SUCCESS, - model); + DeliveryListCommand.MESSAGE_SUCCESS, + model); assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.CANCELLED, null, null, null), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); // customer id assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.COMPLETED, 2, null, null), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.COMPLETED, 2, null, null), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); // expected delivery date assertCommandListSuccess( - new DeliveryListCommand(DeliveryStatus.COMPLETED, null, new DeliveryDate(VALID_DELIVERY_DATE_3), null), - model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + new DeliveryListCommand(DeliveryStatus.COMPLETED, null, new DeliveryDate(VALID_DELIVERY_DATE_3), null), + model, + DeliveryListCommand.MESSAGE_SUCCESS, model); } @Test public void execute_listIsFiltered_empty() { assertCommandListSuccess( - new DeliveryListCommand(DeliveryStatus.CREATED, 1, new DeliveryDate("2001-12-12"), null), model, - DeliveryListCommand.MESSAGE_EMPTY, model); + new DeliveryListCommand(DeliveryStatus.CREATED, 1, new DeliveryDate("2001-12-12"), null), model, + DeliveryListCommand.MESSAGE_EMPTY, model); assertCommandListSuccess( - new DeliveryListCommand(DeliveryStatus.SHIPPED, 1, new DeliveryDate("2001-12-12"), null), model, - DeliveryListCommand.MESSAGE_EMPTY, model); + new DeliveryListCommand(DeliveryStatus.SHIPPED, 1, new DeliveryDate("2001-12-12"), null), model, + DeliveryListCommand.MESSAGE_EMPTY, model); assertCommandListSuccess( - new DeliveryListCommand(DeliveryStatus.COMPLETED, 1, new DeliveryDate("2001-12-12"), null), model, - DeliveryListCommand.MESSAGE_EMPTY, model); + new DeliveryListCommand(DeliveryStatus.COMPLETED, 1, new DeliveryDate("2001-12-12"), null), model, + DeliveryListCommand.MESSAGE_EMPTY, model); assertCommandListSuccess( - new DeliveryListCommand(DeliveryStatus.CANCELLED, 1, new DeliveryDate("2001-12-12"), null), model, - DeliveryListCommand.MESSAGE_EMPTY, model); + new DeliveryListCommand(DeliveryStatus.CANCELLED, 1, new DeliveryDate("2001-12-12"), null), model, + DeliveryListCommand.MESSAGE_EMPTY, model); } @Test public void execute_listIsFilteredAndSortedAscending_showsSameList() { assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.CREATED, null, null, Sort.ASC), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.SHIPPED, 2, null, Sort.ASC), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); assertCommandListSuccess( - new DeliveryListCommand(DeliveryStatus.COMPLETED, 2, new DeliveryDate(VALID_DELIVERY_DATE_3), Sort.ASC), - model, - DeliveryListCommand.MESSAGE_SUCCESS, - model); + new DeliveryListCommand(DeliveryStatus.COMPLETED, 2, new DeliveryDate(VALID_DELIVERY_DATE_3), Sort.ASC), + model, + DeliveryListCommand.MESSAGE_SUCCESS, + model); assertCommandListSuccess(new DeliveryListCommand(DeliveryStatus.CANCELLED, null, null, Sort.ASC), model, - DeliveryListCommand.MESSAGE_SUCCESS, model); + DeliveryListCommand.MESSAGE_SUCCESS, model); } @Test public void execute_listIsSortedAscending_showsSameList() { assertCommandListSuccess(new DeliveryListCommand(null, null, null, Sort.ASC), model, - DeliveryListCommand.MESSAGE_SUCCESS, - model); + DeliveryListCommand.MESSAGE_SUCCESS, + model); } @Test public void execute_listIsSortedDescending_showsSameList() { assertCommandListSuccess(new DeliveryListCommand(null, null, null, Sort.DESC), model, - DeliveryListCommand.MESSAGE_SUCCESS, - model); + DeliveryListCommand.MESSAGE_SUCCESS, + model); } @Test public void execute_listIsNotFilteredLoggedOut_throwsCommandException() { model.setLogoutSuccess(); assertCommandFailure(new DeliveryListCommand(null, null, null, null), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); } @Test public void execute_listIsFilteredLoggedOut_throwsCommandException() { model.setLogoutSuccess(); assertCommandFailure(new DeliveryListCommand(DeliveryStatus.CREATED, null, null, null), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); assertCommandFailure(new DeliveryListCommand(DeliveryStatus.SHIPPED, null, null, null), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); assertCommandFailure(new DeliveryListCommand(DeliveryStatus.COMPLETED, null, null, null), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); assertCommandFailure(new DeliveryListCommand(DeliveryStatus.CANCELLED, null, null, null), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); } @Test public void execute_listIsFilteredAndSortedAscendingLoggedOut_throwsCommandException() { model.setLogoutSuccess(); assertCommandFailure(new DeliveryListCommand(DeliveryStatus.CREATED, null, null, Sort.ASC), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); assertCommandFailure(new DeliveryListCommand(DeliveryStatus.SHIPPED, null, null, Sort.ASC), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); assertCommandFailure(new DeliveryListCommand(DeliveryStatus.COMPLETED, null, null, Sort.ASC), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); assertCommandFailure(new DeliveryListCommand(DeliveryStatus.CANCELLED, null, null, Sort.ASC), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); } @Test public void execute_listIsSortedAscendingLoggedOut_throwsCommandException() { model.setLogoutSuccess(); assertCommandFailure(new DeliveryListCommand(null, null, null, Sort.ASC), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); } @Test public void execute_listIsSortedDescendingLoggedOut_throwsCommandException() { model.setLogoutSuccess(); assertCommandFailure(new DeliveryListCommand(null, null, null, Sort.DESC), model, - Messages.MESSAGE_USER_NOT_AUTHENTICATED); + Messages.MESSAGE_USER_NOT_AUTHENTICATED); } @@ -153,21 +158,21 @@ public void equals() { DeliveryListCommand deliveryListCommand = new DeliveryListCommand(null, null, null, null); DeliveryListCommand deliveryListCommand1 = new DeliveryListCommand(DeliveryStatus.CREATED, null, null, null); DeliveryListCommand deliveryListCommand2 = new DeliveryListCommand(DeliveryStatus.CREATED, null, null, - Sort.ASC); + Sort.ASC); DeliveryListCommand deliveryListCommand3 = new DeliveryListCommand(DeliveryStatus.CREATED, null, null, - Sort.DESC); + Sort.DESC); DeliveryListCommand deliveryListCommand4 = new DeliveryListCommand(DeliveryStatus.COMPLETED, null, null, - Sort.ASC); + Sort.ASC); DeliveryListCommand deliveryListCommand5 = new DeliveryListCommand(DeliveryStatus.COMPLETED, 1, null, - Sort.ASC); + Sort.ASC); DeliveryListCommand deliveryListCommand6 = new DeliveryListCommand(DeliveryStatus.COMPLETED, 2, null, - Sort.ASC); + Sort.ASC); DeliveryListCommand deliveryListCommand7 = new DeliveryListCommand(DeliveryStatus.COMPLETED, 1, - new DeliveryDate(VALID_DELIVERY_DATE_1), - Sort.ASC); + new DeliveryDate(VALID_DELIVERY_DATE_1), + Sort.ASC); DeliveryListCommand deliveryListCommand8 = new DeliveryListCommand(DeliveryStatus.COMPLETED, 1, - new DeliveryDate(VALID_DELIVERY_DATE_2), - Sort.ASC); + new DeliveryDate(VALID_DELIVERY_DATE_2), + Sort.ASC); // same object -> returns true assertTrue(deliveryListCommand.equals(deliveryListCommand)); diff --git a/src/test/java/seedu/address/logic/parser/delivery/DeliveryListCommandParserTest.java b/src/test/java/seedu/address/logic/parser/delivery/DeliveryListCommandParserTest.java index cd24f633e5a..727e798a5f6 100644 --- a/src/test/java/seedu/address/logic/parser/delivery/DeliveryListCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/delivery/DeliveryListCommandParserTest.java @@ -1,5 +1,7 @@ package seedu.address.logic.parser.delivery; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static seedu.address.logic.commands.CommandTestUtil.INVALID_DELIVERY_LIST; import static seedu.address.logic.commands.CommandTestUtil.INVALID_DELIVERY_LIST_ALL; import static seedu.address.logic.commands.CommandTestUtil.INVALID_DELIVERY_LIST_CUSTOMER_ID; @@ -7,6 +9,7 @@ import static seedu.address.logic.commands.CommandTestUtil.INVALID_DELIVERY_LIST_DELIVERY_DATE_MONTH; import static seedu.address.logic.commands.CommandTestUtil.INVALID_DELIVERY_LIST_DELIVERY_DATE_TODAY; import static seedu.address.logic.commands.CommandTestUtil.INVALID_DELIVERY_LIST_SORT; +import static seedu.address.logic.commands.CommandTestUtil.VALID_DELIVERY_DATE_3; import static seedu.address.logic.commands.CommandTestUtil.VALID_DELIVERY_LIST_CANCELLED; import static seedu.address.logic.commands.CommandTestUtil.VALID_DELIVERY_LIST_COMPLETED; import static seedu.address.logic.commands.CommandTestUtil.VALID_DELIVERY_LIST_CREATED; @@ -25,15 +28,17 @@ import seedu.address.logic.Messages; import seedu.address.logic.Sort; import seedu.address.logic.commands.delivery.DeliveryListCommand; +import seedu.address.logic.commands.delivery.DeliveryViewCommand; import seedu.address.logic.parser.CommandParserTestUtil; import seedu.address.logic.parser.ParserUtil; import seedu.address.model.delivery.Date; +import seedu.address.model.delivery.DeliveryDate; import seedu.address.model.delivery.DeliveryStatus; public class DeliveryListCommandParserTest { - private DeliveryListCommandParser parser = new DeliveryListCommandParser(); + private DeliveryListCommandParser parser = new DeliveryListCommandParser(); @Test public void parse_validArgs_returnsDeliveryListCommand() { @@ -70,7 +75,35 @@ public void parse_validArgs_returnsDeliveryListCommand() { CommandParserTestUtil.assertParseSuccess(parser, VALID_DELIVERY_LIST_SORT_DESC, new DeliveryListCommand(null, null, null, Sort.DESC)); + } + + @Test + public void parse_duplicateArgs_returnsDeliveryListCommand() { + CommandParserTestUtil.assertParseSuccess(parser, VALID_DELIVERY_LIST_SHIPPED + VALID_DELIVERY_LIST_CANCELLED, + new DeliveryListCommand(DeliveryStatus.CANCELLED, null, null, Sort.DESC)); + CommandParserTestUtil.assertParseSuccess(parser, + VALID_DELIVERY_LIST_DELIVERY_DATE + VALID_DELIVERY_LIST_DELIVERY_DATE, + new DeliveryListCommand(null, null, new DeliveryDate(VALID_DELIVERY_DATE_3), Sort.DESC)); + CommandParserTestUtil.assertParseSuccess(parser, + VALID_DELIVERY_LIST_DELIVERY_DATE + VALID_DELIVERY_LIST_DELIVERY_DATE_TODAY, + new DeliveryListCommand(null, null, new DeliveryDate(LocalDate.now().format( + DateTimeFormatter.ofPattern(Date.FORMAT))), Sort.DESC)); + CommandParserTestUtil.assertParseSuccess(parser, + VALID_DELIVERY_LIST_SHIPPED + VALID_DELIVERY_LIST_CANCELLED + VALID_DELIVERY_LIST_DELIVERY_DATE_TODAY + + VALID_DELIVERY_LIST_DELIVERY_DATE, + new DeliveryListCommand(DeliveryStatus.CANCELLED, null, new DeliveryDate(VALID_DELIVERY_DATE_3), + Sort.DESC)); + + CommandParserTestUtil.assertParseSuccess(parser, + VALID_DELIVERY_LIST_SORT_DESC + VALID_DELIVERY_LIST_SORT_ASC, + new DeliveryListCommand(null, null, null, + Sort.ASC)); + CommandParserTestUtil.assertParseSuccess(parser, + VALID_DELIVERY_LIST_SHIPPED + VALID_DELIVERY_LIST_CANCELLED + VALID_DELIVERY_LIST_DELIVERY_DATE_TODAY + + VALID_DELIVERY_LIST_DELIVERY_DATE + VALID_DELIVERY_LIST_SORT_DESC + VALID_DELIVERY_LIST_SORT_ASC, + new DeliveryListCommand(DeliveryStatus.CANCELLED, null, new DeliveryDate(VALID_DELIVERY_DATE_3), + Sort.ASC)); } @Test @@ -147,4 +180,45 @@ public void parse_validStatusAndSort_returnsDeliveryListCommand() { CommandParserTestUtil.assertParseSuccess(parser, VALID_DELIVERY_LIST_SHIPPED + VALID_DELIVERY_LIST_SORT_DESC, new DeliveryListCommand(DeliveryStatus.SHIPPED, null, null, Sort.DESC)); } + + @Test + public void equals() { + DeliveryListCommand deliveryListCommand = new DeliveryListCommand(DeliveryStatus.SHIPPED, 1, + new Date("2023-12-12"), Sort.ASC); + + // same object -> returns true + assertEquals(deliveryListCommand, deliveryListCommand); + + // same values -> returns true + DeliveryListCommand deliveryListCommandCopy = new DeliveryListCommand(DeliveryStatus.SHIPPED, 1, + new Date("2023-12-12"), + Sort.ASC); + assertEquals(deliveryListCommand, deliveryListCommandCopy); + + // different types -> returns false + assertNotEquals(deliveryListCommand, new DeliveryViewCommand(1)); + + // null -> returns false + assertNotEquals(deliveryListCommand, null); + + // different status -> returns false + DeliveryListCommand differentDeliveryListCommand = new DeliveryListCommand(DeliveryStatus.CANCELLED, 1, + new Date("2023-12-12"), Sort.ASC); + assertNotEquals(deliveryListCommand, differentDeliveryListCommand); + + // different sort -> returns false + differentDeliveryListCommand = new DeliveryListCommand(DeliveryStatus.SHIPPED, 1, new Date("2023-12-12"), + Sort.DESC); + assertNotEquals(deliveryListCommand, differentDeliveryListCommand); + + // different customer id -> returns false + differentDeliveryListCommand = new DeliveryListCommand(DeliveryStatus.SHIPPED, 2, new Date("2023-12-12"), + Sort.ASC); + assertNotEquals(deliveryListCommand, differentDeliveryListCommand); + + // different delivery date -> returns false + differentDeliveryListCommand = new DeliveryListCommand(DeliveryStatus.SHIPPED, 1, + new Date("2024-12-12"), Sort.ASC); + assertNotEquals(deliveryListCommand, differentDeliveryListCommand); + } } diff --git a/src/test/java/seedu/address/model/delivery/DeliveryTest.java b/src/test/java/seedu/address/model/delivery/DeliveryTest.java index d1e7c848145..b77516f80fc 100644 --- a/src/test/java/seedu/address/model/delivery/DeliveryTest.java +++ b/src/test/java/seedu/address/model/delivery/DeliveryTest.java @@ -1,5 +1,6 @@ package seedu.address.model.delivery; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.testutil.TypicalDeliveries.GABRIELS_MILK; @@ -13,6 +14,7 @@ public class DeliveryTest { + @Test public void deliveryId_success() { Delivery delivery = new DeliveryBuilder().autoBuild(); @@ -29,6 +31,16 @@ public void deliveryId_failure() { assertFalse(delivery.getDeliveryId() == delivery1.getDeliveryId()); } + @Test + public void setDeliveryCount_success() { + Delivery delivery = new DeliveryBuilder().autoBuild(); + Delivery delivery1 = new DeliveryBuilder().autoBuild(); + Delivery delivery2 = new DeliveryBuilder().autoBuild(); + + Delivery.setDeliveryCount(1); + assertEquals(1, Delivery.getDeliveryCount()); + } + @Test public void setOrderDate() { Delivery delivery = new DeliveryBuilder().autoBuild(); @@ -100,8 +112,8 @@ public void isSameDelivery() { // different id, all other attributes different -> returns false editedGabrielsMilk = new DeliveryBuilder(GABRIELS_MILK).withName("Gabriel Milk Updated") - .withStatus(DeliveryStatus.COMPLETED).withCustomer(TypicalCustomers.BOB).withOrderDate("2019-12-12") - .withDeliveryDate("2024-12-12").autoBuild(); + .withStatus(DeliveryStatus.COMPLETED).withCustomer(TypicalCustomers.BOB).withOrderDate("2019-12-12") + .withDeliveryDate("2024-12-12").autoBuild(); assertFalse(GABRIELS_MILK.isSameDelivery(editedGabrielsMilk)); } @@ -145,13 +157,13 @@ public void equals() { // same id, different attributes -> returns false editedGabrielsMilk = new DeliveryBuilder(GABRIELS_MILK).withName("Gabriel Milk Updated") - .withStatus(DeliveryStatus.COMPLETED).withCustomer(TypicalCustomers.BOB).build(); + .withStatus(DeliveryStatus.COMPLETED).withCustomer(TypicalCustomers.BOB).build(); assertFalse(GABRIELS_MILK.equals(editedGabrielsMilk)); // different id, all other attributes different -> returns false editedGabrielsMilk = new DeliveryBuilder(GABRIELS_MILK).withName("Gabriel Milk Updated") - .withStatus(DeliveryStatus.COMPLETED).withCustomer(TypicalCustomers.BOB).withOrderDate("2019-12-12") - .withDeliveryDate("2024-12-12").autoBuild(); + .withStatus(DeliveryStatus.COMPLETED).withCustomer(TypicalCustomers.BOB).withOrderDate("2019-12-12") + .withDeliveryDate("2024-12-12").autoBuild(); assertFalse(GABRIELS_MILK.isSameDelivery(editedGabrielsMilk)); // different delivery address, all other attributes same -> returns false @@ -168,7 +180,7 @@ public void equals() { // different delivery note, all other attributes same -> returns false editedGabrielsMilk = new DeliveryBuilder(GABRIELS_MILK).withNote( - "Different note").build(); + "Different note").build(); assertFalse(GABRIELS_MILK.equals(editedGabrielsMilk)); } }