fixed failing tests
This commit is contained in:
parent
3c70c8ac48
commit
62fb3869e6
|
@ -87,10 +87,11 @@ public class JsonTaskList implements TaskList {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Task task :
|
List<Task> temptasks = taskMap.values().stream().
|
||||||
taskMap.values()) {
|
filter(task -> { return task.getCropId() == cropId;}).toList();
|
||||||
|
for (Task task : temptasks ) {
|
||||||
if (task.getCropId() == cropId) {
|
if (task.getCropId() == cropId) {
|
||||||
taskMap.remove(task);
|
taskMap.remove(task.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeTaskListToFile();
|
writeTaskListToFile();
|
||||||
|
@ -113,6 +114,7 @@ public class JsonTaskList implements TaskList {
|
||||||
if(task.getId() == 0) {
|
if(task.getId() == 0) {
|
||||||
task.withId(idProvider.incrementAndGet());
|
task.withId(idProvider.incrementAndGet());
|
||||||
}
|
}
|
||||||
|
taskMap.put(task.getId(),task);
|
||||||
writeTaskListToFile();
|
writeTaskListToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,13 @@ public class JsonTaskListTest {
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Add task.")
|
@DisplayName("Add task.")
|
||||||
void addTask() {
|
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 {
|
try {
|
||||||
testDatabase.saveTask(task);
|
testDatabase.saveTask(task);
|
||||||
List<Task> taskList;
|
List<Task> taskList;
|
||||||
try {
|
try {
|
||||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
|
taskList = testDatabase.getTaskList(LocalDate.parse("2022-04-30", formatter),
|
||||||
LocalDate.parse("31.05.2022", formatter));
|
LocalDate.parse("2022-05-31", formatter));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue