diff --git a/app/src/main/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsViewModel.kt b/app/src/main/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsViewModel.kt index 7111488a55..340e3fb715 100644 --- a/app/src/main/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsViewModel.kt +++ b/app/src/main/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsViewModel.kt @@ -43,7 +43,7 @@ class ToolsViewModel @Inject constructor( .map { if (!it) BannerType.TOOL_LIST_FAVORITES else null } .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), null) - val spotlightTools = toolsRepository.getToolsFlow() + val spotlightTools = toolsRepository.getNormalToolsFlow() .map { it.filter { !it.isHidden && it.isSpotlight }.sortedWith(Tool.COMPARATOR_DEFAULT_ORDER) } .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList()) @@ -59,7 +59,7 @@ class ToolsViewModel @Inject constructor( private val toolsForLocale = selectedLocale .flatMapLatest { - if (it != null) toolsRepository.getToolsFlowForLanguage(it) else toolsRepository.getToolsFlow() + if (it != null) toolsRepository.getToolsFlowForLanguage(it) else toolsRepository.getNormalToolsFlow() } .map { it.filterNot { it.isHidden }.sortedBy { it.defaultOrder } } .combine( diff --git a/app/src/main/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsViewModel.kt b/app/src/main/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsViewModel.kt index 9e4c4b07ee..69fa7ef64a 100644 --- a/app/src/main/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsViewModel.kt +++ b/app/src/main/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsViewModel.kt @@ -49,7 +49,7 @@ class ToolDetailsViewModel @Inject constructor( .flatMapLatest { metatool -> when (metatool) { null -> flowOf(emptyList()) - else -> toolsRepository.getToolsFlow().map { it.filter { it.metatoolCode == metatool } } + else -> toolsRepository.getNormalToolsFlow().map { it.filter { it.metatoolCode == metatool } } } } .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), emptyList()) diff --git a/app/src/test/kotlin/org/cru/godtools/ExternalSingletonsModule.kt b/app/src/test/kotlin/org/cru/godtools/ExternalSingletonsModule.kt index 157bb89b48..01b27784a7 100644 --- a/app/src/test/kotlin/org/cru/godtools/ExternalSingletonsModule.kt +++ b/app/src/test/kotlin/org/cru/godtools/ExternalSingletonsModule.kt @@ -96,7 +96,7 @@ class ExternalSingletonsModule { mockk { every { getFavoriteToolsFlow() } returns flowOf(emptyList()) every { getLessonsFlow() } returns flowOf(emptyList()) - every { getToolsFlow() } returns flowOf(emptyList()) + every { getNormalToolsFlow() } returns flowOf(emptyList()) every { getMetaToolsFlow() } returns flowOf(emptyList()) } } diff --git a/app/src/test/kotlin/org/cru/godtools/ui/dashboard/lessons/LessonsViewModelTest.kt b/app/src/test/kotlin/org/cru/godtools/ui/dashboard/lessons/LessonsViewModelTest.kt index 539558dc98..b12e68fcb6 100644 --- a/app/src/test/kotlin/org/cru/godtools/ui/dashboard/lessons/LessonsViewModelTest.kt +++ b/app/src/test/kotlin/org/cru/godtools/ui/dashboard/lessons/LessonsViewModelTest.kt @@ -13,7 +13,6 @@ import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.setMain import org.cru.godtools.db.repository.ToolsRepository -import org.cru.godtools.model.Lesson import org.cru.godtools.model.Tool import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains @@ -23,7 +22,7 @@ import org.junit.Test @OptIn(ExperimentalCoroutinesApi::class) class LessonsViewModelTest { - private val lessonsFlow = MutableStateFlow(emptyList()) + private val lessonsFlow = MutableStateFlow(emptyList()) private val toolsRepository: ToolsRepository = mockk { every { getLessonsFlow() } returns lessonsFlow @@ -45,15 +44,8 @@ class LessonsViewModelTest { @Test fun `Property lessons - Filter hidden lessons`() = testScope.runTest { - val visible = Lesson().apply { - type = Tool.Type.LESSON - code = "visible" - } - val hidden = Lesson().apply { - type = Tool.Type.LESSON - code = "hidden" - isHidden = true - } + val visible = Tool("visible", Tool.Type.LESSON) + val hidden = Tool("hidden", Tool.Type.LESSON) { isHidden = true } viewModel.lessons.test { lessonsFlow.value = listOf(visible, hidden) diff --git a/app/src/test/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsViewModelTest.kt b/app/src/test/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsViewModelTest.kt index 62747c952f..58947b3bd2 100644 --- a/app/src/test/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsViewModelTest.kt +++ b/app/src/test/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsViewModelTest.kt @@ -41,7 +41,7 @@ class ToolsViewModelTest { } private val testScope = TestScope() private val toolsRepository: ToolsRepository = mockk { - every { getToolsFlow() } returns toolsFlow + every { getNormalToolsFlow() } returns toolsFlow every { getMetaToolsFlow() } returns metaToolsFlow } diff --git a/app/src/test/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsViewModelTest.kt b/app/src/test/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsViewModelTest.kt index 39af54792b..c8ad27f536 100644 --- a/app/src/test/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsViewModelTest.kt +++ b/app/src/test/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsViewModelTest.kt @@ -32,7 +32,7 @@ class ToolDetailsViewModelTest { private val toolsRepository: ToolsRepository = mockk { every { findToolFlow(any()) } returns toolFlow - every { getToolsFlow() } returns toolsFlow + every { getNormalToolsFlow() } returns toolsFlow } private val testScope = TestScope() diff --git a/library/db/src/main/kotlin/org/cru/godtools/db/repository/ToolsRepository.kt b/library/db/src/main/kotlin/org/cru/godtools/db/repository/ToolsRepository.kt index 4c7f41f01e..05a0ff7cea 100644 --- a/library/db/src/main/kotlin/org/cru/godtools/db/repository/ToolsRepository.kt +++ b/library/db/src/main/kotlin/org/cru/godtools/db/repository/ToolsRepository.kt @@ -1,30 +1,27 @@ package org.cru.godtools.db.repository -import androidx.annotation.WorkerThread import java.util.Locale import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map -import org.cru.godtools.model.Lesson -import org.cru.godtools.model.Resource import org.cru.godtools.model.Tool interface ToolsRepository { suspend fun findTool(code: String): Tool? - @WorkerThread - fun findResourceBlocking(code: String): Tool? - suspend fun getResources(): List - @WorkerThread - fun getResourcesBlocking(): List - suspend fun getTools(): List - fun findToolFlow(code: String): Flow - fun getResourcesFlow(): Flow> - fun getToolsFlow(): Flow> + + suspend fun getAllTools(): List + suspend fun getToolsByType(types: Collection): List + suspend fun getNormalTools() = getToolsByType(Tool.Type.NORMAL_TYPES) + + fun getAllToolsFlow(): Flow> + fun getToolsFlowByType(vararg types: Tool.Type) = getToolsFlowByType(types.toSet()) + fun getToolsFlowByType(types: Collection): Flow> fun getToolsFlowForLanguage(locale: Locale): Flow> - fun getMetaToolsFlow(): Flow> - fun getFavoriteToolsFlow(): Flow> = - getToolsFlow().map { it.filter { it.isFavorite }.sortedWith(Tool.COMPARATOR_FAVORITE_ORDER) } - fun getLessonsFlow(): Flow> + fun getMetaToolsFlow() = getToolsFlowByType(Tool.Type.META) + fun getLessonsFlow() = getToolsFlowByType(Tool.Type.LESSON) + fun getNormalToolsFlow() = getToolsFlowByType(Tool.Type.NORMAL_TYPES) + fun getFavoriteToolsFlow() = getNormalToolsFlow() + .map { it.filter { it.isFavorite }.sortedWith(Tool.COMPARATOR_FAVORITE_ORDER) } fun toolsChangeFlow(): Flow @@ -35,7 +32,7 @@ interface ToolsRepository { suspend fun updateToolViews(code: String, delta: Int) // region Initial Content Methods - suspend fun storeInitialResources(tools: Collection) + suspend fun storeInitialTools(tools: Collection) // endregion Initial Content Methods // region Sync Methods diff --git a/library/db/src/main/kotlin/org/cru/godtools/db/room/dao/ToolsDao.kt b/library/db/src/main/kotlin/org/cru/godtools/db/room/dao/ToolsDao.kt index a57ff6f410..da23385415 100644 --- a/library/db/src/main/kotlin/org/cru/godtools/db/room/dao/ToolsDao.kt +++ b/library/db/src/main/kotlin/org/cru/godtools/db/room/dao/ToolsDao.kt @@ -19,20 +19,16 @@ internal interface ToolsDao { @Query("SELECT * FROM tools WHERE code = :code") suspend fun findTool(code: String): ToolEntity? @Query("SELECT * FROM tools WHERE code = :code") - fun findToolBlocking(code: String): ToolEntity? - @Query("SELECT * FROM tools WHERE code = :code") - fun findToolFlow(code: String): Flow + suspend fun findToolFavorite(code: String): ToolFavorite? @Query("SELECT * FROM tools WHERE id = :id") fun findToolByIdBlocking(id: Long): ToolEntity? @Query("SELECT * FROM tools WHERE code = :code") - fun findToolFavorite(code: String): ToolFavorite? + fun findToolFlow(code: String): Flow @Query("SELECT * FROM tools") - suspend fun getResources(): List - @Query("SELECT * FROM tools") - fun getResourcesBlocking(): List + suspend fun getTools(): List @Query("SELECT * FROM tools") - fun getResourcesFlow(): Flow> + fun getToolsFlow(): Flow> @Query("SELECT * FROM tools WHERE type in (:types)") suspend fun getToolsByType(types: Collection): List @Query("SELECT * FROM tools WHERE type in (:types)") @@ -53,9 +49,9 @@ internal interface ToolsDao { @Update(entity = ToolEntity::class) suspend fun updateToolFavorites(tools: Collection) @Query("UPDATE tools SET `order` = ${Int.MAX_VALUE}") - fun resetToolOrder() + suspend fun resetToolOrder() @Query("UPDATE tools SET `order` = :order WHERE code = :code") - fun updateToolOrder(code: String, order: Int) + suspend fun updateToolOrder(code: String, order: Int) @Query("UPDATE tools SET pendingShares = pendingShares + :views WHERE code = :code") suspend fun updateToolViews(code: String, views: Int) @Delete diff --git a/library/db/src/main/kotlin/org/cru/godtools/db/room/repository/ToolsRoomRepository.kt b/library/db/src/main/kotlin/org/cru/godtools/db/room/repository/ToolsRoomRepository.kt index 58b1dcfd51..ba19e0625b 100644 --- a/library/db/src/main/kotlin/org/cru/godtools/db/room/repository/ToolsRoomRepository.kt +++ b/library/db/src/main/kotlin/org/cru/godtools/db/room/repository/ToolsRoomRepository.kt @@ -10,29 +10,23 @@ import org.cru.godtools.db.repository.ToolsRepository import org.cru.godtools.db.room.GodToolsRoomDatabase import org.cru.godtools.db.room.entity.ToolEntity import org.cru.godtools.db.room.entity.partial.SyncTool -import org.cru.godtools.model.Resource import org.cru.godtools.model.Tool import org.cru.godtools.model.trackChanges -private val TOOL_TYPES = setOf(Tool.Type.TRACT, Tool.Type.CYOA, Tool.Type.ARTICLE) - @Dao internal abstract class ToolsRoomRepository(private val db: GodToolsRoomDatabase) : ToolsRepository { private val dao get() = db.toolsDao override suspend fun findTool(code: String) = dao.findTool(code)?.toModel() - override fun findResourceBlocking(code: String) = dao.findToolBlocking(code)?.toModel() override fun findToolFlow(code: String) = dao.findToolFlow(code).map { it?.toModel() } - override suspend fun getResources() = dao.getResources().map { it.toModel() } - override fun getResourcesBlocking() = dao.getResourcesBlocking().map { it.toModel() } - override fun getResourcesFlow() = dao.getResourcesFlow().map { it.map { it.toModel() } } - override suspend fun getTools() = dao.getToolsByType(TOOL_TYPES).map { it.toModel() } - override fun getToolsFlow() = dao.getToolsByTypeFlow(TOOL_TYPES).map { it.map { it.toModel() } } + override suspend fun getAllTools() = dao.getTools().map { it.toModel() } + override suspend fun getToolsByType(types: Collection) = dao.getToolsByType(types).map { it.toModel() } + override fun getAllToolsFlow() = dao.getToolsFlow().map { it.map { it.toModel() } } + override fun getToolsFlowByType(types: Collection) = + dao.getToolsByTypeFlow(types).map { it.map { it.toModel() } } override fun getToolsFlowForLanguage(locale: Locale) = - dao.getToolsFlowByTypeAndLanguage(TOOL_TYPES, locale).map { it.map { it.toModel() } } - override fun getMetaToolsFlow() = dao.getToolsByTypeFlow(setOf(Tool.Type.META)).map { it.map { it.toModel() } } - override fun getLessonsFlow() = dao.getToolsByTypeFlow(setOf(Tool.Type.LESSON)).map { it.map { it.toModel() } } + dao.getToolsFlowByTypeAndLanguage(Tool.Type.NORMAL_TYPES, locale).map { it.map { it.toModel() } } override fun toolsChangeFlow(): Flow = db.changeFlow("tools") @@ -60,7 +54,7 @@ internal abstract class ToolsRoomRepository(private val db: GodToolsRoomDatabase override suspend fun updateToolViews(code: String, delta: Int) = dao.updateToolViews(code, delta) - override suspend fun storeInitialResources(tools: Collection) = + override suspend fun storeInitialTools(tools: Collection) = dao.insertOrIgnoreTools(tools.map { ToolEntity(it) }) // region Sync Methods diff --git a/library/db/src/test/kotlin/org/cru/godtools/db/repository/LanguagesRepositoryIT.kt b/library/db/src/test/kotlin/org/cru/godtools/db/repository/LanguagesRepositoryIT.kt index 6b329807c4..f2c8f6bcc7 100644 --- a/library/db/src/test/kotlin/org/cru/godtools/db/repository/LanguagesRepositoryIT.kt +++ b/library/db/src/test/kotlin/org/cru/godtools/db/repository/LanguagesRepositoryIT.kt @@ -122,7 +122,7 @@ abstract class LanguagesRepositoryIT { repository.getLanguagesFlowForToolCategory("cat1").test { assertThat(awaitItem(), empty()) - toolsRepository.storeInitialResources( + toolsRepository.storeInitialTools( listOf( Tool("tool1", category = "cat1"), Tool("tool2", category = "cat2") @@ -143,7 +143,7 @@ abstract class LanguagesRepositoryIT { @Test fun `getLanguagesFlowForToolCategory() - No Duplicate Languages`() = testScope.runTest { val english = Language(Locale.ENGLISH) - toolsRepository.storeInitialResources( + toolsRepository.storeInitialTools( listOf( Tool("tool1", category = "cat1"), Tool("tool2", category = "cat1") diff --git a/library/db/src/test/kotlin/org/cru/godtools/db/repository/ToolsRepositoryIT.kt b/library/db/src/test/kotlin/org/cru/godtools/db/repository/ToolsRepositoryIT.kt index a2c4f77a9b..c479399719 100644 --- a/library/db/src/test/kotlin/org/cru/godtools/db/repository/ToolsRepositoryIT.kt +++ b/library/db/src/test/kotlin/org/cru/godtools/db/repository/ToolsRepositoryIT.kt @@ -18,7 +18,6 @@ import kotlinx.coroutines.test.runTest import kotlinx.coroutines.withContext import org.cru.godtools.model.Attachment import org.cru.godtools.model.Language -import org.cru.godtools.model.Resource import org.cru.godtools.model.Tool import org.cru.godtools.model.ToolMatchers.tool import org.cru.godtools.model.Translation @@ -48,51 +47,27 @@ abstract class ToolsRepositoryIT { } // endregion findTool() - // region findResourceBlocking() - @Test - fun `findResourceBlocking()`() = testScope.runTest { - val resource = Resource("tool", Tool.Type.TRACT) - repository.storeToolsFromSync(setOf(resource)) - - assertNull(repository.findResourceBlocking("other")) - assertThat(repository.findResourceBlocking("tool"), tool(resource)) - } - // endregion findResourceBlocking() - // region getResources() @Test fun `getResources() - Returns All Resource Types`() = testScope.runTest { - val resources = Tool.Type.values().map { Resource(it.name.lowercase(), it) } + val resources = Tool.Type.values().map { Tool(it.name.lowercase(), it) } repository.storeToolsFromSync(resources) assertThat( - repository.getResources(), + repository.getAllTools(), containsInAnyOrder(resources.map { tool(it) }) ) } // endregion getResources() - // region getResourcesBlocking() + // region getNormalTools() @Test - fun `getResourcesBlocking() - Returns All Resource Types`() = testScope.runTest { - val resources = Tool.Type.values().map { Resource(it.name.lowercase(), it) } - repository.storeToolsFromSync(resources) - - assertThat( - repository.getResourcesBlocking(), - containsInAnyOrder(resources.map { tool(it) }) - ) - } - // endregion getResourcesBlocking() - - // region getTools() - @Test - fun `getTools() - Supported Tool Types Only`() = testScope.runTest { + fun `getNormalTools() - Supported Tool Types Only`() = testScope.runTest { val tools = Tool.Type.values().map { Tool(it.name.lowercase(), it) } repository.storeToolsFromSync(tools) assertThat( - repository.getTools(), + repository.getNormalTools(), containsInAnyOrder( tools .filter { it.type == Tool.Type.ARTICLE || it.type == Tool.Type.CYOA || it.type == Tool.Type.TRACT } @@ -102,52 +77,52 @@ abstract class ToolsRepositoryIT { } @Test - fun `getTools() - Don't filter hidden tools`() = testScope.runTest { + fun `getNormalTools() - Don't filter hidden tools`() = testScope.runTest { val hidden = Tool("hidden") { isHidden = true } val visible = Tool("visible") { isHidden = false } repository.storeToolsFromSync(listOf(hidden, visible)) assertThat( - repository.getTools(), + repository.getNormalTools(), containsInAnyOrder(tool(hidden), tool(visible)) ) } @Test - fun `getTools() - Don't filter metatool variants`() = testScope.runTest { - val meta = Resource("meta", Tool.Type.META) { defaultVariantCode = "defaultVariant" } + fun `getNormalTools() - Don't filter metatool variants`() = testScope.runTest { + val meta = Tool("meta", Tool.Type.META) { defaultVariantCode = "defaultVariant" } val defaultVariant = Tool("defaultVariant") { metatoolCode = "meta" } val otherVariant = Tool("otherVariant") { metatoolCode = "meta" } repository.storeToolsFromSync(listOf(meta, defaultVariant, otherVariant)) assertThat( - repository.getTools(), + repository.getNormalTools(), containsInAnyOrder(tool(defaultVariant), tool(otherVariant)) ) } - // endregion getTools() + // endregion getNormalTools() - // region getResourcesFlow() + // region getAllToolsFlow() @Test - fun `getResourcesFlow() - Returns All Resource Types`() = testScope.runTest { - val resources = Tool.Type.values().map { Resource(it.name.lowercase(), it) } + fun `getAllToolsFlow() - Returns All Resource Types`() = testScope.runTest { + val resources = Tool.Type.values().map { Tool(it.name.lowercase(), it) } repository.storeToolsFromSync(resources) assertThat( - repository.getResourcesFlow().first(), + repository.getAllToolsFlow().first(), containsInAnyOrder(resources.map { tool(it) }) ) } - // endregion getResourcesFlow() + // endregion getAllToolsFlow() - // region getToolsFlow() + // region getNormalToolsFlow() @Test - fun `getToolsFlow() - Supported Tool Types Only`() = testScope.runTest { + fun `getNormalToolsFlow() - Supported Tool Types Only`() = testScope.runTest { val tools = Tool.Type.values().map { Tool(it.name.lowercase(), it) } repository.storeToolsFromSync(tools) assertThat( - repository.getToolsFlow().first(), + repository.getNormalToolsFlow().first(), containsInAnyOrder( tools .filter { it.type == Tool.Type.ARTICLE || it.type == Tool.Type.CYOA || it.type == Tool.Type.TRACT } @@ -157,37 +132,37 @@ abstract class ToolsRepositoryIT { } @Test - fun `getToolsFlow() - Don't filter hidden tools`() = testScope.runTest { + fun `getNormalToolsFlow() - Don't filter hidden tools`() = testScope.runTest { val hidden = Tool("hidden") { isHidden = true } val visible = Tool("visible") { isHidden = false } repository.storeToolsFromSync(listOf(hidden, visible)) assertThat( - repository.getToolsFlow().first(), + repository.getNormalToolsFlow().first(), containsInAnyOrder(tool(hidden), tool(visible)) ) } @Test - fun `getToolsFlow() - Don't filter metatool variants`() = testScope.runTest { + fun `getNormalToolsFlow() - Don't filter metatool variants`() = testScope.runTest { val meta = Tool("meta", Tool.Type.META) { defaultVariantCode = "defaultVariant" } val defaultVariant = Tool("defaultVariant") { metatoolCode = "meta" } val otherVariant = Tool("otherVariant") { metatoolCode = "meta" } repository.storeToolsFromSync(listOf(meta, defaultVariant, otherVariant)) assertThat( - repository.getToolsFlow().first(), + repository.getNormalToolsFlow().first(), containsInAnyOrder(tool(defaultVariant), tool(otherVariant)) ) } - // endregion getToolsFlow() + // endregion getNormalToolsFlow() // region getToolsFlowForLanguage() @Test fun `getToolsFlowForLanguage()`() = testScope.runTest { val tool1 = Tool("tool1") val tool2 = Tool("tool2") - repository.storeInitialResources(listOf(tool1, tool2)) + repository.storeInitialTools(listOf(tool1, tool2)) languagesRepository.storeInitialLanguages(listOf(Language(Locale.ENGLISH), Language(Locale.FRENCH))) repository.getToolsFlowForLanguage(Locale.ENGLISH).test { @@ -212,7 +187,7 @@ abstract class ToolsRepositoryIT { val tool2 = Tool("tool2") { isFavorite = false } val fav1 = Tool("fav1") { isFavorite = true } val fav2 = Tool("fav2") { isFavorite = true } - repository.storeInitialResources(listOf(tool1, tool2, fav1, fav2)) + repository.storeInitialTools(listOf(tool1, tool2, fav1, fav2)) assertThat( repository.getFavoriteToolsFlow().first(), @@ -277,7 +252,7 @@ abstract class ToolsRepositoryIT { id = 1 code = "tool" } - repository.storeInitialResources(listOf(tool)) + repository.storeInitialTools(listOf(tool)) runCurrent() expectMostRecentItem() @@ -292,7 +267,7 @@ abstract class ToolsRepositoryIT { @Test fun `pinTool()`() = testScope.runTest { val code = "pinTool" - repository.storeInitialResources(listOf(Tool(code))) + repository.storeInitialTools(listOf(Tool(code))) repository.findToolFlow(code).test { assertNotNull(awaitItem()) { @@ -311,7 +286,7 @@ abstract class ToolsRepositoryIT { @Test fun `pinTool(trackChanges = false)`() = testScope.runTest { val code = "pinTool" - repository.storeInitialResources(listOf(Tool(code))) + repository.storeInitialTools(listOf(Tool(code))) repository.findToolFlow(code).test { assertNotNull(awaitItem()) { @@ -330,7 +305,7 @@ abstract class ToolsRepositoryIT { @Test fun `pinTool() - No Change`() = testScope.runTest { val code = "pinTool" - repository.storeInitialResources(listOf(Tool(code) { isFavorite = true })) + repository.storeInitialTools(listOf(Tool(code) { isFavorite = true })) repository.findToolFlow(code).test { assertNotNull(awaitItem()) { @@ -351,7 +326,7 @@ abstract class ToolsRepositoryIT { @Test fun `unpinTool()`() = testScope.runTest { val code = "pinTool" - repository.storeInitialResources(listOf(Tool(code) { isFavorite = true })) + repository.storeInitialTools(listOf(Tool(code) { isFavorite = true })) repository.findToolFlow(code).test { assertNotNull(awaitItem()) { @@ -370,7 +345,7 @@ abstract class ToolsRepositoryIT { @Test fun `unpinTool() - No Change`() = testScope.runTest { val code = "pinTool" - repository.storeInitialResources(listOf(Tool(code) { isFavorite = false })) + repository.storeInitialTools(listOf(Tool(code) { isFavorite = false })) repository.findToolFlow(code).test { assertNotNull(awaitItem()) { @@ -393,16 +368,16 @@ abstract class ToolsRepositoryIT { val tool1 = Tool("tool1") { order = 7 } val tool2 = Tool("tool2") { order = 6 } val tool3 = Tool("tool3") { order = 5 } - repository.storeInitialResources(listOf(tool1, tool2, tool3)) + repository.storeInitialTools(listOf(tool1, tool2, tool3)) assertEquals( listOf("tool3", "tool2", "tool1"), - repository.getTools().sortedBy { it.order }.map { it.code } + repository.getNormalTools().sortedBy { it.order }.map { it.code } ) repository.storeToolOrder(listOf("tool1", "tool3")) assertEquals( listOf("tool1", "tool3", "tool2"), - repository.getTools().sortedBy { it.order }.map { it.code } + repository.getNormalTools().sortedBy { it.order }.map { it.code } ) } // endregion storeToolOrder() @@ -516,7 +491,7 @@ abstract class ToolsRepositoryIT { // region storeFavoriteToolsFromSync() @Test fun `storeFavoriteToolsFromSync()`() = testScope.runTest { - repository.storeInitialResources( + repository.storeInitialTools( listOf( Tool("tool1") { isFavorite = true }, Tool("tool2") { isFavorite = false }, @@ -532,7 +507,7 @@ abstract class ToolsRepositoryIT { @Test fun `storeFavoriteToolsFromSync() - Handle dirty tools`() = testScope.runTest { - repository.storeInitialResources( + repository.storeInitialTools( listOf( Tool("tool1") { trackChanges { isFavorite = true } }, Tool("tool2") { @@ -577,7 +552,7 @@ abstract class ToolsRepositoryIT { val attachment1 = Attachment(tool = tool1) val attachment2 = Attachment(tool = tool2) val attachment3 = Attachment(tool = tool3) - repository.storeInitialResources(listOf(tool1, tool2, tool3)) + repository.storeInitialTools(listOf(tool1, tool2, tool3)) attachmentsRepository.storeInitialAttachments(listOf(attachment1, attachment2, attachment3)) assertNotNull(attachmentsRepository.findAttachment(attachment1.id)) assertNotNull(attachmentsRepository.findAttachment(attachment2.id)) @@ -597,7 +572,7 @@ abstract class ToolsRepositoryIT { @Test fun `deleteIfNotFavorite() - Don't delete favorited tools`() = testScope.runTest { - repository.storeInitialResources(listOf(Tool("tool") { isFavorite = true })) + repository.storeInitialTools(listOf(Tool("tool") { isFavorite = true })) assertNotNull(repository.findTool("tool")) repository.deleteIfNotFavorite("tool") diff --git a/library/download-manager/src/main/kotlin/org/cru/godtools/downloadmanager/GodToolsDownloadManager.kt b/library/download-manager/src/main/kotlin/org/cru/godtools/downloadmanager/GodToolsDownloadManager.kt index 7553106035..d8cf35ba84 100644 --- a/library/download-manager/src/main/kotlin/org/cru/godtools/downloadmanager/GodToolsDownloadManager.kt +++ b/library/download-manager/src/main/kotlin/org/cru/godtools/downloadmanager/GodToolsDownloadManager.kt @@ -489,7 +489,7 @@ class GodToolsDownloadManager @VisibleForTesting internal constructor( // Tool Banner Attachments attachmentsRepository.getAttachmentsFlow() - .combine(toolsRepository.getResourcesFlow()) { attachments, tools -> + .combine(toolsRepository.getAllToolsFlow()) { attachments, tools -> val banners = tools.flatMapTo(mutableSetOf()) { setOfNotNull(it.bannerId, it.detailsBannerId, it.detailsBannerAnimationId) } @@ -508,7 +508,7 @@ class GodToolsDownloadManager @VisibleForTesting internal constructor( private fun Flow>.downloadFavoriteTranslations() = toolsRepository.getFavoriteToolsFlow() .downloadTranslations(this) - private fun Flow>.downloadAllToolTranslations() = toolsRepository.getToolsFlow() + private fun Flow>.downloadAllToolTranslations() = toolsRepository.getNormalToolsFlow() .downloadTranslations(this) private fun Flow>.downloadAttachments() = this diff --git a/library/download-manager/src/test/kotlin/org/cru/godtools/downloadmanager/GodToolsDownloadManagerDispatcherTest.kt b/library/download-manager/src/test/kotlin/org/cru/godtools/downloadmanager/GodToolsDownloadManagerDispatcherTest.kt index 0d3594ba47..bc9797ba2a 100644 --- a/library/download-manager/src/test/kotlin/org/cru/godtools/downloadmanager/GodToolsDownloadManagerDispatcherTest.kt +++ b/library/download-manager/src/test/kotlin/org/cru/godtools/downloadmanager/GodToolsDownloadManagerDispatcherTest.kt @@ -61,9 +61,9 @@ class GodToolsDownloadManagerDispatcherTest { } private val toolsRepository: ToolsRepository by lazy { mockk { - every { getResourcesFlow() } returns resourcesFlow + every { getAllToolsFlow() } returns resourcesFlow every { getFavoriteToolsFlow() } returns favoriteToolsFlow - every { getToolsFlow() } returns toolsFlow + every { getNormalToolsFlow() } returns toolsFlow } } private val translationsRepository: TranslationsRepository by lazy { diff --git a/library/initial-content/src/main/kotlin/org/cru/godtools/init/content/task/Tasks.kt b/library/initial-content/src/main/kotlin/org/cru/godtools/init/content/task/Tasks.kt index 851e169de2..bc3f04a747 100644 --- a/library/initial-content/src/main/kotlin/org/cru/godtools/init/content/task/Tasks.kt +++ b/library/initial-content/src/main/kotlin/org/cru/godtools/init/content/task/Tasks.kt @@ -64,10 +64,10 @@ internal class Tasks @Inject constructor( // region Tool Initial Content Tasks suspend fun loadBundledResources() = withContext(Dispatchers.IO) { // short-circuit if we already have any resources loaded - if (toolsRepository.getResources().isNotEmpty()) return@withContext + if (toolsRepository.getAllTools().isNotEmpty()) return@withContext bundledTools.let { resources -> - toolsRepository.storeInitialResources(resources) + toolsRepository.storeInitialTools(resources) translationsRepository.storeInitialTranslations(resources.flatMap { it.latestTranslations.orEmpty() }) attachmentsRepository.storeInitialAttachments(resources.flatMap { it.attachments.orEmpty() }) } @@ -76,7 +76,7 @@ internal class Tasks @Inject constructor( suspend fun initFavoriteTools() { // check to see if we have initialized the default tools before if (lastSyncTimeRepository.getLastSyncTime(SYNC_TIME_DEFAULT_TOOLS) > 0) return - if (toolsRepository.getTools().any { it.isFavorite }) return + if (toolsRepository.getNormalTools().any { it.isFavorite }) return coroutineScope { val preferred = async { diff --git a/library/initial-content/src/test/kotlin/org/cru/godtools/init/content/task/TasksTest.kt b/library/initial-content/src/test/kotlin/org/cru/godtools/init/content/task/TasksTest.kt index f438a4d563..f55f019824 100644 --- a/library/initial-content/src/test/kotlin/org/cru/godtools/init/content/task/TasksTest.kt +++ b/library/initial-content/src/test/kotlin/org/cru/godtools/init/content/task/TasksTest.kt @@ -40,7 +40,7 @@ class TasksTest { every { appLanguage } returns Locale("x") } private val toolsRepository: ToolsRepository = mockk(relaxUnitFun = true) { - coEvery { getTools() } returns emptyList() + coEvery { getNormalTools() } returns emptyList() } private val translationsRepository: TranslationsRepository = mockk() @@ -71,11 +71,11 @@ class TasksTest { @Test fun `initFavoriteTools() - Already Ran - Has favorite tools`() = runTest { - coEvery { toolsRepository.getTools() } returns listOf(Tool().apply { isFavorite = true }) + coEvery { toolsRepository.getNormalTools() } returns listOf(Tool().apply { isFavorite = true }) tasks.initFavoriteTools() coVerify { lastSyncTimeRepository.getLastSyncTime(*anyVararg()) - toolsRepository.getTools() + toolsRepository.getNormalTools() downloadManager wasNot Called } confirmVerified(lastSyncTimeRepository, toolsRepository) @@ -85,13 +85,13 @@ class TasksTest { fun `initFavoriteTools()`() = runTest { val tools = Array(5) { Tool("${it + 1}") } val translations = listOf("1", "5").map { Translation(toolCode = it) } - coEvery { toolsRepository.getTools() } returns tools.toList() + coEvery { toolsRepository.getNormalTools() } returns tools.toList() coEvery { translationsRepository.getTranslationsForLanguages(any()) } returns translations every { jsonApiConverter.fromJson(any(), Tool::class.java) } returns JsonApiObject.of(*tools) tasks.initFavoriteTools() coVerifyAll { - toolsRepository.getTools() + toolsRepository.getNormalTools() toolsRepository.pinTool("1", trackChanges = false) toolsRepository.pinTool("2", trackChanges = false) toolsRepository.pinTool("3", trackChanges = false) diff --git a/library/model/src/main/kotlin/org/cru/godtools/model/Resource.kt b/library/model/src/main/kotlin/org/cru/godtools/model/Resource.kt deleted file mode 100644 index 1b61385cc1..0000000000 --- a/library/model/src/main/kotlin/org/cru/godtools/model/Resource.kt +++ /dev/null @@ -1,21 +0,0 @@ -package org.cru.godtools.model - -import androidx.annotation.RestrictTo -import kotlin.random.Random - -typealias Resource = Tool - -typealias Lesson = Resource - -// TODO: move this to testFixtures once they support Kotlin source files -@RestrictTo(RestrictTo.Scope.TESTS) -fun Resource( - code: String, - type: Tool.Type, - config: Resource.() -> Unit = {}, -) = Resource().apply { - id = Random.nextLong() - this.code = code - this.type = type - config() -} diff --git a/library/model/src/main/kotlin/org/cru/godtools/model/Tool.kt b/library/model/src/main/kotlin/org/cru/godtools/model/Tool.kt index 95d5eb833a..df5fd61529 100644 --- a/library/model/src/main/kotlin/org/cru/godtools/model/Tool.kt +++ b/library/model/src/main/kotlin/org/cru/godtools/model/Tool.kt @@ -80,6 +80,8 @@ class Tool : Base(), ChangeTrackingModel { companion object { val DEFAULT = UNKNOWN + val NORMAL_TYPES = setOf(TRACT, CYOA, ARTICLE) + fun fromJson(json: String?) = when (json) { null -> null else -> values().firstOrNull { json == it.json } ?: DEFAULT diff --git a/library/sync/src/main/kotlin/org/cru/godtools/sync/repository/SyncRepository.kt b/library/sync/src/main/kotlin/org/cru/godtools/sync/repository/SyncRepository.kt index ee05c501a4..4618fffce4 100644 --- a/library/sync/src/main/kotlin/org/cru/godtools/sync/repository/SyncRepository.kt +++ b/library/sync/src/main/kotlin/org/cru/godtools/sync/repository/SyncRepository.kt @@ -32,7 +32,7 @@ internal class SyncRepository @Inject constructor( tools: List, existingTools: MutableSet? = null, includes: Includes, - ) = coroutineScope { + ): Unit = coroutineScope { val validTools = tools.filter { it.isValid } if (validTools.isNotEmpty()) toolsRepository.storeToolsFromSync(validTools) diff --git a/library/sync/src/main/kotlin/org/cru/godtools/sync/task/ToolSyncTasks.kt b/library/sync/src/main/kotlin/org/cru/godtools/sync/task/ToolSyncTasks.kt index ab0befa576..cde11ffe83 100644 --- a/library/sync/src/main/kotlin/org/cru/godtools/sync/task/ToolSyncTasks.kt +++ b/library/sync/src/main/kotlin/org/cru/godtools/sync/task/ToolSyncTasks.kt @@ -66,8 +66,8 @@ internal class ToolSyncTasks @Inject internal constructor( // store fetched tools syncRepository.storeTools( - json.data, - existingTools = toolsRepository.getResourcesBlocking().mapNotNull { it.code }.toMutableSet(), + tools = json.data, + existingTools = toolsRepository.getAllTools().mapNotNullTo(mutableSetOf()) { it.code }, includes = INCLUDES_GET_TOOL ) lastSyncTimeRepository.updateLastSyncTime(SYNC_TIME_TOOLS) @@ -101,7 +101,7 @@ internal class ToolSyncTasks @Inject internal constructor( */ internal suspend fun syncShares() = coroutineScope { sharesMutex.withLock { - toolsRepository.getResources() + toolsRepository.getAllTools() .filter { it.pendingShares > 0 } .map { tool -> async { diff --git a/library/sync/src/main/kotlin/org/cru/godtools/sync/task/UserFavoriteToolsSyncTasks.kt b/library/sync/src/main/kotlin/org/cru/godtools/sync/task/UserFavoriteToolsSyncTasks.kt index 357f2c3041..210cf0ac2d 100644 --- a/library/sync/src/main/kotlin/org/cru/godtools/sync/task/UserFavoriteToolsSyncTasks.kt +++ b/library/sync/src/main/kotlin/org/cru/godtools/sync/task/UserFavoriteToolsSyncTasks.kt @@ -82,7 +82,7 @@ internal class UserFavoriteToolsSyncTasks @Inject constructor( ?.also { syncRepository.storeUser(it) } ?: return@coroutineScope false - val favoritesToAdd = toolsRepository.getResources() + val favoritesToAdd = toolsRepository.getAllTools() .filter { (it.isFieldChanged(Tool.ATTR_IS_FAVORITE) || !user.isInitialFavoriteToolsSynced) && it.isFavorite } @@ -114,7 +114,7 @@ internal class UserFavoriteToolsSyncTasks @Inject constructor( } } - val favoritesToRemove = toolsRepository.getResources() + val favoritesToRemove = toolsRepository.getAllTools() .filter { it.isFieldChanged(Tool.ATTR_IS_FAVORITE) && !it.isFavorite } if (favoritesToRemove.isNotEmpty()) { diff --git a/library/sync/src/test/kotlin/org/cru/godtools/sync/task/ToolSyncTasksTest.kt b/library/sync/src/test/kotlin/org/cru/godtools/sync/task/ToolSyncTasksTest.kt new file mode 100644 index 0000000000..182249743a --- /dev/null +++ b/library/sync/src/test/kotlin/org/cru/godtools/sync/task/ToolSyncTasksTest.kt @@ -0,0 +1,101 @@ +package org.cru.godtools.sync.task + +import io.mockk.Called +import io.mockk.Runs +import io.mockk.coEvery +import io.mockk.coVerifyAll +import io.mockk.coVerifySequence +import io.mockk.just +import io.mockk.mockk +import kotlin.test.Test +import kotlinx.coroutines.test.runTest +import org.ccci.gto.android.common.jsonapi.model.JsonApiObject +import org.cru.godtools.api.ToolsApi +import org.cru.godtools.api.ViewsApi +import org.cru.godtools.db.repository.LastSyncTimeRepository +import org.cru.godtools.db.repository.ToolsRepository +import org.cru.godtools.model.randomTool +import org.cru.godtools.sync.repository.SyncRepository +import retrofit2.Response + +class ToolSyncTasksTest { + private val tool = randomTool() + private val existingTools = listOf(randomTool()) + + private val toolsApi: ToolsApi = mockk { + coEvery { list(any()) } returns Response.success(JsonApiObject.single(tool)) + } + private val viewsApi: ViewsApi = mockk() + private val syncRepository: SyncRepository = mockk { + coEvery { storeTools(tools = any(), existingTools = any(), includes = any()) } just Runs + } + private val toolsRepository: ToolsRepository = mockk { + coEvery { getAllTools() } returns existingTools + } + private val lastSyncTimeRepository: LastSyncTimeRepository = mockk { + coEvery { isLastSyncStale(*anyVararg(), staleAfter = any()) } returns true + coEvery { updateLastSyncTime(*anyVararg()) } just Runs + } + + private val tasks = ToolSyncTasks( + toolsApi = toolsApi, + viewsApi = viewsApi, + syncRepository = syncRepository, + toolsRepository = toolsRepository, + lastSyncTimeRepository = lastSyncTimeRepository, + ) + + // region syncTools() + @Test + fun `syncTools()`() = runTest { + tasks.syncTools() + coVerifySequence { + lastSyncTimeRepository.isLastSyncStale(*anyVararg(), staleAfter = any()) + + toolsApi.list(any()) + toolsRepository.getAllTools() + + syncRepository.storeTools( + tools = listOf(tool), + existingTools = existingTools.mapNotNullTo(mutableSetOf()) { it.code }, + includes = any() + ) + + lastSyncTimeRepository.updateLastSyncTime(*anyVararg()) + } + } + + @Test + fun `syncTools(force = false) - already synced`() = runTest { + coEvery { lastSyncTimeRepository.isLastSyncStale(*anyVararg(), staleAfter = any()) } returns false + + tasks.syncTools(force = false) + coVerifyAll { + lastSyncTimeRepository.isLastSyncStale(*anyVararg(), staleAfter = any()) + + toolsApi wasNot Called + syncRepository wasNot Called + viewsApi wasNot Called + } + } + + @Test + fun `syncTools(force = true) - already synced`() = runTest { + coEvery { lastSyncTimeRepository.isLastSyncStale(*anyVararg(), staleAfter = any()) } returns false + + tasks.syncTools(force = true) + coVerifySequence { + toolsApi.list(any()) + toolsRepository.getAllTools() + + syncRepository.storeTools( + tools = listOf(tool), + existingTools = existingTools.mapNotNullTo(mutableSetOf()) { it.code }, + includes = any() + ) + + lastSyncTimeRepository.updateLastSyncTime(*anyVararg()) + } + } + // endregion syncTools() +} diff --git a/library/sync/src/test/kotlin/org/cru/godtools/sync/task/UserFavoriteToolsSyncTasksTest.kt b/library/sync/src/test/kotlin/org/cru/godtools/sync/task/UserFavoriteToolsSyncTasksTest.kt index 90f3767095..20c8665801 100644 --- a/library/sync/src/test/kotlin/org/cru/godtools/sync/task/UserFavoriteToolsSyncTasksTest.kt +++ b/library/sync/src/test/kotlin/org/cru/godtools/sync/task/UserFavoriteToolsSyncTasksTest.kt @@ -47,7 +47,7 @@ class UserFavoriteToolsSyncTasksTest { coEvery { storeFavoriteTools(any(), any()) } just Runs } private val toolsRepository: ToolsRepository = mockk { - coEvery { getResources() } returns emptyList() + coEvery { getAllTools() } returns emptyList() } private val userApi: UserApi = mockk { coEvery { getUser(any()) } @@ -134,7 +134,7 @@ class UserFavoriteToolsSyncTasksTest { ) val responseTool = Tool("resp") - coEvery { toolsRepository.getResources() } returns tools + coEvery { toolsRepository.getAllTools() } returns tools coEvery { favoritesApi.addFavoriteTools(any(), any()) } returns Response.success(JsonApiObject.of(responseTool)) assertTrue(tasks.syncDirtyFavoriteTools()) @@ -167,7 +167,7 @@ class UserFavoriteToolsSyncTasksTest { coEvery { userRepository.findUser(userId) } returns null coEvery { userApi.getUser(any()) } returns Response.success(JsonApiObject.single(user)) - coEvery { toolsRepository.getResources() } returns tools + coEvery { toolsRepository.getAllTools() } returns tools coEvery { favoritesApi.addFavoriteTools(any(), any()) } returns Response.success(JsonApiObject.of(responseTool)) coExcludeRecords { userApi.getUser(any()) @@ -201,7 +201,7 @@ class UserFavoriteToolsSyncTasksTest { ) val responseTool = Tool("resp") - coEvery { toolsRepository.getResources() } returns tools + coEvery { toolsRepository.getAllTools() } returns tools coEvery { favoritesApi.removeFavoriteTools(any(), any()) } .returns(Response.success(JsonApiObject.of(responseTool))) diff --git a/ui/article-aem-renderer/src/main/kotlin/org/cru/godtools/article/aem/service/AemArticleManager.kt b/ui/article-aem-renderer/src/main/kotlin/org/cru/godtools/article/aem/service/AemArticleManager.kt index 4f0d9584d2..7b6ef4848b 100644 --- a/ui/article-aem-renderer/src/main/kotlin/org/cru/godtools/article/aem/service/AemArticleManager.kt +++ b/ui/article-aem-renderer/src/main/kotlin/org/cru/godtools/article/aem/service/AemArticleManager.kt @@ -228,7 +228,7 @@ class AemArticleManager @VisibleForTesting internal constructor( // region Translations init { - toolsRepository.getToolsFlow() + toolsRepository.getNormalToolsFlow() .map { tools -> tools .filter { it.type == Tool.Type.ARTICLE } diff --git a/ui/article-aem-renderer/src/test/kotlin/org/cru/godtools/article/aem/service/AemArticleManagerDispatcherTest.kt b/ui/article-aem-renderer/src/test/kotlin/org/cru/godtools/article/aem/service/AemArticleManagerDispatcherTest.kt index 16d800cb8d..3800f6f107 100644 --- a/ui/article-aem-renderer/src/test/kotlin/org/cru/godtools/article/aem/service/AemArticleManagerDispatcherTest.kt +++ b/ui/article-aem-renderer/src/test/kotlin/org/cru/godtools/article/aem/service/AemArticleManagerDispatcherTest.kt @@ -47,7 +47,7 @@ class AemArticleManagerDispatcherTest { private val fileManager = mockk(relaxUnitFun = true) private val testScope = TestScope() private val toolsRepository: ToolsRepository = mockk { - every { getToolsFlow() } returns flowOf(emptyList()) + every { getNormalToolsFlow() } returns flowOf(emptyList()) } private val translationsRepository: TranslationsRepository = mockk { every { getTranslationsForToolsFlow(any()) } returns translationsFlow diff --git a/ui/shortcuts/src/main/kotlin/org/cru/godtools/shortcuts/GodToolsShortcutManager.kt b/ui/shortcuts/src/main/kotlin/org/cru/godtools/shortcuts/GodToolsShortcutManager.kt index bd87b55eee..714b615569 100644 --- a/ui/shortcuts/src/main/kotlin/org/cru/godtools/shortcuts/GodToolsShortcutManager.kt +++ b/ui/shortcuts/src/main/kotlin/org/cru/godtools/shortcuts/GodToolsShortcutManager.kt @@ -182,7 +182,7 @@ class GodToolsShortcutManager @VisibleForTesting internal constructor( val manager = shortcutManager ?: return val dynamicShortcuts = withContext(ioDispatcher) { - toolsRepository.getTools() + toolsRepository.getNormalTools() .filter { it.isFavorite } .sortedWith(Tool.COMPARATOR_FAVORITE_ORDER) .asSequence() @@ -214,7 +214,7 @@ class GodToolsShortcutManager @VisibleForTesting internal constructor( } private suspend fun createAllShortcuts() = withContext(ioDispatcher) { - toolsRepository.getResources() + toolsRepository.getAllTools() .map { async { createToolShortcut(it) } }.awaitAll() .filterNotNull() .associateBy { it.id } diff --git a/ui/shortcuts/src/test/kotlin/org/cru/godtools/shortcuts/GodToolsShortcutManagerTest.kt b/ui/shortcuts/src/test/kotlin/org/cru/godtools/shortcuts/GodToolsShortcutManagerTest.kt index 1aeb10e55b..3f347baeb6 100644 --- a/ui/shortcuts/src/test/kotlin/org/cru/godtools/shortcuts/GodToolsShortcutManagerTest.kt +++ b/ui/shortcuts/src/test/kotlin/org/cru/godtools/shortcuts/GodToolsShortcutManagerTest.kt @@ -147,7 +147,7 @@ class GodToolsShortcutManagerTest { @Test @Config(sdk = [Build.VERSION_CODES.N_MR1, NEWEST_SDK]) fun testUpdateDynamicShortcutsDoesntInterceptChildCancelledException() = testScope.runTest { - coEvery { toolsRepository.getTools() } throws CancellationException() + coEvery { toolsRepository.getNormalTools() } throws CancellationException() ExceptionRaisingTree.plant().use { launch { shortcutManager.updateDynamicShortcuts(emptyMap()) }.apply { @@ -156,7 +156,7 @@ class GodToolsShortcutManagerTest { } } coVerifyAll { - toolsRepository.getTools() + toolsRepository.getNormalTools() shortcutManagerService wasNot Called } }