-
Notifications
You must be signed in to change notification settings - Fork 2
MS-989 SimFace in dev builds only #1203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /build | ||
| !/src/release/java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...er/src/debug/java/com/simprints/face/infra/biosdkresolver/ResolveSimFaceVersionUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.simprints.face.infra.biosdkresolver | ||
|
|
||
| import javax.inject.Inject | ||
|
|
||
| /** | ||
| * At the moment this is just a wrapper to make it simpler to stub it in different source sets. | ||
| * In future we could actually need custom resolution logic. | ||
| */ | ||
| internal class ResolveSimFaceVersionUseCase @Inject constructor( | ||
| private val simFaceBioSdk: SimFaceBioSdk, | ||
| ) { | ||
| operator fun invoke(): FaceBioSDK = simFaceBioSdk | ||
| } |
File renamed without changes.
22 changes: 5 additions & 17 deletions
22
...esolver/src/main/java/com/simprints/face/infra/biosdkresolver/ResolveFaceBioSdkUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,16 @@ | ||
| package com.simprints.face.infra.biosdkresolver | ||
|
|
||
| import com.simprints.infra.config.store.ConfigRepository | ||
| import com.simprints.infra.config.store.models.FaceConfiguration | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
|
|
||
| @Singleton | ||
| class ResolveFaceBioSdkUseCase @Inject constructor( | ||
| private val configRepository: ConfigRepository, | ||
| private val rocV1BioSdk: RocV1BioSdk, | ||
| private val rocV3BioSdk: RocV3BioSdk, | ||
| private val simFaceBioSdk: SimFaceBioSdk, | ||
| class ResolveFaceBioSdkUseCase @Inject internal constructor( | ||
| private val resolveRankOneVersionUseCase: ResolveRankOneVersionUseCase, | ||
| private val resolveSimFaceVersionUseCase: ResolveSimFaceVersionUseCase, | ||
| ) { | ||
| suspend operator fun invoke(bioSdk: FaceConfiguration.BioSdk): FaceBioSDK = when (bioSdk) { | ||
| FaceConfiguration.BioSdk.SIM_FACE -> simFaceBioSdk | ||
| FaceConfiguration.BioSdk.RANK_ONE -> { | ||
| val version = configRepository | ||
| .getProjectConfiguration() | ||
| .face | ||
| ?.rankOne | ||
| ?.version | ||
| ?.takeIf { it.isNotBlank() } // Ensures version is not null or empty | ||
| requireNotNull(version) { "FaceBioSDK version is null or empty" } | ||
| if (version == rocV3BioSdk.version) rocV3BioSdk else rocV1BioSdk | ||
| } | ||
| FaceConfiguration.BioSdk.SIM_FACE -> resolveSimFaceVersionUseCase() | ||
| FaceConfiguration.BioSdk.RANK_ONE -> resolveRankOneVersionUseCase() | ||
| } | ||
| } | ||
21 changes: 21 additions & 0 deletions
21
...ver/src/main/java/com/simprints/face/infra/biosdkresolver/ResolveRankOneVersionUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.simprints.face.infra.biosdkresolver | ||
|
|
||
| import com.simprints.infra.config.store.ConfigRepository | ||
| import javax.inject.Inject | ||
|
|
||
| internal class ResolveRankOneVersionUseCase @Inject constructor( | ||
| private val configRepository: ConfigRepository, | ||
| private val rocV1BioSdk: RocV1BioSdk, | ||
| private val rocV3BioSdk: RocV3BioSdk, | ||
| ) { | ||
| suspend operator fun invoke(): FaceBioSDK { | ||
| val version = configRepository | ||
| .getProjectConfiguration() | ||
| .face | ||
| ?.rankOne | ||
| ?.version | ||
| ?.takeIf { it.isNotBlank() } // Ensures version is not null or empty | ||
| requireNotNull(version) { "FaceBioSDK version is null or empty" } | ||
| return if (version == rocV3BioSdk.version) rocV3BioSdk else rocV1BioSdk | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
.../src/release/java/com/simprints/face/infra/biosdkresolver/ResolveSimFaceVersionUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.simprints.face.infra.biosdkresolver | ||
|
|
||
| import javax.inject.Inject | ||
|
|
||
| /** | ||
| * Class interfaces in the different build types must be identical for it to work, | ||
| * therefore we have to stub the whole class for now. | ||
| */ | ||
| @ExcludedFromGeneratedTestCoverageReports("Stubs for build types") | ||
| internal class ResolveSimFaceVersionUseCase @Inject constructor( | ||
| private val simFaceBioSdk: SimFaceBioSdk, | ||
| ) { | ||
| operator fun invoke(): FaceBioSDK = TODO("SimFace is not available in release build") | ||
| } |
26 changes: 26 additions & 0 deletions
26
...io-sdk-resolver/src/release/java/com/simprints/face/infra/biosdkresolver/SimFaceBioSdk.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.simprints.face.infra.biosdkresolver | ||
|
|
||
| import com.simprints.face.infra.basebiosdk.matching.FaceMatcher | ||
| import com.simprints.face.infra.basebiosdk.matching.FaceSample | ||
| import javax.inject.Inject | ||
|
|
||
| /** | ||
| * Class interfaces in the different build types must be identical for it to work, | ||
| * therefore we have to stub the whole class for now. | ||
| */ | ||
| @ExcludedFromGeneratedTestCoverageReports("Stubs for build types") | ||
| @Singleton | ||
| class SimFaceBioSdk @Inject constructor() : FaceBioSDK { | ||
| override val initializer: FaceBioSdkInitializer | ||
| get() = TODO() | ||
| override val detector: FaceDetector | ||
| get() = TODO() | ||
| override val version: String | ||
| get() = TODO() | ||
| override val templateFormat: String | ||
| get() = TODO() | ||
| override val matcherName: String | ||
| get() = TODO() | ||
|
|
||
| override fun createMatcher(probeSamples: List<FaceSample>): FaceMatcher = TODO() | ||
| } |
15 changes: 15 additions & 0 deletions
15
.../src/staging/java/com/simprints/face/infra/biosdkresolver/ResolveSimFaceVersionUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.simprints.face.infra.biosdkresolver | ||
|
|
||
| import com.simprints.core.ExcludedFromGeneratedTestCoverageReports | ||
| import javax.inject.Inject | ||
|
|
||
| /** | ||
| * Class interfaces in the different build types must be identical for it to work, | ||
| * therefore we have to stub the whole class for now. | ||
| */ | ||
| @ExcludedFromGeneratedTestCoverageReports("Stubs for build types") | ||
| internal class ResolveSimFaceVersionUseCase @Inject constructor( | ||
| private val simFaceBioSdk: SimFaceBioSdk, | ||
| ) { | ||
| operator fun invoke(): FaceBioSDK = TODO("SimFace is not available in staging build") | ||
| } |
30 changes: 30 additions & 0 deletions
30
...io-sdk-resolver/src/staging/java/com/simprints/face/infra/biosdkresolver/SimFaceBioSdk.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.simprints.face.infra.biosdkresolver | ||
|
|
||
| import com.simprints.core.ExcludedFromGeneratedTestCoverageReports | ||
| import com.simprints.face.infra.basebiosdk.detection.FaceDetector | ||
| import com.simprints.face.infra.basebiosdk.initialization.FaceBioSdkInitializer | ||
| import com.simprints.face.infra.basebiosdk.matching.FaceMatcher | ||
| import com.simprints.face.infra.basebiosdk.matching.FaceSample | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
|
|
||
| /** | ||
| * Class interfaces in the different build types must be identical for it to work, | ||
| * therefore we have to stub the whole class for now. | ||
| */ | ||
| @ExcludedFromGeneratedTestCoverageReports("Stubs for build types") | ||
| @Singleton | ||
| class SimFaceBioSdk @Inject constructor() : FaceBioSDK { | ||
| override val initializer: FaceBioSdkInitializer | ||
| get() = TODO() | ||
| override val detector: FaceDetector | ||
| get() = TODO() | ||
| override val version: String | ||
| get() = TODO() | ||
| override val templateFormat: String | ||
| get() = TODO() | ||
| override val matcherName: String | ||
| get() = TODO() | ||
|
|
||
| override fun createMatcher(probeSamples: List<FaceSample>): FaceMatcher = TODO() | ||
| } |
106 changes: 23 additions & 83 deletions
106
...ver/src/test/java/com/simprints/face/infra/biosdkresolver/ResolveFaceBioSdkUseCaseTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,108 +1,48 @@ | ||
| package com.simprints.face.infra.biosdkresolver | ||
|
|
||
| import com.google.common.truth.Truth.* | ||
| import com.simprints.infra.config.store.ConfigRepository | ||
| import com.simprints.infra.config.store.models.FaceConfiguration | ||
| import io.mockk.* | ||
| import io.mockk.impl.annotations.MockK | ||
| import kotlinx.coroutines.test.runTest | ||
| import org.junit.Before | ||
| import org.junit.Test | ||
|
|
||
| class ResolveFaceBioSdkUseCaseTest { | ||
| private lateinit var resolveFaceBioSdkUseCase: ResolveFaceBioSdkUseCase | ||
| private val configRepository: ConfigRepository = mockk() | ||
| private lateinit var rocV1BioSdk: RocV1BioSdk | ||
| private lateinit var rocV3BioSdk: RocV3BioSdk | ||
| private lateinit var simFaceBioSdk: SimFaceBioSdk | ||
|
|
||
| @Before | ||
| fun setUp() { | ||
| rocV1BioSdk = RocV1BioSdk(mockk(), mockk()) | ||
| rocV3BioSdk = RocV3BioSdk(mockk(), mockk()) | ||
| simFaceBioSdk = SimFaceBioSdk(mockk(), mockk(), mockk(relaxed = true)) | ||
| @MockK | ||
| private lateinit var resolveRankOneVersionUseCase: ResolveRankOneVersionUseCase | ||
|
|
||
| resolveFaceBioSdkUseCase = ResolveFaceBioSdkUseCase(configRepository, rocV1BioSdk, rocV3BioSdk, simFaceBioSdk) | ||
| } | ||
|
|
||
| @Test | ||
| fun `return SimFace SDK when requested`() = runTest { | ||
| // When | ||
| val result = resolveFaceBioSdkUseCase.invoke(FaceConfiguration.BioSdk.SIM_FACE) | ||
|
|
||
| // Then | ||
| assertThat(result).isEqualTo(simFaceBioSdk) | ||
| } | ||
| @MockK | ||
| private lateinit var rocBioSdk: RocV1BioSdk | ||
|
|
||
| @Test(expected = IllegalArgumentException::class) | ||
| fun `throw exception when RankOne version is null`() = runTest { | ||
| // Given | ||
| coEvery { | ||
| configRepository | ||
| .getProjectConfiguration() | ||
| .face | ||
| ?.rankOne | ||
| ?.version | ||
| } returns null | ||
| @MockK | ||
| private lateinit var resolveSimFaceVersionUseCase: ResolveSimFaceVersionUseCase | ||
|
|
||
| // When | ||
| resolveFaceBioSdkUseCase.invoke(FaceConfiguration.BioSdk.RANK_ONE) | ||
| @MockK | ||
| private lateinit var simFaceBioSdk: SimFaceBioSdk | ||
|
|
||
| // Then: Expect IllegalArgumentException to be thrown | ||
| } | ||
| private lateinit var resolveFaceBioSdkUseCase: ResolveFaceBioSdkUseCase | ||
|
|
||
| @Test(expected = IllegalArgumentException::class) | ||
| fun `throw exception when RankOne version is empty`() = runTest { | ||
| // Given | ||
| coEvery { | ||
| configRepository | ||
| .getProjectConfiguration() | ||
| .face | ||
| ?.rankOne | ||
| ?.version | ||
| } returns "" | ||
| @Before | ||
| fun setUp() { | ||
| MockKAnnotations.init(this, relaxed = true) | ||
|
|
||
| // When | ||
| resolveFaceBioSdkUseCase.invoke(FaceConfiguration.BioSdk.RANK_ONE) | ||
| coEvery { resolveRankOneVersionUseCase() } returns rocBioSdk | ||
| coEvery { resolveSimFaceVersionUseCase() } returns simFaceBioSdk | ||
|
|
||
| // Then: Expect IllegalArgumentException to be thrown | ||
| resolveFaceBioSdkUseCase = ResolveFaceBioSdkUseCase( | ||
| resolveRankOneVersionUseCase, | ||
| resolveSimFaceVersionUseCase, | ||
| ) | ||
| } | ||
|
|
||
| // Given that version is valid and matches ROC V3 | ||
| @Test | ||
| fun `return ROC V3 SDK when version is valid and matches ROC V3`() = runTest { | ||
| // Given | ||
|
|
||
| coEvery { | ||
| configRepository | ||
| .getProjectConfiguration() | ||
| .face | ||
| ?.rankOne | ||
| ?.version | ||
| } returns rocV3BioSdk.version | ||
|
|
||
| // When | ||
| val result = resolveFaceBioSdkUseCase.invoke(FaceConfiguration.BioSdk.RANK_ONE) | ||
|
|
||
| // Then | ||
| assertThat(result).isEqualTo(rocV3BioSdk) | ||
| fun `return SimFace SDK when requested`() = runTest { | ||
| assertThat(resolveFaceBioSdkUseCase.invoke(FaceConfiguration.BioSdk.SIM_FACE)).isEqualTo(simFaceBioSdk) | ||
| } | ||
|
|
||
| // Given that version is valid and does not match ROC V3 (should match ROC V1) | ||
| @Test | ||
| fun `return ROC V1 SDK when version is valid and does not match ROC V3`() = runTest { | ||
| // Given | ||
| coEvery { | ||
| configRepository | ||
| .getProjectConfiguration() | ||
| .face | ||
| ?.rankOne | ||
| ?.version | ||
| } returns rocV1BioSdk.version | ||
|
|
||
| // When | ||
| val result = resolveFaceBioSdkUseCase.invoke(FaceConfiguration.BioSdk.RANK_ONE) | ||
|
|
||
| // Then | ||
| assertThat(result).isEqualTo(rocV1BioSdk) | ||
| fun `return RankOne SDK when requested`() = runTest { | ||
| assertThat(resolveFaceBioSdkUseCase.invoke(FaceConfiguration.BioSdk.RANK_ONE)).isEqualTo(rocBioSdk) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a matter of preference but do we really need to extract something as simple as the version resolving? It seems the overhead is higher than the code itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not necessary, but it has the benefit of isolating each SDK's logic.
Honestly, I was just trying a lot of things to minimise the amount of classes that we would need to duplicate per build type and this is a by-product of the experimentation. We can simplify it when the need for build types is gone.