fixed failing tests

This commit is contained in:
Elias Csomor 2022-11-21 10:27:31 +01:00
parent 3c70c8ac48
commit 62fb3869e6
2 changed files with 8 additions and 6 deletions

View File

@ -87,10 +87,11 @@ public class JsonTaskList implements TaskList {
loadTaskListFromFile();
}
for (Task task :
taskMap.values()) {
List<Task> temptasks = taskMap.values().stream().
filter(task -> { return task.getCropId() == cropId;}).toList();
for (Task task : temptasks ) {
if (task.getCropId() == cropId) {
taskMap.remove(task);
taskMap.remove(task.getId());
}
}
writeTaskListToFile();
@ -113,6 +114,7 @@ public class JsonTaskList implements TaskList {
if(task.getId() == 0) {
task.withId(idProvider.incrementAndGet());
}
taskMap.put(task.getId(),task);
writeTaskListToFile();
}

View File

@ -50,13 +50,13 @@ public class JsonTaskListTest {
@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);
}