Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
feature:setup
feature:enrol-last-biometric
feature:matcher
feature:validate-subject-pool
reportsId: feature2

feature-dashboard-unit-tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ internal class SyncViewModelTest {

@Test
fun `should initialize the live data syncToBFSIDAllowed correctly`() {
syncState.postValue(EventSyncState("", 0, 0, listOf(), listOf()))
syncState.postValue(EventSyncState("", 0, 0, listOf(), listOf(), listOf()))
isConnected.postValue(true)

val viewModel = initViewModel()
Expand Down Expand Up @@ -155,7 +155,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Running
)
), listOf()
), listOf(), listOf()
)
isConnected.value = true

Expand Down Expand Up @@ -200,7 +200,7 @@ internal class SyncViewModelTest {
fun `should post a SyncDefault card state if there is no sync history`() {
coEvery { configManager.getDeviceConfiguration() } returns deviceConfiguration
isConnected.value = true
syncState.value = EventSyncState("", 0, 0, listOf(), listOf())
syncState.value = EventSyncState("", 0, 0, listOf(), listOf(), listOf())
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

assertThat(syncCardLiveData).isEqualTo(SyncDefault(DATE))
Expand All @@ -217,7 +217,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Succeeded
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -236,7 +236,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Succeeded
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -254,7 +254,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Running
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -272,7 +272,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Enqueued
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -289,7 +289,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Failed(failedBecauseTooManyRequest = true)
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -306,7 +306,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Failed(failedBecauseCloudIntegration = true)
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -323,7 +323,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Failed(failedBecauseReloginRequired = true)
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand Down Expand Up @@ -369,7 +369,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Failed(failedBecauseBackendMaintenance = true)
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -389,7 +389,7 @@ internal class SyncViewModelTest {
estimatedOutage = 30
)
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -407,7 +407,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Failed()
)
)
), listOf()
)
val syncCardLiveData = initViewModel().syncCardLiveData.getOrAwaitValue()

Expand All @@ -426,7 +426,7 @@ internal class SyncViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Succeeded
)
)
), listOf()
)
val viewModel = initViewModel()
viewModel.syncCardLiveData.getOrAwaitValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ class SyncInfoViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Running
)
)
),
reporterStates = listOf(),
)
)

Expand All @@ -286,7 +287,8 @@ class SyncInfoViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Succeeded
)
)
),
reporterStates = listOf(),
)
)

Expand All @@ -306,7 +308,8 @@ class SyncInfoViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Succeeded
)
)
),
reporterStates = listOf(),
)

viewModel.fetchSyncInformationIfNeeded(state)
Expand Down Expand Up @@ -362,7 +365,7 @@ class SyncInfoViewModelTest {
)
}
viewModel.refreshInformation()
stateLiveData.value = EventSyncState("", 0, 0, emptyList(), emptyList())
stateLiveData.value = EventSyncState("", 0, 0, emptyList(), emptyList(), emptyList())

connectionLiveData.value = false
assertThat(viewModel.isSyncAvailable.getOrAwaitValue()).isFalse()
Expand All @@ -382,7 +385,7 @@ class SyncInfoViewModelTest {
viewModel.refreshInformation()
connectionLiveData.value = true

stateLiveData.value = EventSyncState("", 0, 0, emptyList(), emptyList())
stateLiveData.value = EventSyncState("", 0, 0, emptyList(), emptyList(), emptyList())
assertThat(viewModel.isSyncAvailable.getOrAwaitValue()).isTrue()

stateLiveData.value = EventSyncState(
Expand All @@ -395,7 +398,8 @@ class SyncInfoViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Running
)
)
),
reporterStates = listOf(),
)
assertThat(viewModel.isSyncAvailable.getOrAwaitValue()).isFalse()

Expand All @@ -409,7 +413,8 @@ class SyncInfoViewModelTest {
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Succeeded
)
)
),
reporterStates = listOf(),
)
assertThat(viewModel.isSyncAvailable.getOrAwaitValue()).isTrue()
}
Expand All @@ -423,7 +428,7 @@ class SyncInfoViewModelTest {
}
viewModel.refreshInformation()
connectionLiveData.value = true
stateLiveData.value = EventSyncState("", 0, 0, emptyList(), emptyList())
stateLiveData.value = EventSyncState("", 0, 0, emptyList(), emptyList(), emptyList())

assertThat(viewModel.isSyncAvailable.getOrAwaitValue()).isTrue()
}
Expand All @@ -438,7 +443,7 @@ class SyncInfoViewModelTest {
}
viewModel.refreshInformation()
connectionLiveData.value = true
stateLiveData.value = EventSyncState("", 0, 0, emptyList(), emptyList())
stateLiveData.value = EventSyncState("", 0, 0, emptyList(), emptyList(), emptyList())

