Skip to content

Commit

Permalink
- fix tests
Browse files Browse the repository at this point in the history
- do not suppress warnings
  • Loading branch information
Balcan committed Dec 13, 2024
1 parent e757331 commit 5e84545
Show file tree
Hide file tree
Showing 23 changed files with 9 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.dhis2.commons.viewmodel.DispatcherProvider
import org.dhis2.usescases.datasets.dataSetTable.DataSetTableContract.View
import org.dhis2.utils.analytics.AnalyticsHelper

@Suppress("UNCHECKED_CAST")
class DataSetTableViewModelFactory(
private val view: View,
private val dataSetTableRepository: DataSetTableRepositoryImpl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import org.dhis2.commons.viewmodel.DispatcherProvider

@Suppress("UNCHECKED_CAST")
class DataSetDetailViewModelFactory(
private val dispatcherProvider: DispatcherProvider,
private val dataSetPageConfigurator: DataSetPageConfigurator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.dhis2.commons.schedulers.SchedulerProvider
import org.dhis2.commons.viewmodel.DispatcherProvider
import org.dhis2.usescases.datasets.datasetDetail.DataSetDetailRepository

@Suppress("UNCHECKED_CAST")
class DataSetListViewModelFactory(
val dataSetDetailRepository: DataSetDetailRepository,
val schedulerProvider: SchedulerProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.domain.CreateO
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.providers.EventDetailResourcesProvider
import org.hisp.dhis.android.core.period.PeriodType

@Suppress("UNCHECKED_CAST")
class EventDetailsViewModelFactory(
private val configureEventDetails: ConfigureEventDetails,
private val configureEventReportDate: ConfigureEventReportDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.dhis2.data.biometric.BiometricController
import org.dhis2.data.server.UserManager
import org.dhis2.utils.analytics.AnalyticsHelper

@Suppress("UNCHECKED_CAST")
class LoginViewModelFactory(
private val view: LoginContracts.View,
private val preferenceProvider: PreferenceProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.dhis2.usescases.login.accounts
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

@Suppress("UNCHECKED_CAST")
class AccountsViewModelFactory(
val repository: AccountRepository,
) : ViewModelProvider.Factory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.dhis2.commons.matomo.MatomoAnalyticsController
import org.dhis2.commons.viewmodel.DispatcherProvider
import org.dhis2.data.service.SyncStatusController

@Suppress("UNCHECKED_CAST")
class ProgramViewModelFactory(
private val view: ProgramView,
private val programRepository: ProgramRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.dhis2.maps.usecases.MapStyleConfiguration
import org.dhis2.tracker.events.CreateEventUseCase
import org.dhis2.utils.customviews.navigationbar.NavigationPageConfigurator

@Suppress("UNCHECKED_CAST")
class ProgramEventDetailViewModelFactory(
private val mapStyleConfiguration: MapStyleConfiguration,
private val eventRepository: ProgramEventDetailRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.dhis2.usescases.programEventDetail.ProgramEventDetailRepository
import org.dhis2.usescases.programEventDetail.ProgramEventMapper
import org.dhis2.usescases.programEventDetail.eventList.ui.mapper.EventCardMapper

@Suppress("UNCHECKED_CAST")
class EventListPresenterFactory(
private val filterManager: FilterManager,
private val programEventDetailRepository: ProgramEventDetailRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.dhis2.commons.viewmodel.DispatcherProvider
import org.dhis2.form.ui.provider.DisplayNameProvider
import org.dhis2.maps.usecases.MapStyleConfiguration

@Suppress("UNCHECKED_CAST")
class SearchTeiViewModelFactory(
private val searchRepository: SearchRepository,
private val searchRepositoryKt: SearchRepositoryKt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.dhis2.commons.viewmodel.DispatcherProvider
import org.dhis2.utils.analytics.AnalyticsHelper
import org.dhis2.utils.customviews.navigationbar.NavigationPageConfigurator

@Suppress("UNCHECKED_CAST")
class DashboardViewModelFactory(
val repository: DashboardRepository,
val analyticsHelper: AnalyticsHelper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.dhis2.commons.resources.ResourceManager
import org.dhis2.commons.viewmodel.DispatcherProvider
import org.hisp.dhis.android.core.D2

@Suppress("UNCHECKED_CAST")
class SchedulingViewModelFactory @AssistedInject constructor(
private val d2: D2,
private val resourceManager: ResourceManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import org.dhis2.commons.resources.LocaleSelector

@Suppress("UNCHECKED_CAST")
class TroubleshootingViewModelFactory(
private val localeSelector: LocaleSelector,
private val troubleshootingRepository: TroubleshootingRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.dhis2.commons.viewmodel.DispatcherProvider
import org.dhis2.data.service.workManager.WorkManagerController
import org.hisp.dhis.android.core.D2

@Suppress("UNCHECKED_CAST")
class GranularSyncViewModelFactory(
private val d2: D2,
private val view: GranularSyncContracts.View,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import org.dhis2.commons.featureconfig.data.FeatureConfigRepository

@Suppress("UNCHECKED_CAST")
class FeatureConfigViewModelFactory(val repository: FeatureConfigRepository) :
ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import org.dhis2.commons.filters.data.FilterRepository

@Suppress("UNCHECKED_CAST")
class WorkingListViewModelFactory(
private val programUid: String?,
private val filterRepository: FilterRepository,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.dhis2.composetable

import androidx.compose.material.lightColors
import androidx.compose.ui.test.junit4.createComposeRule
import org.dhis2.composetable.model.FakeModelType
import org.dhis2.composetable.ui.TableColors
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.junit.Rule
import org.junit.Test

Expand Down Expand Up @@ -34,7 +34,7 @@ class ColumnTableTest {
val firstTableId = fakeModel[0].id!!

clickOnHeaderElement(firstTableId, 2, 3)
assertColumnHeaderBackgroundColor(firstTableId, 2, 3, lightColors().primary)
assertColumnHeaderBackgroundColor(firstTableId, 2, 3, SurfaceColor.Primary)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package org.dhis2.composetable

import androidx.compose.material.lightColors
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.test.junit4.createComposeRule
import org.dhis2.composetable.model.FakeModelType
import org.dhis2.composetable.model.FakeTableModels
import org.dhis2.composetable.ui.TableColors
import org.junit.Before
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.junit.Rule
import org.junit.Test

Expand All @@ -16,8 +13,6 @@ class RowTableTest {
val composeTestRule = createComposeRule()
private val tableColors = TableColors()

var primaryColor: Color = lightColors().primary

@Test
fun shouldClickOnFirstRowElementAndHighlightAllElements() {
tableRobot(composeTestRule) {
Expand All @@ -29,7 +24,7 @@ class RowTableTest {
assertRowHeaderBackgroundChangeToPrimary(
firstTableId,
0,
primaryColor.let { tableColors.copy(primary = it) } ?: tableColors
tableColors.copy(primary = SurfaceColor.Primary)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ import org.dhis2.composetable.ui.semantics.RowIndexHeader
import org.dhis2.composetable.ui.semantics.TableId
import org.dhis2.composetable.ui.semantics.TableIdColumnHeader
import org.dhis2.composetable.utils.KeyboardHelper
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor
import org.junit.Assert

fun tableRobot(
Expand Down Expand Up @@ -103,7 +105,7 @@ class TableRobot(
mutableStateOf<TableSelection>(TableSelection.Unselected())
}
TableTheme(
tableColors = TableColors().copy(primary = MaterialTheme.colorScheme.primary),
tableColors = tableColors.copy(primary = SurfaceColor.Primary),
tableConfiguration = TableConfiguration(headerActionsEnabled = false),
tableResizeActions = object : TableResizeActions {}
) {
Expand Down Expand Up @@ -140,7 +142,7 @@ class TableRobot(
keyboardHelper.view = LocalView.current
var model by remember { mutableStateOf(screenState) }
TableTheme(
tableColors = TableColors().copy(primary = MaterialTheme.colorScheme.primary),
tableColors = TableColors().copy(primary = SurfaceColor.Primary),
tableConfiguration = tableConfiguration,
tableResizeActions = object : TableResizeActions {}
) {
Expand Down Expand Up @@ -277,7 +279,7 @@ class TableRobot(
composeTestRule.onNode(
SemanticsMatcher.expectValue(TableId, tableId)
.and(SemanticsMatcher.expectValue(RowIndex, rowIndex))
.and(SemanticsMatcher.expectValue(RowBackground, tableColors.primary))
.and(SemanticsMatcher.expectValue(RowBackground, SurfaceColor.Primary))
).assertExists()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.hisp.dhis.android.core.D2Manager
import org.hisp.dhis.android.core.common.FeatureType

object Injector {
@Suppress("UNCHECKED_CAST")
fun provideMapSelectorViewModelFactory(
context: Context,
locationType: FeatureType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.lifecycle.ViewModelProvider
import dhis2.org.analytics.charts.Charts
import org.dhis2.commons.matomo.MatomoAnalyticsController

@Suppress("UNCHECKED_CAST")
class GroupAnalyticsViewModelFactory(
private val mode: AnalyticMode,
private val uid: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.lifecycle.ViewModelProvider
import org.dhis2.commons.viewmodel.DispatcherProvider
import org.dhis2.form.data.FormRepository

@Suppress("UNCHECKED_CAST")
class FormViewModelFactory(
private val repository: FormRepository,
private val dispatcher: DispatcherProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.dhis2.form.ui.dialog
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

@Suppress("UNCHECKED_CAST")
class QRImageViewModelFactory : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return QRImageViewModel(QRImageControllerImpl()) as T
Expand Down

0 comments on commit 5e84545

Please sign in to comment.