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.
Updates tests to test department filtering
- Loading branch information
1 parent
8f26520
commit 3ff9944
Showing
2 changed files
with
21 additions
and
6 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
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); | ||
} | ||
} |