From 215b140325896ccfc60874ad51fdb61a1727d7c5 Mon Sep 17 00:00:00 2001 From: Sergejs Luhmirins Date: Mon, 24 Feb 2025 13:05:28 +0200 Subject: [PATCH] MS-885 Do not add verification success flag when threshold is not enabled --- .../response/LibSimprintsResponseMapper.kt | 5 ++-- .../LibSimprintsResponseMapperTest.kt | 30 +++++++++++++++++-- gradle/libs.versions.toml | 2 +- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/feature/client-api/src/main/java/com/simprints/feature/clientapi/mappers/response/LibSimprintsResponseMapper.kt b/feature/client-api/src/main/java/com/simprints/feature/clientapi/mappers/response/LibSimprintsResponseMapper.kt index e713cc0954..f7e8908bc3 100644 --- a/feature/client-api/src/main/java/com/simprints/feature/clientapi/mappers/response/LibSimprintsResponseMapper.kt +++ b/feature/client-api/src/main/java/com/simprints/feature/clientapi/mappers/response/LibSimprintsResponseMapper.kt @@ -74,7 +74,8 @@ internal class LibSimprintsResponseMapper @Inject constructor() { guid = response.matchResult.guid, ), ) - putBoolean(Constants.SIMPRINTS_VERIFICATION_SUCCESS, response.matchResult.verificationSuccess == true) + response.matchResult.verificationSuccess + ?.let { putBoolean(Constants.SIMPRINTS_VERIFICATION_SUCCESS, it) } } else -> putString( @@ -83,7 +84,7 @@ internal class LibSimprintsResponseMapper @Inject constructor() { guid = response.matchResult.guid, confidence = response.matchResult.confidenceScore.toFloat(), confidenceBand = ConfidenceBand.valueOf(response.matchResult.matchConfidence.name), - isSuccess = response.matchResult.verificationSuccess == true, + isSuccess = response.matchResult.verificationSuccess, ).toJson(), ) } diff --git a/feature/client-api/src/test/java/com/simprints/feature/clientapi/mappers/response/LibSimprintsResponseMapperTest.kt b/feature/client-api/src/test/java/com/simprints/feature/clientapi/mappers/response/LibSimprintsResponseMapperTest.kt index 951930e4d2..2bcf3727f3 100644 --- a/feature/client-api/src/test/java/com/simprints/feature/clientapi/mappers/response/LibSimprintsResponseMapperTest.kt +++ b/feature/client-api/src/test/java/com/simprints/feature/clientapi/mappers/response/LibSimprintsResponseMapperTest.kt @@ -153,7 +153,7 @@ class LibSimprintsResponseMapperTest { assertThat(extraVerification?.tier).isEqualTo(LegacyTier.TIER_1) assertThat(extraVerification?.getConfidence()).isEqualTo(50) assertThat(extras.getBoolean(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK)).isTrue() - assertThat(extras.getBoolean(Constants.SIMPRINTS_VERIFICATION_SUCCESS)).isFalse() // Default value + assertThat(extras.keySet()).doesNotContain(Constants.SIMPRINTS_VERIFICATION_SUCCESS) } @Test @@ -179,6 +179,7 @@ class LibSimprintsResponseMapperTest { assertThat(extraVerification?.tier).isEqualTo(LegacyTier.TIER_1) assertThat(extraVerification?.getConfidence()).isEqualTo(50) assertThat(extras.getBoolean(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK)).isTrue() + assertThat(extras.keySet()).contains(Constants.SIMPRINTS_VERIFICATION_SUCCESS) assertThat(extras.getBoolean(Constants.SIMPRINTS_VERIFICATION_SUCCESS)).isEqualTo(false) } @@ -204,7 +205,6 @@ class LibSimprintsResponseMapperTest { assertThat(extraVerification?.guid).isEqualTo("guid") assertThat(extraVerification?.tier).isEqualTo(LegacyTier.TIER_1) assertThat(extraVerification?.getConfidence()).isEqualTo(50) - // assertThat(extraVerification?.isSuccess).isTrue() assertThat(extras.getBoolean(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK)).isTrue() assertThat(extras.getBoolean(Constants.SIMPRINTS_VERIFICATION_SUCCESS)).isTrue() } @@ -235,6 +235,32 @@ class LibSimprintsResponseMapperTest { assertThat(extras.getBoolean(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK)).isTrue() } + @Test + fun `correctly maps verify response without success after LibSimprints refactoring`() { + val extras = mapper( + ActionResponse.VerifyActionResponse( + actionIdentifier = VerifyActionFactory + .getIdentifier() + .copy(contractVersion = VersionsList.INITIAL_REWORK), + sessionId = "sessionId", + matchResult = AppMatchResult( + guid = "guid", + confidenceScore = 50, + matchConfidence = AppMatchConfidence.HIGH, + verificationSuccess = null, + ), + ), + ) + + assertThat(extras.getString(Constants.SIMPRINTS_SESSION_ID)).isEqualTo("sessionId") + assertThat(extras.getString(Constants.SIMPRINTS_VERIFICATION)).isEqualTo( + """ + {"guid":"guid","confidenceBand":"HIGH","confidence":50} + """.trimIndent(), + ) + assertThat(extras.getBoolean(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK)).isTrue() + } + @Test fun `correctly maps exit form response`() { val extras = mapper( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 56d660f871..d502c1c04a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -63,7 +63,7 @@ circleImageView_version = "3.1.0" kermit_version = "2.0.5" zip4j_version = "2.11.5" -libsimprints_version = "2025.1.2-SNAPSHOT" +libsimprints_version = "2025.1.3-SNAPSHOT" simmatcher_version = "1.2.0" roc_wrapper_version = "1.23.0" roc_wrapper-v3_version = "3.1.0"