fixed RemoveTasksForCrop

This commit is contained in:
Elias Csomor 2022-11-26 11:22:27 +01:00
parent c79386ec88
commit 77541c282c
2 changed files with 7 additions and 8 deletions

View File

@ -88,7 +88,8 @@ public class JsonTaskList implements TaskList {
if(taskMap.isEmpty()) {
loadTaskListFromFile();
}
taskMap.values().removeIf(task -> task.getCropId() == cropId);
taskMap.entrySet().removeIf(entry -> entry.getValue().getCropId() == cropId);
writeTaskListToFile();
notifySubscribers();
}

View File

@ -47,17 +47,16 @@ public class JsonTaskListTest {
}
@Disabled("disabled until adding works.")
@Test
@DisplayName("Add task.")
void addTask() {
Task task = new Task("Testtask", "This is a test Task.", LocalDate.parse("01.05.2022", formatter), 1);
Task task = new Task("Testtask", "This is a test Task.", LocalDate.parse("2022-05-01", formatter), 1);
try {
testDatabase.saveTask(task);
List<Task> taskList;
try {
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
LocalDate.parse("31.05.2022", formatter));
taskList = testDatabase.getTaskList(LocalDate.parse("2022-04-30", formatter),
LocalDate.parse("2022-05-31", formatter));
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -72,8 +71,7 @@ public class JsonTaskListTest {
@Test
@DisplayName("Remove task.")
void removeTask() {
Task task = new Task("Dummy", "Dummy", LocalDate.parse("2022-05-31", formatter), 1)
.withId(2);
Task task = new Task("Dummy", "Dummy", LocalDate.parse("2022-05-31", formatter), 1).withId(2);
try {
testDatabase.removeTask(task);
List<Task> taskList;
@ -102,7 +100,7 @@ public class JsonTaskListTest {
}
@Disabled("Disabled until removing works")
@Test
void removeTasksForCrop() {
List<Task> taskList;