Skip to content

Commit

Permalink
Merge pull request AY2425S1-CS2103T-F15-2#122 from jessica2828/delete…
Browse files Browse the repository at this point in the history
…-command-tests

Update DeleteCommand tests
  • Loading branch information
JYL27 authored Nov 7, 2024
2 parents d5c2440 + 2545e34 commit ac3a8b2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 40 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@

# EduContacts

**EduContacts** is a desktop application designed for **tertiary teachers and educators** to manage contacts with
**EduContacts** is a desktop application designed for **tertiary teachers and educators** to manage contacts with
students, parents, and faculty across multiple classes or educational years.

- It is optimized for those who prefer to work with a **Command Line Interface** (CLI) while still having the
- It is optimized for those who prefer to work with a **Command Line Interface** (CLI) while still having the
- benefits of a **Graphical User Interface** (GUI).
- It helps educators keep communication organized, track academic progress, and support parent-teacher interactions
- It helps educators keep communication organized, track academic progress, and support parent-teacher interactions
- efficiently, often across large groups.

## Value Proposition

An address book tailored for educators simplifies student and parent contact management, enhances communication
An address book tailored for educators simplifies student and parent contact management, enhances communication
tracking, and integrates progress reports, helping teachers save time and foster effective collaboration across the school community.

## Features

