diff --git a/app/src/test/java/org/dhis2/usescases/main/MainPresenterTest.kt b/app/src/test/java/org/dhis2/usescases/main/MainPresenterTest.kt index 83863fac1c..36ae1676db 100644 --- a/app/src/test/java/org/dhis2/usescases/main/MainPresenterTest.kt +++ b/app/src/test/java/org/dhis2/usescases/main/MainPresenterTest.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.setMain import org.dhis2.commons.filters.FilterManager +import org.dhis2.commons.filters.data.FilterRepository import org.dhis2.commons.matomo.Categories.Companion.HOME import org.dhis2.commons.matomo.MatomoAnalyticsController import org.dhis2.commons.prefs.Preference.Companion.DEFAULT_CAT_COMBO @@ -53,6 +54,8 @@ class MainPresenterTest { private val preferences: PreferenceProvider = mock() private val workManagerController: WorkManagerController = mock() private val filterManager: FilterManager = mock() + private val filterRepository: FilterRepository = mock() + private val matomoAnalyticsController: MatomoAnalyticsController = mock() private val userManager: UserManager = mock() private val deleteUserData: DeleteUserData = mock() @@ -83,6 +86,7 @@ class MainPresenterTest { preferences, workManagerController, filterManager, + filterRepository, matomoAnalyticsController, userManager, deleteUserData, diff --git a/app/src/test/java/org/dhis2/usescases/main/program/ProgramRepositoryImplTest.kt b/app/src/test/java/org/dhis2/usescases/main/program/ProgramRepositoryImplTest.kt index e04f232364..d88a2b3ab1 100644 --- a/app/src/test/java/org/dhis2/usescases/main/program/ProgramRepositoryImplTest.kt +++ b/app/src/test/java/org/dhis2/usescases/main/program/ProgramRepositoryImplTest.kt @@ -10,6 +10,7 @@ import org.dhis2.commons.filters.data.FilterPresenter import org.dhis2.commons.resources.MetadataIconProvider import org.dhis2.commons.resources.ResourceManager import org.dhis2.data.dhislogic.DhisProgramUtils +import org.dhis2.data.dhislogic.DhisTrackedEntityInstanceUtils import org.dhis2.data.schedulers.TrampolineSchedulerProvider import org.dhis2.data.service.SyncStatusData import org.dhis2.ui.MetadataIconData @@ -46,6 +47,7 @@ class ProgramRepositoryImplTest { private val filterPresenter: FilterPresenter = Mockito.mock(FilterPresenter::class.java, Mockito.RETURNS_DEEP_STUBS) private val dhisProgramUtils: DhisProgramUtils = mock() + private val dhis2TeiUtils: DhisTrackedEntityInstanceUtils = mock() private val scheduler = TrampolineSchedulerProvider() private val resourceManager: ResourceManager = mock() private val metadataIconProvider: MetadataIconProvider = mock { @@ -60,6 +62,7 @@ class ProgramRepositoryImplTest { d2, filterPresenter, dhisProgramUtils, + dhis2TeiUtils, resourceManager, metadataIconProvider, scheduler, diff --git a/app/src/test/java/org/dhis2/usescases/main/program/ProgramViewModelTest.kt b/app/src/test/java/org/dhis2/usescases/main/program/ProgramViewModelTest.kt index fe4e7767af..78c88b39ba 100644 --- a/app/src/test/java/org/dhis2/usescases/main/program/ProgramViewModelTest.kt +++ b/app/src/test/java/org/dhis2/usescases/main/program/ProgramViewModelTest.kt @@ -2,6 +2,9 @@ package org.dhis2.usescases.main.program import androidx.arch.core.executor.testing.InstantTaskExecutorRule import io.reactivex.Flowable +import io.reactivex.processors.FlowableProcessor +import io.reactivex.processors.PublishProcessor +import io.reactivex.schedulers.TestScheduler import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -9,8 +12,10 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.setMain import org.dhis2.commons.featureconfig.data.FeatureConfigRepository +import org.dhis2.commons.filters.FilterManager import org.dhis2.commons.matomo.MatomoAnalyticsController import org.dhis2.commons.viewmodel.DispatcherProvider +import org.dhis2.data.schedulers.TestSchedulerProvider import org.dhis2.data.service.SyncStatusController import org.dhis2.data.service.SyncStatusData import org.dhis2.ui.MetadataIconData @@ -43,6 +48,8 @@ class ProgramViewModelTest { private val view: ProgramView = mock() private val programRepository: ProgramRepository = mock() private val matomoAnalyticsController: MatomoAnalyticsController = mock() + private val filterManager: FilterManager = mock() + private val schedulerProvider: TestSchedulerProvider = TestSchedulerProvider(TestScheduler()) private val syncStatusController: SyncStatusController = mock() private val testingDispatcher = UnconfinedTestDispatcher() private val featureConfigRepository: FeatureConfigRepository = mock { @@ -70,8 +77,11 @@ class ProgramViewModelTest { programRepository, featureConfigRepository, dispatcherProvider, + matomoAnalyticsController, + filterManager, syncStatusController, + schedulerProvider, ) } @@ -79,7 +89,12 @@ class ProgramViewModelTest { fun `Should initialize program list`() { val programs = listOf(programViewModel()) val programsFlowable = Flowable.just(programs) + val filterProcessor: FlowableProcessor = PublishProcessor.create() + val syncStatusData = SyncStatusData(true) + val filterManagerFlowable = Flowable.just(filterManager).startWith(filterProcessor) + + whenever(filterManager.asFlowable()) doReturn filterManagerFlowable whenever( syncStatusController.observeDownloadProcess(), @@ -149,6 +164,8 @@ class ProgramViewModelTest { downloadState = ProgramDownloadState.NONE, stockConfig = null, lastUpdated = Date(), + hasOverdueEvent = false, + filtersAreActive = false, ) } @@ -176,6 +193,8 @@ class ProgramViewModelTest { downloadState = ProgramDownloadState.NONE, stockConfig = null, lastUpdated = Date(), + hasOverdueEvent = false, + filtersAreActive = false, ) } } diff --git a/app/src/test/java/org/dhis2/usescases/teiDashboard/teiProgramList/TeiProgramListPresenterTest.kt b/app/src/test/java/org/dhis2/usescases/teiDashboard/teiProgramList/TeiProgramListPresenterTest.kt index 872946e1cb..9b6e696f9d 100644 --- a/app/src/test/java/org/dhis2/usescases/teiDashboard/teiProgramList/TeiProgramListPresenterTest.kt +++ b/app/src/test/java/org/dhis2/usescases/teiDashboard/teiProgramList/TeiProgramListPresenterTest.kt @@ -175,6 +175,8 @@ class TeiProgramListPresenterTest { downloadState = ProgramDownloadState.NONE, stockConfig = null, lastUpdated = Date(), + filtersAreActive = false, + hasOverdueEvent = false, ) }