diff --git a/topics/server-integrate-database.topic b/topics/server-integrate-database.topic index f426195b0..88bd371d2 100644 --- a/topics/server-integrate-database.topic +++ b/topics/server-integrate-database.topic @@ -271,9 +271,37 @@ FakeTaskRepository.kt and add the following class:

- + = tasks + + override fun tasksByPriority(priority: Priority) = tasks.filter { + it.priority == priority + } + + override fun taskByName(name: String) = tasks.find { + it.name.equals(name, ignoreCase = true) + } + + override fun addTask(task: Task) { + if (taskByName(task.name) != null) { + throw IllegalStateException("Cannot duplicate task names!") + } + tasks.add(task) + } + + override fun removeTask(name: String): Boolean { + return tasks.removeIf { it.name == name } + } + } + ]]>