assertThat(viewModel.isSyncAvailable.getOrAwaitValue()).isFalse()
}
Expand All @@ -447,12 +452,14 @@ class SyncInfoViewModelTest {
fun `emit ReloginRequired = false when lastSyncState updates with different status`() =
runTest {
stateLiveData.value = EventSyncState(
"", 0, 0, listOf(), listOf(
"", 0, 0, listOf(),
listOf(
EventSyncState.SyncWorkerInfo(
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Failed(failedBecauseBackendMaintenance = true)
)
)
),
reporterStates = listOf(),
)

assertThat(viewModel.isReloginRequired.getOrAwaitValue()).isFalse()
Expand All @@ -461,12 +468,14 @@ class SyncInfoViewModelTest {
@Test
fun `emit ReloginRequired = true when lastSyncState updates with such status`() = runTest {
stateLiveData.value = EventSyncState(
"", 0, 0, listOf(), listOf(
"", 0, 0, listOf(),
listOf(
EventSyncState.SyncWorkerInfo(
EventSyncWorkerType.DOWNLOADER,
EventSyncWorkerState.Failed(failedBecauseReloginRequired = true)
)
)
),
reporterStates = listOf(),
)

assertThat(viewModel.isReloginRequired.getOrAwaitValue()).isTrue()
Expand Down Expand Up @@ -504,6 +513,7 @@ class SyncInfoViewModelTest {
partitionType = partitionType,
moduleOptions = modules.map(String::asTokenizableRaw),
maxNbOfModules = 0,
maxAge = "PT24H",
)
)
}
Expand Down
1 change: 1 addition & 0 deletions feature/orchestrator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
implementation(project(":feature:select-subject"))
implementation(project(":feature:exit-form"))
implementation(project(":feature:matcher"))
implementation(project(":feature:validate-subject-pool"))

implementation(project(":face:capture"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.simprints.feature.logincheck.LoginCheckViewModel
import com.simprints.feature.orchestrator.cache.OrchestratorCache
import com.simprints.feature.selectsubject.SelectSubjectContract
import com.simprints.feature.setup.SetupContract
import com.simprints.feature.validatepool.ValidateSubjectPoolContract
import com.simprints.fingerprint.capture.FingerprintCaptureContract
import com.simprints.infra.orchestration.data.responses.AppConfirmationResponse
import com.simprints.infra.orchestration.data.responses.AppEnrolResponse
Expand Down Expand Up @@ -114,6 +115,7 @@ internal class OrchestratorFragment : Fragment(R.layout.fragment_orchestrator) {
handleResult(FaceCaptureContract.DESTINATION, orchestratorVm::handleResult)
handleResult(FingerprintCaptureContract.DESTINATION, orchestratorVm::handleResult)
handleResult(FetchSubjectContract.DESTINATION, orchestratorVm::handleResult)
handleResult(ValidateSubjectPoolContract.DESTINATION, orchestratorVm::handleResult)
}

private fun <T : Serializable> handleResult(destination: Int, block: (T) -> Unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ internal class OrchestratorViewModel @Inject constructor(

fun handleResult(result: Serializable) = viewModelScope.launch {
Simber.d(result.toString())

val errorResponse = mapRefusalOrErrorResult(result)
if (errorResponse != null) {
// Shortcut the flow execution if any refusal or error result is found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.simprints.feature.fetchsubject.FetchSubjectResult
import com.simprints.feature.login.LoginResult
import com.simprints.feature.selectsubject.SelectSubjectResult
import com.simprints.feature.setup.SetupResult
import com.simprints.feature.validatepool.ValidateSubjectPoolResult
import com.simprints.fingerprint.capture.FingerprintCaptureResult
import com.simprints.fingerprint.connect.FingerprintConnectResult
import com.simprints.matcher.FaceMatchResult
Expand Down Expand Up @@ -54,6 +55,7 @@ import java.io.Serializable
JsonSubTypes.Type(value = SelectSubjectResult::class, name = "SelectSubjectResult"),
JsonSubTypes.Type(value = AlertResult::class, name = "AlertResult"),
JsonSubTypes.Type(value = ExitFormResult::class, name = "ExitFormResult"),
JsonSubTypes.Type(value = ValidateSubjectPoolResult::class, name = "ValidateSubjectPoolResult"),
)
abstract class SerializableMixin : Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal object StepId {
const val CONSENT = STEP_BASE_CORE + 3
const val ENROL_LAST_BIOMETRIC = STEP_BASE_CORE + 4
const val CONFIRM_IDENTITY = STEP_BASE_CORE + 5
const val VALIDATE_ID_POOL = STEP_BASE_CORE + 6

// Face step ids
private const val STEP_BASE_FINGERPRINT = 300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import com.simprints.feature.alert.AlertResult
import com.simprints.feature.exitform.ExitFormResult
import com.simprints.feature.fetchsubject.FetchSubjectResult
import com.simprints.feature.setup.SetupResult
import com.simprints.feature.validatepool.ValidateSubjectPoolResult
import com.simprints.fingerprint.connect.FingerprintConnectResult
import com.simprints.infra.events.SessionEventRepository
import com.simprints.infra.orchestration.data.responses.AppErrorResponse
import com.simprints.infra.orchestration.data.responses.AppIdentifyResponse
import com.simprints.infra.orchestration.data.responses.AppRefusalResponse
import com.simprints.infra.orchestration.data.responses.AppResponse
import java.io.Serializable
import javax.inject.Inject

internal class MapRefusalOrErrorResultUseCase @Inject constructor() {
internal class MapRefusalOrErrorResultUseCase @Inject constructor(
private val eventRepository: SessionEventRepository,
) {

operator fun invoke(result: Serializable): AppResponse? = when (result) {
suspend operator fun invoke(result: Serializable): AppResponse? = when (result) {
is ExitFormResult -> AppRefusalResponse.fromResult(result)
is FetchSubjectResult -> result.takeUnless { it.found }?.let {
AppErrorResponse(
Expand All @@ -31,6 +36,9 @@ internal class MapRefusalOrErrorResultUseCase @Inject constructor() {

is AlertResult -> AppErrorResponse(result.appErrorReason ?: AppErrorReason.UNEXPECTED_ERROR)

is ValidateSubjectPoolResult -> result.takeUnless { it.isValid }
?.let { AppIdentifyResponse(emptyList(), eventRepository.getCurrentSessionScope().id) }

else -> null
}
}
Loading