Remove unused blocking dao methods

pull/1055/head
Alex Baker 4 years ago
parent 02d99d9996
commit 22363bcb17

@ -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)
}
}

@ -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)

@ -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)
}

@ -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<Task> = runBlocking {
dao.needsRefresh()
}
fun fetchBlocking(id: Long) = runBlocking {
dao.fetch(id)
}
fun fetch(ids: List<Long>): List<Task> = runBlocking {
dao.fetch(ids)
}
fun activeTimers(): Int = runBlocking {
dao.activeTimers()
}
fun snooze(taskIds: List<Long>, millis: Long) = runBlocking {
dao.snooze(taskIds, millis)
}
fun getTasksWithReminders(): List<Task> = 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<Task> = runBlocking {
dao.fetchFiltered(filter)
}
}

@ -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<Alarm> = runBlocking {
dao.getAlarms(taskId)
}
fun insert(alarms: Iterable<Alarm>) = runBlocking {
dao.insert(alarms)
}
}

@ -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<CaldavCalendar> = runBlocking {
dao.getCalendars()
}

@ -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)
}
}

@ -5,38 +5,10 @@ import javax.inject.Inject
@Deprecated("use coroutines")
class LocationDaoBlocking @Inject constructor(private val dao: LocationDao) {
fun getPlacesWithGeofences(): List<Place> = 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<Geofence> = 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<List<PlaceUsage>> {
return dao.getPlaceUsage()
}

@ -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<Tag>) = runBlocking {
dao.insert(tags)
}
}

@ -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<TagData> = runBlocking {
dao.searchTags(query)
}
@ -25,10 +17,6 @@ class TagDataDaoBlocking @Inject constructor(private val dao: TagDataDao) {
dao.tagDataOrderedByName()
}
fun getTagDataForTask(id: Long): List<TagData> = runBlocking {
dao.getTagDataForTask(id)
}
fun createNew(tag: TagData) = runBlocking {
dao.createNew(tag)
}

Loading…
Cancel
Save