forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from freshcabbage123/alan-listTask
feat: Implement listTask command
- Loading branch information
Showing
6 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/seedu/address/logic/commands/ListTaskCommand.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,23 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_TASKS; | ||
|
||
import seedu.address.model.Model; | ||
|
||
/** | ||
* Lists all tasks in CoordiMate to the user. | ||
*/ | ||
public class ListTaskCommand extends Command { | ||
public static final String COMMAND_WORD = "listTask"; | ||
|
||
public static final String MESSAGE_SUCCESS = "Listed all tasks"; | ||
|
||
|
||
@Override | ||
public CommandResult execute(Model model) { | ||
requireNonNull(model); | ||
model.updateFilteredTaskList(PREDICATE_SHOW_ALL_TASKS); | ||
return new CommandResult(MESSAGE_SUCCESS); | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
src/test/java/seedu/address/logic/commands/ListTaskCommandTest.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,35 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.logic.commands.CommandTestUtil.showTaskAtIndex; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST; | ||
import static seedu.address.testutil.TypicalTasks.getTypicalAddressBook; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
|
||
public class ListTaskCommandTest { | ||
private Model model; | ||
private Model expectedModel; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); | ||
} | ||
|
||
@Test | ||
public void execute_listIsNotFiltered_showsSameList() { | ||
assertCommandSuccess(new ListTaskCommand(), model, ListTaskCommand.MESSAGE_SUCCESS, expectedModel); | ||
} | ||
|
||
@Test | ||
public void execute_listIsFiltered_showsEverything() { | ||
showTaskAtIndex(model, INDEX_FIRST); | ||
assertCommandSuccess(new ListTaskCommand(), model, ListTaskCommand.MESSAGE_SUCCESS, expectedModel); | ||
} | ||
} |
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