forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/AY2324S1-CS2103-F13-2/tp …
…into add-leave
- Loading branch information
Showing
9 changed files
with
139 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
[![CI Status](https://github.com/se-edu/addressbook-level3/workflows/Java%20CI/badge.svg)](https://github.com/se-edu/addressbook-level3/actions) | ||
[![CI Status](https://github.com/se-edu/addressbook-level3/workflows/Java%20CI/badge.svg)](https://github.com/AY2324S1-CS2103-F13-2/tp/actions) | ||
|
||
![Ui](docs/images/Ui.png) | ||
|
||
* This is **a sample project for Software Engineering (SE) students**.<br> | ||
* This is **a project that utilises CLI to aid HR admins with their administrative tasks.**.<br> | ||
Example usages: | ||
* as a starting point of a course project (as opposed to writing everything from scratch) | ||
* as a case study | ||
* The project is constructed based an ongoing software project (called _AddressBook3_) for a desktop application (called _HR Insight_) used for managing employee details. | ||
* As a HR admin, I can perform basic CRUD operations (Add/Delete/List) for all the employees in my organisation. | ||
* As a HR admin, I can list all the employees in the organisation. | ||
* As a HR admin, I can better forecast manpower issues by tracking which months have the highest number of leaves. | ||
* As a HR admin, I can better plan birthday celebrations by tracking which employees have birthdays for that particular month. | ||
* As a HR admin, I can process employee's claims efficiently and accurately. | ||
|
||
* The project is constructed based an ongoing software project (called _HR Insight_), a desktop application used for managing employee details. | ||
* It is **written in OOP fashion**. It provides a **reasonably well-written** code base **bigger** (around 6 KLoC) than what students usually write in beginner-level SE modules, without being overwhelmingly big. | ||
* It comes with a **reasonable level of user and developer documentation**. | ||
* It is named `AddressBook Level 3` (`AB3` for short) because it was initially created as a part of a series of `AddressBook` projects (`Level 1`, `Level 2`, `Level 3` ...). | ||
* For the detailed documentation of this project, see the **[Address Book Product Website](https://se-education.org/addressbook-level3)**. | ||
* This project is a **part of the se-education.org** initiative. If you would like to contribute code to this project, see [se-education.org](https://se-education.org#https://se-education.org/#contributing) for more info. | ||
|
||
* It is named `HR Insight` because it provides HR employees an extensive insight into an organisation. | ||
* For the detailed documentation of this project, see the **[HR Insight Product Website](https://ay2324s1-cs2103-f13-2.github.io/tp/)**. | ||
* This project is a **part of the CS2103** course structure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/seedu/address/logic/parser/ListCommandParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEPARTMENT; | ||
|
||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.ListCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.person.Department; | ||
import seedu.address.model.person.MatchingDepartmentPredicate; | ||
|
||
|
||
/** | ||
* Parses input arguments and creates a new ListCommand object | ||
*/ | ||
public class ListCommandParser implements Parser<ListCommand> { | ||
|
||
/** | ||
* Parses {@code userInput} into a command and returns it. | ||
* | ||
* @param args arguments | ||
* @throws ParseException if {@code userInput} does not conform the expected format | ||
*/ | ||
@Override | ||
public ListCommand parse(String args) throws ParseException { | ||
requireNonNull(args); | ||
ArgumentMultimap argMultimap = | ||
ArgumentTokenizer.tokenize(args, PREFIX_DEPARTMENT); | ||
if (argMultimap.getValue(PREFIX_DEPARTMENT).isEmpty()) { | ||
return new ListCommand(); | ||
} | ||
try { | ||
Department filteringDepartment = new Department(argMultimap.getValue(PREFIX_DEPARTMENT).get()); | ||
return new ListCommand(new MatchingDepartmentPredicate(filteringDepartment)); | ||
} catch (IllegalArgumentException e) { | ||
throw new ParseException(Messages.MESSAGE_EMPTY_DEPARTMENT_FILTER); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/seedu/address/model/person/MatchingDepartmentPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package seedu.address.model.person; | ||
|
||
import java.util.function.Predicate; | ||
|
||
/** | ||
* Tests that a {@code Person}'s {@code Department} matches the department name given. | ||
*/ | ||
public class MatchingDepartmentPredicate implements Predicate<Person> { | ||
|
||
private final Department department; | ||
|
||
public MatchingDepartmentPredicate(Department department) { | ||
this.department = department; | ||
} | ||
|
||
/** | ||
* Evaluates this predicate on the given argument. | ||
* | ||
* @param person the input argument | ||
* @return {@code true} if the input argument matches the predicate, otherwise {@code false} | ||
*/ | ||
@Override | ||
public boolean test(Person person) { | ||
return this.department.equals(person.getDepartment()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 19 additions & 5 deletions
24
src/test/java/seedu/address/logic/commands/ListCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,53 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.commands.CommandTestUtil.VALID_DEPARTMENT; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.Messages; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.person.Department; | ||
import seedu.address.model.person.MatchingDepartmentPredicate; | ||
import seedu.address.model.person.Person; | ||
|
||
|
||
|
||
/** | ||
* Contains integration tests (interaction with the Model) and unit tests for ListCommand. | ||
*/ | ||
public class ListCommandTest { | ||
|
||
private static final Predicate<Person> FILTER_TEST_PREDICATE = | ||
new MatchingDepartmentPredicate(new Department(VALID_DEPARTMENT)); | ||
private Model model; | ||
private Model expectedModel; | ||
private Model expectedFilteredModel; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); | ||
expectedFilteredModel = new ModelManager(model.getAddressBook(), new UserPrefs()); | ||
expectedFilteredModel.updateFilteredPersonList(FILTER_TEST_PREDICATE); | ||
} | ||
|
||
@Test | ||
public void execute_listIsNotFiltered_showsSameList() { | ||
assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); | ||
assertCommandSuccess(new ListCommand(), model, String.format( | ||
Messages.MESSAGE_LIST_SUCCESS, expectedModel.getFilteredPersonList().size()), expectedModel); | ||
} | ||
|
||
@Test | ||
public void execute_listIsFiltered_showsEverything() { | ||
showPersonAtIndex(model, INDEX_FIRST_PERSON); | ||
assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); | ||
assertCommandSuccess(new ListCommand(FILTER_TEST_PREDICATE), model, String.format( | ||
Messages.MESSAGE_FILTER_SUCCESS, expectedFilteredModel.getFilteredPersonList().size()), | ||
expectedFilteredModel); | ||
} | ||
} |