diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md
index 46dd5839b1d..2d83a25c98d 100644
--- a/docs/DeveloperGuide.md
+++ b/docs/DeveloperGuide.md
@@ -242,7 +242,7 @@ To display the new `details` field, modifications to the `applicationCard.java`
Below is an image of the UI after the changes were made:
-![Ui-after-details-update](images/Ui-after-details-update.png)
+![Ui-after-details-update](images/Ui.png)
#### Proposed improvements
1. As the colour of each `application card` alternates between each index, changes to the `Ui` have to be made as well to match the alternating colours. To achieve this change, implementing the css style in `DarkTheme.css` file, in particular `List-view` css should be made when implementing changes to the `applicationCard.fxml`
diff --git a/docs/UserGuide.md b/docs/UserGuide.md
index 11145db8044..e33e275aa73 100644
--- a/docs/UserGuide.md
+++ b/docs/UserGuide.md
@@ -5,30 +5,42 @@ title: User Guide
SoC InternApply (SIA) is a **desktop app for managing internship applications, optimized for use via a Command Line Interface** (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, SIA can get your internship application management tasks done faster than traditional GUI apps.
+With SoC InternApply, you can easily add an application, edit it later on if there are any changes needed, find the applications based on keywords and also sort them based on priority, interview date and much more! All while not having to worry about saving or storing your applications as this is done internally and automatically by SoC InternApply.
+
+Ultimately, with SoC InternApply, you can worry less about the administrative tasks and focus more on preparing for the interviews themselves!
+
+## Table of Contents
* Table of Contents
- {:toc}
+{:toc}
+
+--------------------------------------------------------------------------------------------------------------------
+## Glossary
+1. SIA (SoC InternApply)
+
+[Go To TOC](#table-of-contents)
--------------------------------------------------------------------------------------------------------------------
## Quick start
-1. Ensure you have Java `11` or above installed in your Computer.
+1. Ensure you have Java `11` or above installed in your Computer. You can download it from [this website](https://www.oracle.com/sg/java/technologies/javase/jdk11-archive-downloads.html).
2. Download the latest `internapply.jar` from [here](https://github.com/AY2122S2-CS2103T-T11-3/tp/releases).
-3. Copy the file to the folder you want to use as the _home folder_ for your SIA.
+3. Copy the file to the folder you want to use as the _root folder_ for your SIA (e.g. you can save it in your desktop or downloads folder).
+**Note:** There will be data (your internship applications) stored into this same folder, but it would not take up much space.
+
+4. Double-click the jar file to start the app. The GUI similar to the diagram below should appear in a few seconds. Note how the app contains some sample data.
-4. Double-click the jar file to start the app. The GUI similar to the below should appear in a few seconds. Note how the app contains some sample data.
![Ui](images/MainWindowUi.png)
-5. Another window should appear similar to the below. Note that this window **would contain any upcoming interviews you have in a weeks time**.
+5. Another reminder window should appear automatically similar to the below. Note that this window **would contain any upcoming interviews you have in a weeks time**.
![Ui](images/ReminderWindowUi.png)
-
6. Type the command in the command box and press Enter to execute it. e.g. typing **`help`** and pressing Enter will open the help window.
Some example commands you can try:
* **`help`** : Shows a message explaining how to access the help page.
- * **`list`** : Lists all applications.
+ * **`list`**`name desc` : Sort all applications base on company name in descending order.
* **`reminder`** : Lists all applications with upcoming interviews within a week from now.
@@ -48,6 +60,8 @@ SoC InternApply (SIA) is a **desktop app for managing internship applications, o
7. Refer to the [Features](#features) below for details of each command.
+[Go To TOC](#table-of-contents)
+
--------------------------------------------------------------------------------------------------------------------
## Features
@@ -62,6 +76,24 @@ SoC InternApply (SIA) is a **desktop app for managing internship applications, o
* Items in square brackets are optional.
e.g `n/NAME [t/TAG]` can be used as `n/Grab SG t/local` or as `n/Grab SG`.
+* Items with `…` after them can be used multiple times including zero times.
+ e.g. `[t/TAG]…` can be used as ` ` (i.e. 0 times), `t/local` or `t/local t/NUS` etc.
+
+* Parameters can be in any order.
+ e.g. if the command specifies `n/NAME p/PHONE_NUMBER`, `p/PHONE_NUMBER n/NAME` is also acceptable.
+
+* If a parameter is expected only once in the command but you specified it multiple times, only the last occurrence of the parameter will be taken.
+ e.g. if you specify `j/Software Engineer j/Data Scientist`, only `j/Data Scientist` will be taken.
+
+* Extraneous parameters for commands that do not take in parameters (such as `help`, `list`, `reminder`, `exit` and `clear`) will be ignored.
+ e.g. if the command specifies `help 123`, it will be interpreted as `help`.
+
+
+**:information_source: Notes about the input format:**
+
+* For `[t/TAG]...`, only alphanumeric inputs are allowed. i.e. Only the characters A-Z, a-z, 0-9.
+ e.g. `t/Based In Singapore` is not allowed, `t/BasedInSingapore` is allowed.
+
* For `[pt/PRIORITY_TAG]`, user input can only be any one of these: `HIGH`, `MEDIUM`, `LOW`
e.g `pt/HIGH` can be used to set priority of an application to `HIGH`
@@ -71,30 +103,31 @@ SoC InternApply (SIA) is a **desktop app for managing internship applications, o
* For `[pt/PRIORITY_TAG]` and `[ast/APPLICATION_STATUS_TAG]`, the inputs are case-insensitive
e.g. `pt/HIGH` can be inputted with `pt/high` and `ast/INTERVIEWD` can be inputted with `ast/Interviewed`
-* For `[t/TAG]...`, only alphanumeric inputs are allowed. i.e. Only the characters A-Z, a-z, 0-9.
- e.g. `t/Based In Singapore` is not allowed, `t/BasedInSingapore` is allowed.
-
-* Items with `…` after them can be used multiple times including zero times.
- e.g. `[t/TAG]…` can be used as ` ` (i.e. 0 times), `t/local`, `t/local t/NUS` etc.
-
-* Parameters can be in any order.
- e.g. if the command specifies `n/NAME p/PHONE_NUMBER`, `p/PHONE_NUMBER n/NAME` is also acceptable.
+* For `[j/JobTitle]...`, only alphanumeric inputs are allowed. i.e. Only the characters A-Z, a-z, 0-9. Spaces are also allowed.
+ e.g. `j/SoftwareEngineerIntern` is allowed, `t/Software Engineer Intern` is also allowed.
-* If a parameter is expected only once in the command but you specified it multiple times, only the last occurrence of the parameter will be taken.
- e.g. if you specify `j/Software Engineer j/Data Scientist`, only `j/Data Scientist` will be taken.
-* Extraneous parameters for commands that do not take in parameters (such as `help`, `list`, `reminder`, `exit` and `clear`) will be ignored.
- e.g. if the command specifies `help 123`, it will be interpreted as `help`.
+[Go To TOC](#table-of-contents)
+
### Viewing help : `help`
-Shows a message explaining how to access the help page.
+This command displays a message explaining how to access the help page.
+
+Format: `help`
+
+Example usages:
+
+`help`
+
+Expected outcome:
+A pop up window showing a link to the help page, as shown below.
![helpMessage](images/helpMessage.png)
-Format: `help`
+[Go To TOC](#table-of-contents)
### Adding an application: `add`
@@ -102,17 +135,58 @@ Adds an application to SoC InternApply.
Format: `add n/NAME_OF_COMPANY j/JOB_TITLE p/PHONE_NUMBER a/ADDRESS e/EMAIL [t/TAG]... [pt/PRIORITY_TAG] [ast/APPLICATION_STATUS_TAG]`
-**Note:** `[t/TAG]`, `[pt/PRIORITY_TAG]` and `[ast/APPLICATION_STATUS_TAG]` are optional.
+**Note:** `NAME_OF_COMPANY` has to be unique.
+**Note:** `[t/TAG]`, `[pt/PRIORITY_TAG]` and `[ast/APPLICATION_STATUS_TAG]` are optional.
-Examples:
+Example usages and expected outcomes:
* `add n/Shopee j/Software Engineer Intern p/87438807 e/hr@shopee.sg a/5 Science Park Dr, #06-40 t/SoftwareEngineering `
+
+Feedback message:
+```
+New application added: Shopee; Job Title: Software Engineer Intern; Phone: 87438807; Email: hr@shopee.sg; Address: 5 Science Park Dr, #06-40; Interview Slot: Interview date is not set.; Details: To add details, use the edit command; Tags: SoftwareEngineering
+```
+
* `add n/Shopee j/Software Engineer Intern p/87438807 e/hr@shopee.sg a/5 Science Park Dr, #06-40 t/SoftwareEngineering pt/HIGH ast/NOT_APPLIED`
-### Listing all applications : `list`
+Feedback message:
+```
+This application already exists in InternApply
+```
+
+[Go To TOC](#table-of-contents)
+
+### Listing all applications in a sorted manner : `list`
+
+Sorts the list of all application in SoC InternApply base on the provided paramters.
+
+Format: `list [sorting paramter] [order by]`
+
+Sorting paramters:
+- `name` : Sort by name of the company in alphabetical order starting with A in ascending order.
+- `interview` : Sort by interview date of applications starting with the latest earliest date.
+- `piroity` : Sort by piroity in the following order - HIGH, MEDIUM, LOW.
+- `status` : Sort by status in the following order - ACCEPTED, REJECTED, INTERVIEWED, APPLIE and NOT_APPLIED.
+
+* If optional fields (i.e. interview date and time, piroirty, status) do not exist in that certain application, that application will be move to the bottom of the sorting order. If there is more than one of such application, it will be sorted alphabeticaly.
+
+Order by:
+- `asc` : Order by ascending.
+- `desc` : Order by descending (reverse order of ascending).
+
+Examples:
+* `list interview desc`
+* `list name desc`, running this will output:
+```
+Sorted applications by name order by desc.
+```
+> 💡 The `list` command also works without paramters. It will reverted to the last sorted paramter and order used by the user. This is used after using the `find` feature to list out all applications.
+
+> ⚠️ Applications are originally sorted in a chonological order base on create date and time. Do take note that after using the `list` feature to sort, you will not be able to sort the applications in chronological order.
+
+> ❗ Sorting will not apply to newly added or newly edited applications. Please re-run the `list` coomand with the respective paramters to sort as per you like.
-Shows a list of all applications in SoC InternApply.
-Format: `list`
+[Go To TOC](#table-of-contents)
### Listing applications with upcoming interviews: `reminder`
@@ -120,32 +194,51 @@ Shows a list of applications with upcoming interviews, falling within a week fro
Format: `reminder`
+Example usages:
+
+`reminder`
+
+Expected outcome:
+
+A new window pops up, showing a list of applications with upcoming interviews within a week from now.
+
+[Go To TOC](#table-of-contents)
+
### Editing an application : `edit`
Edits an existing application in SoC InternApply.
Format: `edit INDEX [n/NAME] [j/JOB_TITLE] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [idt/INTERVIEW_DATE_TIME] [d/DETAILS] [t/TAG]... [pt/PRIORITY_TAG] [ast/APPLICATION_STATUS_TAG]`
+
+**CAUTION:** The `edit` command might overwrite your existing application data.
+
- Edits the application at the specified `INDEX`. The index refers to the index number shown in the displayed application list. The index **must be a positive integer** 1, 2, 3, ...
- At least one of the optional fields must be provided.
- Existing values will be updated to the input values.
- You can add an interview slot that includes both date and time by using the `idt/INTERVIEW_DATE_TIME`
-- The interview date time, `INTERVIEW_DATE_TIME`, must in the follow format `dd-MM-yyyy HH:mm`.
+- The interview date time, `INTERVIEW_DATE_TIME`, must be in the follow format `dd-MM-yyyy HH:mm`.
- You can add details to the application by using `d/DETAILS`
- You can enter new lines in the details by using `\n`
- You can remove `INTERVIEW_DATE_TIME` by typing `idt/` without specifying any tags after it.
-- When editing `TAG`'s, the `TAG`'s that are not specified by the user will be filled in using the corresponding `TAG`'s within the existing application.
+- When editing the `TAG` field, if `t/` is given without any input, the existing tags will be reused and not deleted.
-Examples:
+Example usages and expected outcomes:
- `edit 1 e/SoCStudent@example.com n/NUS Research` Edits the email and name of the 1st application to be `SoCStudent@example.com` and `NUS Research` respectively.
-- `edit 1 t/Singapore ast/APPLIED` Edits the tags and application status tag of the 1st application to Singapore and APPLIED respectively. Since the priority tag is not specified, the 1st application will keep it's current priority tag if it had any.
+- `edit 1 t/Singapore ast/APPLIED` Edits the tags and application status tag of the 1st application to Singapore and APPLIED respectively. Since the priority tag is not specified, the 1st application will keep its current priority tag if it had any.
- `edit 2 j/Intern idt/` Edits the job title of the 2nd application to be `Intern` and clears the existing interview date time.
-- `edit 1 d/Example details \nThis is a newline of the details` Edits the details to be:
+
+- To edit the details of an application, you can follow this format (adding \n to type in a new line): `edit 1 d/Example details \nThis is a newline of the details`
+
+e.g.`edit 1 d/This company requires a preliminary coding round.\n I should practice more on HackerRank` will result in this details being added:
+
```
-Example details
-This is a newline of the details
+This company requires a preliminary coding round.
+I should practice more on HackerRank
```
+[Go To TOC](#table-of-contents)
+
### Deleting an application : `delete`
Deletes the specified application from SoC InternApply.
@@ -156,9 +249,15 @@ Format: `delete INDEX`
* The index refers to the index number shown in the displayed application list.
* The index **must be a positive integer** 1, 2, 3, …
-Examples:
+Example usages:
* `list` followed by `delete 2` deletes the 2nd application.
+Expected outcome:
+
+The previous 2nd application is removed from the storage and a new list of applications is shown.
+
+[Go To TOC](#table-of-contents)
+
### Finding application(s) : `find`
Find existing applications in SoC InternApply.
@@ -169,14 +268,15 @@ Format: `find [n/NAME] or find [j/JOB_TITLE] or find [t/TAG]... or find [pt/PRIO
- Parameters are only expected once (except tags). e.g. `find n/shopee n/grab` is equivalent to `find n/grab`, the last occurrence of the parameter will be taken.
- If more than 1 different fields are given, i.e. `find n/shopee j/ML`, only the first field will be processed, i.e. `find n/shopee j/ML` is the same as `find n/shopee`
-Examples:
+Example usages and expected outcomes:
- `find n/shopee` finds and displays all applications with "shopee" in its name.
- `find j/ML` finds and displays all applications with "ML" in its job title.
- `find pt/HIGH` finds and displays all applications with "HIGH" in its priority tag.
- `find ast/applied` finds and displays all applications with "applied" in its application status. (note that it is case-insensitive)
- `find t/overseas` finds and displays all applications with "overseas" in its tags.
-- `find t/overseas t/USA` finds and displays all applications with "overseas" and "USA" in its tags.
+- `find t/overseas t/USA` finds and displays all applications with "overseas" or "USA" in its tags.
+[Go To TOC](#table-of-contents)
### Clearing all applications : `clear`
@@ -184,27 +284,36 @@ Clears all applications from SoC InternApply.
Format: `clear`
+[Go To TOC](#table-of-contents)
+
### Exiting the program : `exit`
Exits the program.
Format: `exit`
+[Go To TOC](#table-of-contents)
+
### Saving the data
InternApply data are saved in the hard disk automatically after any command that changes the data. There is no need to save manually.
-_More features coming soon ..._
+[Go To TOC](#table-of-contents)
--------------------------------------------------------------------------------------------------------------------
## FAQ
+**Q**: How do I know where my internship applications data is stored?
+**A**: Please locate where SoC InternApply is being stored on your computer. You will see a folder named `data` found in the root folder of the application (the folder containing SoC InternApply) Inside the `data` folder, you can find a data file named `internapplymemory.json`, which stores all the applications.
-**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 SoC InternApply home folder.
+**Q**: How do I transfer my data to another computer?
+**A**: Refer to the 1st QnA to locate the data file. Install the app in the other computer. Copy the contents of the data file of SoC InternApply from your previous computer and paste it in the empty data file of SoC InternApply of the new computer.
**Q**: When I run SIA for the first time, I do not see any of the sample application. How can I get the sample applications to appear in SIA?
-**A**: Please locate where InternApply data is being stored on your hard disk. This will usually be in a folder named `data` found in the root folder of the application. Delete any existing files in that folder and run SoC InternApply again.
+**A**: Refer to the 1st QnA to locate the `data` folder. Delete any existing files in the `data` folder and run SoC InternApply again.
+
+
+[Go To TOC](#table-of-contents)
--------------------------------------------------------------------------------------------------------------------
@@ -212,12 +321,15 @@ _More features coming soon ..._
Action | Format, Examples
--------|------------------
-**Help** | `help`
-**List** | `list`
-**Reminder**| `reminder`
-**Add** | `add n/NAME_OF_COMPANY p/PHONE_NUMBER a/ADDRESS j/JOB_TITLE e/EMAIL [t/TAG]... [pt/PRIORITY_TAG] [ast/APPLICATION_STATUS_TAG]`
e.g., `add n/Singtel j/UIUX Intern p/62527525 e/singtel@sg.com a/Singtel Group Strategic Communications and Brand, 31 Exeter Road, Comcentre #19-00 ast/APPLIED`
-**Edit** | `edit INDEX [n/NAME] [j/JOB_TITLE] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [idt/INTERVIEW_DATE_TIME] [t/TAG]... [pt/PRIORITY_TAG] [ast/APPLICATION_STATUS_TAG]`
e.g, `edit 1 n/Grab SG p/65358292 idt/17-03-2022 13:30`
-**Delete** | `delete INDEX`
e.g., `delete 3`
-**Find** | `find [n/NAME] or find [j/JOB_TITLE] or find [t/TAG]... or find [pt/PRIORITY_TAG] or find [ast/APPLICATION_STATUS_TAG]`
e.g., `find n/shopee`
-**Clear** | `clear`
-**Exit** | `exit`
+[**Add**](#adding-an-application) | `add n/NAME_OF_COMPANY p/PHONE_NUMBER a/ADDRESS j/JOB_TITLE e/EMAIL [t/TAG]... [pt/PRIORITY_TAG] [ast/APPLICATION_STATUS_TAG]`
e.g., `add n/Singtel j/UIUX Intern p/62527525 e/singtel@sg.com a/Singtel Group Strategic Communications and Brand, 31 Exeter Road, Comcentre #19-00 ast/APPLIED`
+[**Delete**](deleting-an-application) | `delete INDEX`
e.g., `delete 3`
+[**Clear**](clearing-all-applications) | `clear`
+[**Edit**](exit) | `edit INDEX [n/NAME] [j/JOB_TITLE] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [idt/INTERVIEW_DATE_TIME] [t/TAG]... [pt/PRIORITY_TAG] [ast/APPLICATION_STATUS_TAG]`
e.g, `edit 1 n/Grab SG p/65358292 idt/17-03-2022 13:30`
+[**Exit**](exiting-the-program) | `exit`
+[**Find**](finding-application(s)) | `find [n/NAME] or find [j/JOB_TITLE] or find [t/TAG]... or find [pt/PRIORITY_TAG] or find [ast/APPLICATION_STATUS_TAG]`
e.g., `find n/shopee`
+[**Help**](viewing-help) | `help`
+[**List**](listing-all-applications) | `list [sorting paramter] [order by]`
+[**Reminder**](listing-applications-with-upcoming-interviews)| `reminder`
+
+
+[Go To TOC](#table-of-contents)
diff --git a/docs/images/Ui-after-details-update.png b/docs/images/Ui.png
similarity index 100%
rename from docs/images/Ui-after-details-update.png
rename to docs/images/Ui.png
diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java
index 4e5337d5938..1f4331b087a 100644
--- a/src/main/java/seedu/address/logic/commands/ListCommand.java
+++ b/src/main/java/seedu/address/logic/commands/ListCommand.java
@@ -3,7 +3,15 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_APPLICATIONS;
+import java.util.Comparator;
+import java.util.Optional;
+
+import seedu.address.logic.sort.ApplicationStatusComparator;
+import seedu.address.logic.sort.InterviewSlotComparator;
+import seedu.address.logic.sort.NameComparator;
+import seedu.address.logic.sort.PriorityComparator;
import seedu.address.model.Model;
+import seedu.address.model.application.Application;
/**
* Lists all applications in InternApply to the user.
@@ -12,13 +20,58 @@ public class ListCommand extends Command {
public static final String COMMAND_WORD = "list";
- public static final String MESSAGE_SUCCESS = "Listed all applications";
+ public static final String COMMAND_ORDER_WORD_ASCENDING = "ASC";
+
+ public static final String COMMAND_ORDER_WORD_DESCENDING = "DESC";
+
+ public static final String MESSAGE_SUCCESS = "Sorted applications by %1$s";
+
+ public static final String MESSAGE_NO_CHANGE = "last sorted method.";
+
+ public static final String MESSAGE_NO_CHANGE_FULL = String.format(MESSAGE_SUCCESS, MESSAGE_NO_CHANGE);
+
+ public static final String MESSAGE_USAGE = COMMAND_WORD
+ + ": Show a sorted list of all applications with the given sort parameter.\n"
+ + "Parameters: [parameter "
+ + NameComparator.COMMAND_WORD.toUpperCase() + "|"
+ + InterviewSlotComparator.COMMAND_WORD.toUpperCase() + "|"
+ + PriorityComparator.COMMAND_WORD.toUpperCase() + "|"
+ + ApplicationStatusComparator.COMMAND_WORD.toUpperCase() + "] "
+ + "[order " + COMMAND_ORDER_WORD_ASCENDING + "|" + COMMAND_ORDER_WORD_DESCENDING + "] \n"
+ + "Example: " + COMMAND_WORD + " INTERVIEW " + COMMAND_ORDER_WORD_DESCENDING + "\n"
+ + "Note: Using list without parameters will revert to the last sorted.";
+ private final Optional> sortingComparator;
+ private final String orderBy;
+
+ /**
+ * Creates a ListCommand with the previous sorting order.
+ * Notes: the {@code sortingComparator} and {@code orderBy} are just placeholder values.
+ */
+ public ListCommand() {
+ sortingComparator = Optional.empty();
+ orderBy = COMMAND_ORDER_WORD_ASCENDING;
+ }
+
+ /**
+ * Creates a ListCommand with a specified {@code sortingComparator} and {@code orderBy}
+ */
+ public ListCommand(Comparator sortingComparator, String orderBy) {
+ this.sortingComparator = Optional.ofNullable(sortingComparator);
+ this.orderBy = orderBy;
+ }
@Override
public CommandResult execute(Model model) {
requireNonNull(model);
+ sortingComparator.ifPresent(applicationComparator -> model.sortApplications(applicationComparator, orderBy));
model.updateFilteredApplicationList(PREDICATE_SHOW_ALL_APPLICATIONS);
- return new CommandResult(MESSAGE_SUCCESS);
+ return new CommandResult(String.format(MESSAGE_SUCCESS, outputMsg()));
+ }
+
+ private String outputMsg() {
+ return sortingComparator.map(applicationComparator -> String.format(
+ "%s order by %s.", applicationComparator, orderBy.toLowerCase()))
+ .orElse(MESSAGE_NO_CHANGE);
}
}
diff --git a/src/main/java/seedu/address/logic/parser/InternApplyParser.java b/src/main/java/seedu/address/logic/parser/InternApplyParser.java
index 24f1d9c63a4..d3fd47164f7 100644
--- a/src/main/java/seedu/address/logic/parser/InternApplyParser.java
+++ b/src/main/java/seedu/address/logic/parser/InternApplyParser.java
@@ -61,7 +61,7 @@ public Command parseCommand(String userInput) throws ParseException {
return new FindCommandParser().parse(arguments);
case ListCommand.COMMAND_WORD:
- return new ListCommand();
+ return new ListCommandParser().parse(arguments);
case ExitCommand.COMMAND_WORD:
return new ExitCommand();
diff --git a/src/main/java/seedu/address/logic/parser/ListCommandParser.java b/src/main/java/seedu/address/logic/parser/ListCommandParser.java
new file mode 100644
index 00000000000..905224ac555
--- /dev/null
+++ b/src/main/java/seedu/address/logic/parser/ListCommandParser.java
@@ -0,0 +1,63 @@
+package seedu.address.logic.parser;
+
+import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
+import static seedu.address.logic.commands.ListCommand.COMMAND_ORDER_WORD_ASCENDING;
+import static seedu.address.logic.commands.ListCommand.COMMAND_ORDER_WORD_DESCENDING;
+
+import seedu.address.logic.commands.ListCommand;
+import seedu.address.logic.parser.exceptions.ParseException;
+import seedu.address.logic.sort.ApplicationStatusComparator;
+import seedu.address.logic.sort.InterviewSlotComparator;
+import seedu.address.logic.sort.NameComparator;
+import seedu.address.logic.sort.PriorityComparator;
+
+/**
+ * Parses input arguments and creates a new ListCommand object
+ */
+public class ListCommandParser implements Parser {
+
+ /**
+ * Parses the given {@code String} of arguments in the context of the ListCommand
+ * and returns a ListCommand object for execution.
+ * @throws ParseException if the user input does not conform the expected format
+ */
+ public ListCommand parse(String args) throws ParseException {
+ String trimmedArgs = args.trim();
+
+ if (trimmedArgs.isEmpty()) /* Handles default list */ {
+ return new ListCommand();
+ }
+
+ String[] sortingArgs = trimmedArgs.split("\\s+");
+
+ if (sortingArgs.length == 1) {
+ String keyword = sortingArgs[0];
+ if (keyword.equals(COMMAND_ORDER_WORD_DESCENDING)) {
+ return new ListCommand(null, COMMAND_ORDER_WORD_DESCENDING);
+ } else if (keyword.equals(COMMAND_ORDER_WORD_ASCENDING)) {
+ return new ListCommand();
+ }
+ } else {
+ String sortingField = sortingArgs[0].toLowerCase();
+ String orderBy = sortingArgs[1].toUpperCase();
+
+ if (validateOrderBy(orderBy)) {
+ throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ListCommand.MESSAGE_USAGE));
+ } else if (sortingField.equals(NameComparator.COMMAND_WORD)) {
+ return new ListCommand(new NameComparator(), orderBy);
+ } else if (sortingField.equals(InterviewSlotComparator.COMMAND_WORD)) {
+ return new ListCommand(new InterviewSlotComparator(), orderBy);
+ } else if (sortingField.equals(PriorityComparator.COMMAND_WORD)) {
+ return new ListCommand(new PriorityComparator(), orderBy);
+ } else if (sortingField.equals(ApplicationStatusComparator.COMMAND_WORD)) {
+ return new ListCommand(new ApplicationStatusComparator(), orderBy);
+ }
+ }
+
+ throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ListCommand.MESSAGE_USAGE));
+ }
+
+ private boolean validateOrderBy(String s) {
+ return !s.equals(COMMAND_ORDER_WORD_DESCENDING) && !s.equals(COMMAND_ORDER_WORD_ASCENDING);
+ }
+}
diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java
index a4ab50f9a67..83f56870489 100644
--- a/src/main/java/seedu/address/logic/parser/ParserUtil.java
+++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java
@@ -4,6 +4,7 @@
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -214,6 +215,9 @@ public static Tag parsePriorityTag(String tag) throws ParseException {
*/
public static Set parseTags(Collection tags) throws ParseException {
requireNonNull(tags);
+ if (tags.equals(Collections.emptySet())) {
+ throw new ParseException(Tag.MESSAGE_CONSTRAINTS);
+ }
final Set tagSet = new HashSet<>();
for (String tagName : tags) {
tagSet.add(parseTag(tagName));
diff --git a/src/main/java/seedu/address/logic/sort/ApplicationStatusComparator.java b/src/main/java/seedu/address/logic/sort/ApplicationStatusComparator.java
new file mode 100644
index 00000000000..c5ef813dd46
--- /dev/null
+++ b/src/main/java/seedu/address/logic/sort/ApplicationStatusComparator.java
@@ -0,0 +1,53 @@
+package seedu.address.logic.sort;
+
+import static seedu.address.model.tag.ApplicationStatusTagType.ACCEPTED;
+import static seedu.address.model.tag.ApplicationStatusTagType.APPLIED;
+import static seedu.address.model.tag.ApplicationStatusTagType.INTERVIEWED;
+import static seedu.address.model.tag.ApplicationStatusTagType.NOT_APPLIED;
+import static seedu.address.model.tag.ApplicationStatusTagType.REJECTED;
+
+import java.util.Comparator;
+import java.util.Optional;
+
+import seedu.address.model.application.Application;
+import seedu.address.model.tag.Tag;
+
+public class ApplicationStatusComparator implements Comparator {
+
+ public static final String COMMAND_WORD = "status";
+
+ @Override
+ public int compare(Application o1, Application o2) {
+ return getStatusRanking(o1.getApplicationStatusTag()) - getStatusRanking(o2.getApplicationStatusTag());
+ }
+
+ /**
+ * Compares the two application's status tag field. Returns a negative integer, zero, or a positive integer as
+ * the first argument is less than, equal to, or greater than the second base on alphanumeric order.
+ * The default order from ascending to descend is as follows ACCEPTED, REJECTED, INTERVIEWED, APPLIE and
+ * NOT_APPLIED.
+ * An empty tag will be considered as the lowest ranking, ranked below NOT_APPLIED.
+ * */
+ private int getStatusRanking(Optional t) {
+ if (t.isEmpty()) {
+ return 6;
+ } else if (t.get().toString().equals(NOT_APPLIED.toString())) {
+ return 5;
+ } else if (t.get().toString().equals(APPLIED.toString())) {
+ return 4;
+ } else if (t.get().toString().equals(INTERVIEWED.toString())) {
+ return 3;
+ } else if (t.get().toString().equals(REJECTED.toString())) {
+ return 2;
+ } else if (t.get().toString().equals(ACCEPTED.toString())) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return COMMAND_WORD;
+ }
+}
diff --git a/src/main/java/seedu/address/logic/sort/InterviewSlotComparator.java b/src/main/java/seedu/address/logic/sort/InterviewSlotComparator.java
new file mode 100644
index 00000000000..97e355b3f75
--- /dev/null
+++ b/src/main/java/seedu/address/logic/sort/InterviewSlotComparator.java
@@ -0,0 +1,24 @@
+package seedu.address.logic.sort;
+
+import java.util.Comparator;
+
+import seedu.address.model.application.Application;
+
+public class InterviewSlotComparator implements Comparator {
+
+ public static final String COMMAND_WORD = "interview";
+
+ /**
+ * Compares the two application's interview slot field. Returns a negative integer, zero, or a positive integer as
+ * the first argument is less than, equal to, or greater than the second base on alphanumeric order.
+ * */
+ @Override
+ public int compare(Application o1, Application o2) {
+ return o1.getInterviewSlot().getValue().compareTo(o2.getInterviewSlot().getValue());
+ }
+
+ @Override
+ public String toString() {
+ return COMMAND_WORD;
+ }
+}
diff --git a/src/main/java/seedu/address/logic/sort/NameComparator.java b/src/main/java/seedu/address/logic/sort/NameComparator.java
new file mode 100644
index 00000000000..4125e7bda2f
--- /dev/null
+++ b/src/main/java/seedu/address/logic/sort/NameComparator.java
@@ -0,0 +1,24 @@
+package seedu.address.logic.sort;
+
+import java.util.Comparator;
+
+import seedu.address.model.application.Application;
+
+public class NameComparator implements Comparator {
+
+ public static final String COMMAND_WORD = "name";
+
+ /**
+ * Compares the two application's name field. Returns a negative integer, zero, or a positive integer as
+ * the first argument is less than, equal to, or greater than the second base on alphanumeric order.
+ * */
+ @Override
+ public int compare(Application o1, Application o2) {
+ return o1.getName().toString().compareTo(o2.getName().toString());
+ }
+
+ @Override
+ public String toString() {
+ return COMMAND_WORD;
+ }
+}
diff --git a/src/main/java/seedu/address/logic/sort/PriorityComparator.java b/src/main/java/seedu/address/logic/sort/PriorityComparator.java
new file mode 100644
index 00000000000..d8f4c59d0a9
--- /dev/null
+++ b/src/main/java/seedu/address/logic/sort/PriorityComparator.java
@@ -0,0 +1,53 @@
+package seedu.address.logic.sort;
+
+import java.util.Comparator;
+import java.util.Optional;
+
+import seedu.address.model.application.Application;
+import seedu.address.model.tag.PriorityTagType;
+import seedu.address.model.tag.Tag;
+
+public class PriorityComparator implements Comparator {
+
+ public static final String COMMAND_WORD = "priority";
+
+ private static final String PRIORITY_HIGH = "[" + PriorityTagType.HIGH + "]";
+ private static final String PRIORITY_LOW = "[" + PriorityTagType.LOW + "]";
+
+ /**
+ * Compares the two application's priority field. Returns a negative integer, zero, or a positive integer as
+ * the first argument is less than, equal to, or greater than the second base on alphanumeric order.
+ * The default order from ascending to descend is as follows HIGH, MEDIUM, LOW.
+ * An empty tag will be considered as the lowest ranking, ranked below LOW.
+ * */
+ @Override
+ public int compare(Application o1, Application o2) {
+ Optional p1 = o1.getPriorityTag();
+ Optional p2 = o2.getPriorityTag();
+
+ if (p1.isPresent() && p2.isEmpty()) {
+ return 1;
+ } else if (p1.isEmpty() && p2.isPresent()) {
+ return -1;
+ } else if (p1.isEmpty()) {
+ return o1.getName().toString().compareTo(o2.getName().toString());
+ } else {
+ if (p1.get().toString().equals(p2.get().toString())) {
+ return o1.getName().toString().compareTo(o2.getName().toString());
+ } else if (p1.get().toString().equals(PRIORITY_HIGH)) {
+ return 1;
+ } else if (p2.get().toString().equals(PRIORITY_HIGH)) {
+ return -1;
+ } else if (p2.get().toString().equals(PRIORITY_LOW)) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return COMMAND_WORD;
+ }
+}
diff --git a/src/main/java/seedu/address/model/InternApplyMemory.java b/src/main/java/seedu/address/model/InternApplyMemory.java
index 5be05041cf0..17dac04e2a0 100644
--- a/src/main/java/seedu/address/model/InternApplyMemory.java
+++ b/src/main/java/seedu/address/model/InternApplyMemory.java
@@ -2,6 +2,7 @@
import static java.util.Objects.requireNonNull;
+import java.util.Comparator;
import java.util.List;
import javafx.collections.ObservableList;
@@ -38,6 +39,14 @@ public InternApplyMemory(ReadOnlyInternApplyMemory toBeCopied) {
}
//// list overwrite operations
+ /**
+ * Replaces the order of the application list with {@code c} and order by {@code orderBy}.
+ * */
+ public void sortApplications(Comparator c, String orderBy) {
+ requireNonNull(c);
+ requireNonNull(orderBy);
+ this.applications.sort(c, orderBy);
+ }
/**
* Replaces the contents of the application list with {@code applications}.
diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java
index 7aaf40c77e6..253eddeb082 100644
--- a/src/main/java/seedu/address/model/Model.java
+++ b/src/main/java/seedu/address/model/Model.java
@@ -1,6 +1,7 @@
package seedu.address.model;
import java.nio.file.Path;
+import java.util.Comparator;
import java.util.function.Predicate;
import javafx.collections.ObservableList;
@@ -18,9 +19,7 @@ public interface Model {
/** {@code Predicate} that returns true if the application's interview slot falls with a week of the local date on
* the local machine.
*/
- Predicate PREDICATE_SHOW_UPCOMING_APPLICATIONS_ONLY = application -> {
- return application.isUpcomingInterview();
- };
+ Predicate PREDICATE_SHOW_UPCOMING_APPLICATIONS_ONLY = Application::isUpcomingInterview;
/**
* Replaces user prefs data with the data in {@code userPrefs}.
@@ -94,7 +93,9 @@ public interface Model {
*/
void updateFilteredApplicationList(Predicate predicate);
- /** Returns an unmodifiable view of the upcoming application list */
+
+ /** Returns an unmodifiable view of the upcoming application list
+ */
ObservableList getUpcomingApplicationList();
/**
@@ -102,6 +103,8 @@ public interface Model {
*/
void updateUpcomingApplicationList(Predicate predicate);
+ void sortApplications(Comparator c, String orderBy);
+
/** Returns a modifiable view of the list of summary boxes */
ObservableList getSummaryBoxList();
diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java
index 8daddfb8662..63eca60f9bd 100644
--- a/src/main/java/seedu/address/model/ModelManager.java
+++ b/src/main/java/seedu/address/model/ModelManager.java
@@ -4,6 +4,7 @@
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
import java.nio.file.Path;
+import java.util.Comparator;
import java.util.function.Predicate;
import java.util.logging.Logger;
@@ -115,10 +116,17 @@ public void addApplication(Application application) {
@Override
public void setApplication(Application target, Application editedApplication) {
requireAllNonNull(target, editedApplication);
-
internApplyMemory.setApplication(target, editedApplication);
}
+ //=========== Sorting Application List Accessors ========================================================
+ @Override
+ public void sortApplications(Comparator c, String orderBy) {
+ requireNonNull(c);
+ requireNonNull(orderBy);
+ internApplyMemory.sortApplications(c, orderBy);
+ }
+
//=========== Filtered Application List Accessors ========================================================
/**
diff --git a/src/main/java/seedu/address/model/application/Application.java b/src/main/java/seedu/address/model/application/Application.java
index 64924f8b43b..46c1ba3032d 100644
--- a/src/main/java/seedu/address/model/application/Application.java
+++ b/src/main/java/seedu/address/model/application/Application.java
@@ -5,9 +5,11 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import seedu.address.model.tag.Tag;
+import seedu.address.model.tag.TagType;
/**
* Represents an Application in InternApply.
@@ -79,6 +81,24 @@ public Details getDetails() {
return details;
}
+ public Optional getPriorityTag() {
+ for (Tag tag: tags) {
+ if (tag.tagType.equals(TagType.PRIORITY)) {
+ return Optional.of(tag);
+ }
+ }
+ return Optional.empty();
+ }
+
+ public Optional getApplicationStatusTag() {
+ for (Tag tag: tags) {
+ if (tag.tagType.equals(TagType.APPLICATION_STATUS)) {
+ return Optional.of(tag);
+ }
+ }
+ return Optional.empty();
+ }
+
/**
* Returns an immutable tag set, which throws {@code UnsupportedOperationException}
* if modification is attempted.
diff --git a/src/main/java/seedu/address/model/application/InterviewSlot.java b/src/main/java/seedu/address/model/application/InterviewSlot.java
index f327e910c78..61a007ae667 100644
--- a/src/main/java/seedu/address/model/application/InterviewSlot.java
+++ b/src/main/java/seedu/address/model/application/InterviewSlot.java
@@ -61,6 +61,10 @@ public static boolean isNotSet(String test) {
.ofPattern(InterviewSlot.FORMAT_DATETIME_INPUT)));
}
+ public LocalDateTime getValue() {
+ return this.value;
+ }
+
/**
* Returns true if the interview slot is within a week of the current local date of the local machine.
*/
diff --git a/src/main/java/seedu/address/model/application/UniqueApplicationList.java b/src/main/java/seedu/address/model/application/UniqueApplicationList.java
index 9d48f61bd2e..4197140382d 100644
--- a/src/main/java/seedu/address/model/application/UniqueApplicationList.java
+++ b/src/main/java/seedu/address/model/application/UniqueApplicationList.java
@@ -3,11 +3,14 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import seedu.address.logic.commands.ListCommand;
import seedu.address.model.application.exceptions.ApplicationNotFoundException;
import seedu.address.model.application.exceptions.DuplicateApplicationException;
@@ -28,6 +31,18 @@ public class UniqueApplicationList implements Iterable {
private final ObservableList internalList = FXCollections.observableArrayList();
private final ObservableList internalUnmodifiableList =
FXCollections.unmodifiableObservableList(internalList);
+ /**
+ * Sort the application list according to the given sorting argument.
+ * */
+ public void sort(Comparator c, String orderBy) {
+ requireNonNull(c);
+ requireNonNull(orderBy);
+ if (orderBy.equals(ListCommand.COMMAND_ORDER_WORD_ASCENDING)) {
+ internalList.sort(c);
+ } else {
+ internalList.sort(Collections.reverseOrder(c));
+ }
+ }
/**
* Returns true if the list contains an equivalent application as the given argument.
diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java
index 25c55be2e35..4a32efa2abe 100644
--- a/src/main/java/seedu/address/model/util/SampleDataUtil.java
+++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java
@@ -1,5 +1,7 @@
package seedu.address.model.util;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
@@ -21,25 +23,58 @@
*/
public class SampleDataUtil {
public static Application[] getSampleApplications() {
+ LocalDateTime today = LocalDateTime.now();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
return new Application[] {
-
- new Application(new Name("Shopee"), new JobTitle("Software Engineer Intern"), new Phone("87438807"),
- new Email("hr@shopee.sg"), new Address("5 Science Park Dr, #06-40"), new InterviewSlot(),
- new Details(), getTagSet("singapore", "HIGH", "INTERVIEWED")),
- new Application(new Name("Grab Holdings Singapore"), new JobTitle("AI Engineer"), new Phone("99272758"),
- new Email("hr@grab.sg"), new Address("3 Media Cl, #07-18"), new InterviewSlot(),
- new Details(), getTagSet("colleagues", "friends", "MEDIUM", "APPLIED")),
- new Application(new Name("Microsoft"), new JobTitle("Software Engineer Intern"), new Phone("93210283"),
- new Email("hr@microsoft.com"), new Address("182 Cecil St, #13-01"), new InterviewSlot(),
- new Details(), getTagSet("overseas", "LOW", "NOT_APPLIED")),
- new Application(new Name("Aftershock PC"), new JobTitle("Data Scientist"), new Phone("63458727"),
- new Email("corpsales@sg.aftershockpc.com"), new Address("994, Bendemeer Rd, #05-07"),
- new InterviewSlot("17-04-2022 12:00"),
- new Details(), getTagSet("passion", "HIGH", "APPLIED")),
- new Application(new Name("Google Asia Pacific"), new JobTitle("ML Engineer"), new Phone("91031282"),
- new Email("hr@google.com"), new Address("70 Pasir Panjang Rd, #16-43"),
- new InterviewSlot("28-03-2022 13:00"),
- new Details(), getTagSet("family", "LOW", "REJECTED")),
+ new Application(new Name("Shopee"),
+ new JobTitle("Software Engineer Intern"),
+ new Phone("87438807"),
+ new Email("hr@shopee.sg"),
+ new Address("5 Science Park Dr, #06-40"),
+ new InterviewSlot(today.minusDays(7).format(formatter)),
+ new Details("Applied 2 weeks ago, waiting for a response.\n"
+ + "OMG! They replied! Will be interviewed this week!\n"
+ + "Preparing for the interview with Alice and Bob.\n"
+ + "Interview done, waiting for response...\n"
+ + "I GOT IN~"),
+ getTagSet("BasedInSingapore", "HIGH", "ACCEPTED")),
+ new Application(new Name("Grab Holdings Singapore"),
+ new JobTitle("AI Engineer"),
+ new Phone("99272758"),
+ new Email("hr@grab.sg"),
+ new Address("3 Media Cl, #07-18"),
+ new InterviewSlot(today.plusDays(1).format(formatter)),
+ new Details("Alice and Bob was interested in this company so they asked me to join in."
+ + " Hopefully all goes well and I get accepted (The interview was really tough)..."),
+ getTagSet("WithFriends", "MEDIUM", "INTERVIEWED")),
+ new Application(new Name("Microsoft"),
+ new JobTitle("Software Engineer Intern"),
+ new Phone("93210283"),
+ new Email("hr@microsoft.com"),
+ new Address("182 Cecil St, #13-01"),
+ new InterviewSlot(today.plusDays(7).format(formatter)),
+ new Details("Microsoft interview preparations:\n"
+ + "1. Work on LeetCode\n"
+ + "2. Look for tips on the internet\n"
+ + "3. Make sure to dress smartly for the interview\n"
+ + "4. Do your best!"),
+ getTagSet("DreamJob", "HIGH", "APPLIED")),
+ new Application(new Name("Aftershock PC"),
+ new JobTitle("Data Scientist"),
+ new Phone("63458727"),
+ new Email("corpsales@sg.aftershockpc.com"),
+ new Address("994, Bendemeer Rd, #05-07"),
+ new InterviewSlot(today.plusDays(8).format(formatter)),
+ new Details(),
+ getTagSet("PassionForPCBuilding", "PossibleOption", "MEDIUM", "NOT_APPLIED")),
+ new Application(new Name("Google Asia Pacific"),
+ new JobTitle("ML Engineer"),
+ new Phone("91031282"),
+ new Email("hr@google.com"),
+ new Address("70 Pasir Panjang Rd, #16-43"),
+ new InterviewSlot(),
+ new Details(),
+ getTagSet("HotJob", "LOW", "REJECTED")),
};
}
diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java
index 7701a605598..96ee2ad4bf1 100644
--- a/src/test/java/seedu/address/logic/LogicManagerTest.java
+++ b/src/test/java/seedu/address/logic/LogicManagerTest.java
@@ -8,6 +8,7 @@
import static seedu.address.logic.commands.CommandTestUtil.JOBTITLE_DESC_SHOPEE;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_SHOPEE;
import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_SHOPEE;
+import static seedu.address.logic.commands.ListCommand.MESSAGE_NO_CHANGE_FULL;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalApplications.SHOPEE;
@@ -66,7 +67,7 @@ public void execute_commandExecutionError_throwsCommandException() {
@Test
public void execute_validCommand_success() throws Exception {
String listCommand = ListCommand.COMMAND_WORD;
- assertCommandSuccess(listCommand, ListCommand.MESSAGE_SUCCESS, model);
+ assertCommandSuccess(listCommand, MESSAGE_NO_CHANGE_FULL, model);
}
@Test
diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java
index 35639e832d0..a1a778ce12a 100644
--- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java
@@ -9,6 +9,7 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Comparator;
import java.util.function.Predicate;
import org.junit.jupiter.api.Test;
@@ -160,6 +161,11 @@ public void updateUpcomingApplicationList(Predicate predicate) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public void sortApplications(Comparator c, String orderBy) {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public ObservableList getSummaryBoxList() {
throw new AssertionError("This method should not be called.");
diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java
index 98f4a779970..adefa56bbb3 100644
--- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java
+++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java
@@ -91,7 +91,7 @@ public static void assertCommandSuccess(Command command, Model actualModel, Comm
Model expectedModel) {
try {
CommandResult result = command.execute(actualModel);
- assertEquals(expectedCommandResult, result);
+ assertEquals(expectedCommandResult.toString(), result.toString());
assertEquals(expectedModel, actualModel);
} catch (CommandException ce) {
throw new AssertionError("Execution of command should not fail.", ce);
diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java
index 59d82bf6757..af4411f7b2b 100644
--- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java
@@ -2,6 +2,7 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showApplicationAtIndex;
+import static seedu.address.logic.commands.ListCommand.MESSAGE_NO_CHANGE_FULL;
import static seedu.address.testutil.TypicalApplications.getTypicalInternApplyMemory;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_APPLICATION;
@@ -28,12 +29,14 @@ public void setUp() {
@Test
public void execute_listIsNotFiltered_showsSameList() {
- assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel);
+ assertCommandSuccess(new ListCommand(), model, MESSAGE_NO_CHANGE_FULL,
+ expectedModel);
}
@Test
public void execute_listIsFiltered_showsEverything() {
showApplicationAtIndex(model, INDEX_FIRST_APPLICATION);
- assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel);
+ assertCommandSuccess(new ListCommand(), model, MESSAGE_NO_CHANGE_FULL,
+ expectedModel);
}
}
diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java
index acbd9d2660d..967de7b3715 100644
--- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java
+++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java
@@ -115,6 +115,17 @@ public void parse_invalidValue_failure() {
Name.MESSAGE_CONSTRAINTS);
}
+ @Test
+ public void parse_resetTags_failure() {
+ Index targetIndex = INDEX_THIRD_APPLICATION;
+ String userInput = targetIndex.getOneBased() + TAG_EMPTY;
+
+ EditApplicationDescriptor descriptor = new EditApplicationDescriptorBuilder().withTags().build();
+ EditCommand expectedCommand = new EditCommand(targetIndex, descriptor);
+
+ assertParseFailure(parser, userInput, Tag.MESSAGE_CONSTRAINTS);
+ }
+
@Test
public void parse_allFieldsSpecified_success() {
Index targetIndex = INDEX_SECOND_APPLICATION;
@@ -218,15 +229,4 @@ public void parse_invalidValueFollowedByValidValue_success() {
expectedCommand = new EditCommand(targetIndex, descriptor);
assertParseSuccess(parser, userInput, expectedCommand);
}
-
- @Test
- public void parse_resetTags_success() {
- Index targetIndex = INDEX_THIRD_APPLICATION;
- String userInput = targetIndex.getOneBased() + TAG_EMPTY;
-
- EditApplicationDescriptor descriptor = new EditApplicationDescriptorBuilder().withTags().build();
- EditCommand expectedCommand = new EditCommand(targetIndex, descriptor);
-
- assertParseSuccess(parser, userInput, expectedCommand);
- }
}
diff --git a/src/test/java/seedu/address/logic/parser/InternApplyParserTest.java b/src/test/java/seedu/address/logic/parser/InternApplyParserTest.java
index e630402df6f..6fb7963ddc7 100644
--- a/src/test/java/seedu/address/logic/parser/InternApplyParserTest.java
+++ b/src/test/java/seedu/address/logic/parser/InternApplyParserTest.java
@@ -23,6 +23,7 @@
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.parser.exceptions.ParseException;
+import seedu.address.logic.sort.NameComparator;
import seedu.address.model.application.Application;
import seedu.address.model.application.NameContainsKeywordsPredicate;
import seedu.address.testutil.ApplicationBuilder;
@@ -88,7 +89,8 @@ public void parseCommand_help() throws Exception {
@Test
public void parseCommand_list() throws Exception {
assertTrue(parser.parseCommand(ListCommand.COMMAND_WORD) instanceof ListCommand);
- assertTrue(parser.parseCommand(ListCommand.COMMAND_WORD + " 3") instanceof ListCommand);
+ assertTrue(parser.parseCommand(ListCommand.COMMAND_WORD + " " + NameComparator.COMMAND_WORD + " "
+ + ListCommand.COMMAND_ORDER_WORD_ASCENDING + " 1") instanceof ListCommand);
}
@Test