From 21c809b6e79c4255141912f71fbcdd9490ef5153 Mon Sep 17 00:00:00 2001 From: peppapighs Date: Sat, 22 Oct 2022 22:18:01 +0800 Subject: [PATCH] Fix: use relative person index when adding task --- src/main/java/swift/logic/commands/AddTaskCommand.java | 2 +- .../java/swift/logic/commands/AddTaskCommandTest.java | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/swift/logic/commands/AddTaskCommand.java b/src/main/java/swift/logic/commands/AddTaskCommand.java index f3b54385d28..6020047eb10 100644 --- a/src/main/java/swift/logic/commands/AddTaskCommand.java +++ b/src/main/java/swift/logic/commands/AddTaskCommand.java @@ -54,7 +54,7 @@ public CommandResult execute(Model model) throws CommandException { } model.addTask(toAdd); for (Index index : contactIndices) { - model.addBridge(model.getAddressBook().getPersonList().get(index.getZeroBased()), toAdd); + model.addBridge(model.getFilteredPersonList().get(index.getZeroBased()), toAdd); } return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); diff --git a/src/test/java/swift/logic/commands/AddTaskCommandTest.java b/src/test/java/swift/logic/commands/AddTaskCommandTest.java index 477477076d4..dc11d22b29c 100644 --- a/src/test/java/swift/logic/commands/AddTaskCommandTest.java +++ b/src/test/java/swift/logic/commands/AddTaskCommandTest.java @@ -15,11 +15,11 @@ import org.junit.jupiter.api.Test; +import javafx.collections.FXCollections; import javafx.collections.ObservableList; import swift.commons.core.GuiSettings; import swift.commons.core.index.Index; import swift.logic.commands.exceptions.CommandException; -import swift.model.AddressBook; import swift.model.Model; import swift.model.ReadOnlyAddressBook; import swift.model.ReadOnlyUserPrefs; @@ -250,11 +250,8 @@ public void addBridge(Person person, Task task) { } @Override - public ReadOnlyAddressBook getAddressBook() { - AddressBook ab = new AddressBook(); - ab.addPerson(new PersonBuilder().build()); - return ab; + public ObservableList getFilteredPersonList() { + return FXCollections.observableArrayList(new PersonBuilder().build()); } } - }