- **Class/Group-Based Contact Management**: Organize contacts by class, subject, or school year for easy access.
- **Parent-Teacher Communication Tracking**: Keep a history of messages or meetings with parents and faculty.
- **Student Progress and Grade Tracking**: Link contact information with student records and academic performance.
- **Event Scheduling and Reminders**: Integrate with school calendars to manage parent-teacher meetings,
- **Event Scheduling and Reminders**: Integrate with school calendars to manage parent-teacher meetings,
report deadlines, or school events.
- **Group Messaging**: Enable teachers to send messages to an entire class or group of parents at once,
- **Group Messaging**: Enable teachers to send messages to an entire class or group of parents at once,
streamlining communication.
- **Custom Fields**: Add notes for individual students (e.g., learning accommodations,
- **Custom Fields**: Add notes for individual students (e.g., learning accommodations,
behavioral issues, or special needs).
- **Integration with School Management Systems**: Sync with platforms like Google Classroom or
- **Integration with School Management Systems**: Sync with platforms like Google Classroom or
school LMS (Learning Management Systems).

## Getting Started
Expand Down
31 changes: 15 additions & 16 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ All these, including the `MainWindow`, inherit from the abstract `UiPart` class
classes that represent parts of the visible GUI.

The `UI` component uses the JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that
are in the `src/main/resources/view` folder. For example, the layout of the
[`MainWindow`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/ui/MainWindow.java)
are in the `src/main/resources/view` folder. For example, the layout of the
[`MainWindow`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/ui/MainWindow.java)
is specified in [`MainWindow.fxml`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/resources/view/MainWindow.fxml)

**The `UI` component,**
Expand All @@ -107,7 +107,7 @@ is specified in [`MainWindow.fxml`](https://github.com/se-edu/addressbook-level3
* listens for changes to `Model` data so that the UI can be updated with the modified data.
* keeps a reference to the `Logic` component, because the `UI` relies on the `Logic` to execute commands.
* depends on some classes in the `Model` component, as it displays `Person` object residing in the `Model`.

#### `CommandHistory` Integration

The `CommandHistory` class, located in `seedu.address.ui.util`, is responsible for tracking user-entered commands.
Expand Down Expand Up @@ -158,8 +158,8 @@ How the parsing works:
The `Model` component,

* stores the contact data i.e., all `Person` objects (which are contained in a `UniquePersonList` object).
* a `Person` object stores `StudentId`, `Name`, `Address`, `Phone`, `Email`, `Role`, `Course` objects.
* contains an ArrayList of `Module` objects which is optional.
* a `Person` object stores `StudentId`, `Name`, `Address`, `Phone`, `Email`, `Role`, `Course` objects.
* contains an ArrayList of `Module` objects which is optional.
* stores the currently 'selected' `Person` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList<Person>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* stores a `UserPref` object that represents the user’s preferences. This is exposed to the outside as a `ReadOnlyUserPref` objects.
* is intentionally designed to be independent of other components (e.g., UI, Logic, Storage) to maintain a clean separation of concerns. This ensures that the Model layer is solely responsible for managing data and that data structures make sense on their own. This independence enables easier maintenance, testing, and adaptability of the data structures, as changes in one component (e.g., UI) do not affect the Model.
Expand Down Expand Up @@ -562,7 +562,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
* 2b1. EduContacts overwrites the old grade with the new grade.

Use case ends.

**Use case: UC08 - Add contacts of next-of-kins of a student**

**MSS**
Expand Down Expand Up @@ -668,7 +668,7 @@ testers are expected to do more *exploratory* testing.

1. Download the jar file and copy into an empty folder.

2. Double-click the jar file.<br>
2. Double-click the jar file.<br>
Expected: Shows the GUI with a set of sample contacts. The window size may not be optimum.

2. Saving window preferences
Expand Down Expand Up @@ -698,17 +698,17 @@ testers are expected to do more *exploratory* testing.
2. Deleting a person while only one person is being shown

1. Prerequisites: Filter persons using the `filter` command until only one person remains. Multiple persons in the list. Person that remains has Student ID `12345678`. One person in the list has Student ID `11111111`

2. Test case: `delete 12345678`<br>
Expected: Person with Student ID `12345678` is deleted. Details of the deleted contact shown in the status message. Timestamp in the status bar is updated. List of persons shown is now blank.

3. Test case: `delete 11111111`<br>
Expected: No person is deleted. Error details shown in the status message. Status bar remains the same.

3. Deleting a person while no persons are in the list

1. Prerequisites: Delete all persons in the list using the `clear` command.

2. Test case: `delete 12345678`<br>
Expected: No person is deleted. Error details shown in the status message. Status bar remains the same.

Expand All @@ -719,7 +719,7 @@ testers are expected to do more *exploratory* testing.
1. Dealing with missing data files

1. To simulate a missing file, in the same folder as the jar file, navigate to the `data` folder and delete the `address.json` file in the folder.

2. Launch EduContacts by double-clicking the jar file.<br>
Expected: EduContacts is populated by a set of default list of persons. A new `address.json` file will be created in the `data` folder after closing the app or executing a command.

Expand All @@ -744,10 +744,10 @@ _{to work on in the future}_

* Description: Allow users to move inactive or irrelevant entries to an archive.
* Benefits:
* Reduces clutter in the main data set, making it easier to manage and navigate active records without losing historical data.
* Lower the load on real-time data processing by isolating inactive records.
* Retain archived data for historical records or compliance requirements.
* Provide a safe way to store inactive data without risking deletion or loss.
* Reduces clutter in the main data set, making it easier to manage and navigate active records without losing historical data.
* Lower the load on real-time data processing by isolating inactive records.
* Retain archived data for historical records or compliance requirements.
* Provide a safe way to store inactive data without risking deletion or loss.

### Importing contact data

Expand All @@ -767,4 +767,3 @@ _{to work on in the future}_
* Enable users to share their contact lists with others.
* Allow users to organize and manipulate their contact data externally.
* Help users comply with data export regulations or organizational policies.

30 changes: 15 additions & 15 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# EduContacts User Guide

<br>
<br>

EduContacts is a **desktop app for Educators in Tertiary Institution to manage contacts, 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, AB3 can get your contact management tasks done faster than traditional GUI apps. For educators who may be less experienced with command-based tools, EduContacts also includes user-friendly and intuitive features and guidance, making it accessible for all users.

Expand Down Expand Up @@ -58,7 +58,7 @@ EduContacts is a **desktop app for Educators in Tertiary Institution to manage c
```bash
cd ~/Desktop/EduContacts
```

and use the following command to run the application:

```bash
Expand All @@ -72,17 +72,17 @@ EduContacts is a **desktop app for Educators in Tertiary Institution to manage c
1. 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.<br>
Some example commands you can try:

```bash
list
```bash
list
```
Lists all contacts.

```bash
```bash
add 12345678 n/John Doe p/99999999 e/[email protected] a/123 Jane Doe Road c/Computer Science t/Student
```
```
Adds a contact named `John Doe` to EduContacts.
```bash

```bash
delete 12345678
```
Deletes a student contact with StudentID `12345678`.
Expand Down Expand Up @@ -131,7 +131,7 @@ EduContacts is a **desktop app for Educators in Tertiary Institution to manage c
Shows a message explaining how to access the help page.

Format:
```bash
```bash
help
```
![help message](images/helpMessage.png)
Expand All @@ -145,7 +145,7 @@ Alternatively, you can click the button on the top right hand corner as indicate

Adds a person contact to the EduContacts.

Format:
Format:
```bash
add ID n/NAME p/PHONE e/EMAIL a/ADDRESS c/COURSE r/ROLE
```
Expand All @@ -162,7 +162,7 @@ Examples:

Shows a list of all persons in EduContacts.

Format:
Format:
```bash
list
```
Expand Down Expand Up @@ -237,7 +237,7 @@ filter [KEYWORD_PREFIX] [MORE_KEYWORDS]
* **For filtering by Course:**

* Use prefix `c/`
* Partial matching is supported, but the first keyword must match the beginning of the course name.
* Partial matching is supported, but the first keyword must match the beginning of the course name.
e.g `Engineer` will match courses like "Engineering" but not "Civil Engineering".

<box type="tip" seamless>
Expand All @@ -247,7 +247,7 @@ filter [KEYWORD_PREFIX] [MORE_KEYWORDS]

Examples:
* ```filter n/John``` returns `john` and `John Doe`
* `filter m/CS2103T` returns a list of all students with module CS2103T.
* `filter m/CS2103T` returns a list of all students with module CS2103T.
* `filter c/Computer Science` returns a list of all students with course Computer Science.<br>
* `filter n/alex david` returns `Alex Yeoh`, `David Li`

Expand Down Expand Up @@ -283,7 +283,7 @@ Examples:

Deletes the specified person from EduContacts.

Format:
Format:
```bash
delete ID
```
Expand Down Expand Up @@ -313,7 +313,7 @@ Examples:

Clears all entries from EduContacts.

Format:
Format:
```bash
clear
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,36 @@ public void execute_invalidStudentIdWithModule_throwsCommandException() {
deleteCommand, model, String.format(DeleteCommand.MESSAGE_PERSON_NOT_FOUND, invalidStudentId));
}

@Test
public void execute_validStudentIdAndModule_success() {
Person personWithModule = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased());
StudentId studentIdToDelete = personWithModule.getStudentId();
Module moduleToDelete = personWithModule.getModules().get(0); // Assuming this person has at least one module

DeleteCommand deleteCommand = new DeleteCommand(studentIdToDelete, moduleToDelete);
String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_MODULE_SUCCESS, moduleToDelete);

ModelManager expectedModel = new ModelManager(model.getEduContacts(), new UserPrefs());
expectedModel.deleteModule(personWithModule, moduleToDelete);

assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel);
}

@Test
public void execute_validModuleDeletionAndCheckModuleList() {
Person personWithModules = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased());
StudentId studentIdToDelete = personWithModules.getStudentId();
Module moduleToDelete = personWithModules.getModules().get(0);

DeleteCommand deleteCommand = new DeleteCommand(studentIdToDelete, moduleToDelete);

String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_MODULE_SUCCESS, moduleToDelete);
assertCommandSuccess(deleteCommand, model, expectedMessage, model);

Person updatedPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased());
assertFalse(updatedPerson.getModules().contains(moduleToDelete)); // Check the updated person
}

@Test
public void execute_deleteModuleWhenPersonDisplayed_success() {
Person personToDisplay = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased());
Expand All @@ -202,6 +232,7 @@ public void execute_deleteModuleWhenPersonDisplayed_success() {

ModelManager expectedModel = new ModelManager(model.getEduContacts(), new UserPrefs(), personToDisplay);
expectedModel.deleteModule(updatedPerson, moduleToDelete);

assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel);
}

Expand Down Expand Up @@ -239,7 +270,6 @@ public void execute_deleteGradedModule_success() {
ModelManager expectedModel = new ModelManager(model.getEduContacts(), new UserPrefs());
expectedModel.deleteModule(personWithModule, moduleToDelete);


assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel);
}

Expand Down

0 comments on commit ac3a8b2

Please sign in to comment.