diff --git a/app/src/androidTest/java/com/todoroo/astrid/model/TaskTest.kt b/app/src/androidTest/java/com/todoroo/astrid/model/TaskTest.kt index 1036b0e23..460497df9 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/model/TaskTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/model/TaskTest.kt @@ -1,12 +1,13 @@ package com.todoroo.astrid.model -import com.todoroo.astrid.dao.TaskDaoBlocking +import com.todoroo.astrid.dao.TaskDao import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules +import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Test -import org.tasks.Freeze +import org.tasks.SuspendFreeze.Companion.freezeClock import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule import org.tasks.time.DateTimeUtils @@ -15,11 +16,11 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class TaskTest : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var taskDao: TaskDao @Test - fun testSavedTaskHasCreationDate() { - Freeze.freezeClock { + fun testSavedTaskHasCreationDate() = runBlocking { + freezeClock { val task = Task() taskDao.createNew(task) assertEquals(DateTimeUtils.currentTimeMillis(), task.creationDate) @@ -27,10 +28,10 @@ class TaskTest : InjectingTestCase() { } @Test - fun testReadTaskFromDb() { + fun testReadTaskFromDb() = runBlocking { val task = Task() taskDao.createNew(task) - val fromDb = taskDao.fetchBlocking(task.id) + val fromDb = taskDao.fetch(task.id) assertEquals(task, fromDb) } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.kt b/app/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.kt index 5ad1d53d4..053b9fa31 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.kt @@ -1,17 +1,17 @@ package com.todoroo.astrid.sync -import com.todoroo.astrid.dao.TaskDaoBlocking +import com.todoroo.astrid.dao.TaskDao import com.todoroo.astrid.data.Task import org.tasks.data.TagData -import org.tasks.data.TagDataDaoBlocking +import org.tasks.data.TagDataDao import org.tasks.injection.InjectingTestCase import javax.inject.Inject open class NewSyncTestCase : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDaoBlocking - @Inject lateinit var tagDataDao: TagDataDaoBlocking + @Inject lateinit var taskDao: TaskDao + @Inject lateinit var tagDataDao: TagDataDao - fun createTask(): Task { + suspend fun createTask(): Task { val task = Task() task.title = SYNC_TASK_TITLE task.priority = SYNC_TASK_IMPORTANCE @@ -19,7 +19,7 @@ open class NewSyncTestCase : InjectingTestCase() { return task } - fun createTagData(): TagData { + suspend fun createTagData(): TagData { val tag = TagData() tag.name = "new tag" tagDataDao.createNew(tag) diff --git a/app/src/androidTest/java/com/todoroo/astrid/sync/SyncModelTest.kt b/app/src/androidTest/java/com/todoroo/astrid/sync/SyncModelTest.kt index 0d5dfca34..92288a17e 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/sync/SyncModelTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/sync/SyncModelTest.kt @@ -3,6 +3,7 @@ package com.todoroo.astrid.sync import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules +import kotlinx.coroutines.runBlocking import org.junit.Assert.assertNotEquals import org.junit.Test import org.tasks.injection.ProductionModule @@ -12,13 +13,13 @@ import org.tasks.injection.ProductionModule class SyncModelTest : NewSyncTestCase() { @Test - fun testCreateTaskMakesUuid() { + fun testCreateTaskMakesUuid() = runBlocking{ val task = createTask() assertNotEquals(Task.NO_UUID, task.uuid) } @Test - fun testCreateTagMakesUuid() { + fun testCreateTagMakesUuid() = runBlocking{ val tag = createTagData() assertNotEquals(Task.NO_UUID, tag.remoteId) } diff --git a/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt b/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt deleted file mode 100644 index 23a5adc81..000000000 --- a/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2012 Todoroo Inc - * - * See the file "LICENSE" for the full license governing this code. - */ -package com.todoroo.astrid.dao - -import com.todoroo.astrid.api.Filter -import com.todoroo.astrid.data.Task -import org.tasks.data.runBlocking -import javax.inject.Inject - -@Deprecated("use coroutines") -class TaskDaoBlocking @Inject constructor(private val dao: TaskDao) { - fun needsRefresh(): List = runBlocking { - dao.needsRefresh() - } - - fun fetchBlocking(id: Long) = runBlocking { - dao.fetch(id) - } - - fun fetch(ids: List): List = runBlocking { - dao.fetch(ids) - } - - fun activeTimers(): Int = runBlocking { - dao.activeTimers() - } - - fun snooze(taskIds: List, millis: Long) = runBlocking { - dao.snooze(taskIds, millis) - } - - fun getTasksWithReminders(): List = runBlocking { - dao.getTasksWithReminders() - } - - fun save(task: Task) = runBlocking { - dao.save(task) - } - - fun save(task: Task, original: Task? = fetchBlocking(task.id)) = runBlocking { - dao.save(task, original) - } - - fun createNew(task: Task) = runBlocking { - dao.createNew(task) - } - - fun count(filter: Filter): Int = runBlocking { - dao.count(filter) - } - - fun fetchFiltered(filter: Filter): List = runBlocking { - dao.fetchFiltered(filter) - } -} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt b/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt deleted file mode 100644 index d4c8a5dc9..000000000 --- a/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.tasks.data - -import javax.inject.Inject - -@Deprecated("use coroutines") -class AlarmDaoBlocking @Inject constructor(private val dao: AlarmDao) { - fun getAlarms(taskId: Long): List = runBlocking { - dao.getAlarms(taskId) - } - - fun insert(alarms: Iterable) = runBlocking { - dao.insert(alarms) - } -} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt b/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt index 54870f52d..3a7df335e 100644 --- a/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt @@ -1,7 +1,6 @@ package org.tasks.data import androidx.lifecycle.LiveData -import com.todoroo.astrid.data.Task import javax.inject.Inject @Deprecated("use coroutines") @@ -10,22 +9,10 @@ class CaldavDaoBlocking @Inject constructor(private val dao: CaldavDao) { return dao.subscribeToCalendars() } - fun accountCount(): Int = runBlocking { - dao.accountCount() - } - fun setCollapsed(id: Long, collapsed: Boolean) = runBlocking { dao.setCollapsed(id, collapsed) } - fun insert(task: Task, caldavTask: CaldavTask, addToTop: Boolean): Long = runBlocking { - dao.insert(task, caldavTask, addToTop) - } - - fun getTask(taskId: Long): CaldavTask? = runBlocking { - dao.getTask(taskId) - } - fun getCalendars(): List = runBlocking { dao.getCalendars() } diff --git a/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt b/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt index c3ab24a88..f4aaec049 100644 --- a/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt @@ -4,15 +4,7 @@ import javax.inject.Inject @Deprecated("use coroutines") class GoogleTaskDaoBlocking @Inject constructor(private val dao: GoogleTaskDao) { - fun insertAndShift(task: GoogleTask, top: Boolean) = runBlocking { - dao.insertAndShift(task, top) - } - fun setCollapsed(id: Long, collapsed: Boolean) = runBlocking { dao.setCollapsed(id, collapsed) } - - fun getByTaskId(taskId: Long): GoogleTask? = runBlocking { - dao.getByTaskId(taskId) - } } \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt b/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt index 5ca8ea166..e3ea082ba 100644 --- a/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt @@ -5,38 +5,10 @@ import javax.inject.Inject @Deprecated("use coroutines") class LocationDaoBlocking @Inject constructor(private val dao: LocationDao) { - fun getPlacesWithGeofences(): List = runBlocking { - dao.getPlacesWithGeofences() - } - - fun getGeofencesByPlace(uid: String): MergedGeofence? = runBlocking { - dao.getGeofencesByPlace(uid) - } - - fun getPlaceForTask(taskId: Long): Place? = runBlocking { - dao.getPlaceForTask(taskId) - } - - fun insert(location: Geofence): Long = runBlocking { - dao.insert(location) - } - fun insert(place: Place): Long = runBlocking { dao.insert(place) } - fun getGeofencesForTask(taskId: Long): List = runBlocking { - dao.getGeofencesForTask(taskId) - } - - fun getPlace(id: Long): Place? = runBlocking { - dao.getPlace(id) - } - - fun getPlace(uid: String): Place? = runBlocking { - dao.getPlace(uid) - } - fun getPlaceUsage(): LiveData> { return dao.getPlaceUsage() } diff --git a/app/src/main/java/org/tasks/data/TagDaoBlocking.kt b/app/src/main/java/org/tasks/data/TagDaoBlocking.kt deleted file mode 100644 index 7ff736b35..000000000 --- a/app/src/main/java/org/tasks/data/TagDaoBlocking.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.tasks.data - -import javax.inject.Inject - -@Deprecated("use coroutines") -class TagDaoBlocking @Inject constructor(private val dao: TagDao) { - fun insert(tag: Tag) = runBlocking { - dao.insert(tag) - } - - fun insert(tags: Iterable) = runBlocking { - dao.insert(tags) - } -} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt b/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt index 81ec3c750..9f52f26eb 100644 --- a/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt +++ b/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt @@ -9,14 +9,6 @@ class TagDataDaoBlocking @Inject constructor(private val dao: TagDataDao) { return dao.subscribeToTags() } - fun getTagByName(name: String): TagData? = runBlocking { - dao.getTagByName(name) - } - - fun getTagWithCase(tag: String): String? = runBlocking { - dao.getTagWithCase(tag) - } - fun searchTags(query: String): List = runBlocking { dao.searchTags(query) } @@ -25,10 +17,6 @@ class TagDataDaoBlocking @Inject constructor(private val dao: TagDataDao) { dao.tagDataOrderedByName() } - fun getTagDataForTask(id: Long): List = runBlocking { - dao.getTagDataForTask(id) - } - fun createNew(tag: TagData) = runBlocking { dao.createNew(tag) }