Skip to content

feat: SDK-based biometric quality evaluation with SBI fallback - #785

Open
mishradev1 wants to merge 1 commit into
mosip:masterfrom
mishradev1:master
Open

feat: SDK-based biometric quality evaluation with SBI fallback#785
mishradev1 wants to merge 1 commit into
mosip:masterfrom
mishradev1:master

Conversation

@mishradev1

@mishradev1 mishradev1 commented May 9, 2026

Copy link
Copy Markdown

Problem

Currently, the registration client validates biometric quality using only the SBI-provided quality score compared against configurable thresholds. There is no support for SDK-based quality evaluation, which can provide more accurate and standardized quality assessment during biometric capture.

Solution

This PR enables SDK-based biometric quality evaluation during capture in the registration client, while maintaining seamless fallback to SBI quality scores when the SDK is disabled in configuration.

When SDK is enabled (mosip.registration.quality_check_with_sdk=Y):

  • SDK evaluates captured biometric quality in real time
  • SDK score replaces the SBI quality score for threshold validation
  • If SDK fails (timeout/exception/invalid score) → registration is blocked and operator is prompted to re-capture
  • No silent fallback to SBI — ensures quality integrity

When SDK is disabled (default behavior):

  • SBI quality score is used for threshold validation (existing behavior, unchanged)

Key Changes

File Change
BioServiceImpl.java Added evaluateQualityWithSdk() for SDK-based evaluation with timeout support, corrupt data detection, and audit logging
RegistrationExceptionConstants.java Added 8 new error codes for SDK evaluation scenarios (invalid score, timeout, no quality source, below threshold, partial capture, corrupt data, config error, audit failure)
RegistrationConstants.java Added SDK_QUALITY_EVALUATION_TIMEOUT configuration key
BioServiceTest.java Added 4 unit tests for SDK evaluation, SBI fallback, exception handling, and timeout configuration

How It Works

Biometric Capture (SBI)
        │
        ▼
   SDK Enabled? ──No──► Use SBI Score ──► Threshold Validation
        │
       Yes
        │
        ▼
  Evaluate with SDK
        │
   ┌────┼────────────┐
   ▼    ▼            ▼
 Valid  Invalid/    Timeout/
 Score  Null Score  Exception
   │    │            │
   ▼    ▼            ▼
 Replace Block +     Block +
 quality Prompt      Prompt
 Score   Re-capture  Re-capture
   │
   ▼
 Threshold Validation

Scenario Coverage

Scenario Condition System Behavior
SDK Quality Evaluation SDK available and valid SDK score used against existing threshold
SBI Fallback SDK disabled in config SBI score used against existing threshold
SDK Invalid Score SDK returns null/invalid Block registration, prompt re-capture
SDK Timeout SDK response delayed Block progression, prompt re-capture
SDK Exception Runtime/integration error Block registration, prompt re-capture
Corrupt Data Invalid biometric data Reject captured data, prompt re-capture
Quality Below Threshold Score below threshold Re-capture enforced

Configuration

Property Default Description
mosip.registration.quality_check_with_sdk N Enable/disable SDK-based quality evaluation
mosip.registration.sdk_quality_evaluation_timeout 10000 (ms) Timeout for SDK quality evaluation calls

Design Decisions

  1. SDK score replaces qualityScore field — When SDK succeeds, the SDK score is written to both sdkScore and qualityScore in BiometricsDto. This ensures the existing threshold validation logic in getCapturedBiometrics() and addAllBiometrics() works without modification, reusing the same configurable thresholds.

  2. No silent SBI fallback on SDK failure — Per the acceptance criteria, when SDK is configured but fails, the system blocks and prompts re-capture rather than silently falling back to SBI. This prevents potentially low-quality biometrics from being accepted.

  3. Configurable timeout with ExecutorService — SDK evaluation runs in a separate thread with configurable timeout to prevent UI freezing on SDK delays.

  4. Audit logging — All quality evaluations, fallbacks, and errors are logged for audit purposes via logAuditEvent().

Type of Change

  • New feature (non-breaking change which adds functionality)

Checklist

  • SDK-based biometric quality evaluation supported
  • SDK scores validated against existing configurable thresholds
  • SBI fallback triggered when SDK is disabled in configuration
  • Re-capture enforced when quality scores fall below threshold
  • Error handling for invalid SDK responses, timeouts, and exceptions
  • Registration blocked when biometric data is corrupt/invalid
  • All quality evaluations, fallbacks, and errors logged for audit
  • Unit tests added for new functionality
  • Existing tests unaffected

Related Issue

Fixes #770

Summary by CodeRabbit

Release Notes

  • New Features

    • Added SDK-based biometric quality evaluation with configurable timeout support for enhanced capture validation
    • Introduced comprehensive error handling for biometric quality evaluation scenarios, including timeout, invalid scores, corrupt data, and configuration issues
  • Tests

    • Added test coverage for SDK quality evaluation and timeout configuration functionality

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@mishradev1 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 34 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 248506fe-f344-4920-9086-b4a788ca59be

📥 Commits

Reviewing files that changed from the base of the PR and between d435aff and 8569ea2.

📒 Files selected for processing (4)
  • registration/registration-services/src/main/java/io/mosip/registration/constants/RegistrationConstants.java
  • registration/registration-services/src/main/java/io/mosip/registration/exception/RegistrationExceptionConstants.java
  • registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java
  • registration/registration-services/src/test/java/io/mosip/registration/bio/service/test/BioServiceTest.java

Walkthrough

This PR implements SDK-based biometric quality evaluation with SBI fallback in the registration client. It adds configuration-driven timeout enforcement, validates SDK scores against existing thresholds, introduces eight error scenarios for invalid scores and timeouts, and includes audit logging that does not interrupt capture flow.

Changes

SDK-Based Biometric Quality Evaluation Feature

Layer / File(s) Summary
Constants & Exception Definitions
registration/registration-services/src/main/java/io/mosip/registration/constants/RegistrationConstants.java, registration/registration-services/src/main/java/io/mosip/registration/exception/RegistrationExceptionConstants.java
Adds SDK_QUALITY_EVALUATION_TIMEOUT constant and eight exception codes: REG_BIOMETRIC_SDK_INVALID_SCORE, REG_BIOMETRIC_SDK_TIMEOUT, REG_BIOMETRIC_NO_QUALITY_SOURCE, REG_BIOMETRIC_QUALITY_BELOW_THRESHOLD, REG_BIOMETRIC_PARTIAL_CAPTURE, REG_BIOMETRIC_CORRUPT_DATA, REG_BIOMETRIC_CONFIG_ERROR, REG_BIOMETRIC_AUDIT_LOG_FAILURE.
Configuration & Initialization
registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java
Imports concurrent utilities, introduces DEFAULT_SDK_TIMEOUT_MS constant (5000ms), and adds isSdkQualityCheckEnabled() and getSdkTimeoutMs() configuration readers that resolve from ApplicationContext with fallback defaults.
Core SDK Evaluation Logic
registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java
evaluateQualityWithSdk() obtains SDK quality score, validates range, overwrites qualityScore, and throws specific exceptions for invalid scores or SDK errors. getSDKScoreWithTimeout() executes SDK evaluation in a single-thread executor to enforce configured timeout via Future.get().
Capture Flow Integration
registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java
captureModality() refactored to compute SDK enablement once, validate SBI quality and biometric ISO early, then branch: invoke SDK evaluation when enabled or continue with SBI score and audit logs when disabled.
Audit Logging
registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java
logAuditEvent() centralizes audit logging while catching and suppressing exceptions to prevent audit failures from interrupting biometric capture.
Tests & Validation
registration/registration-services/src/test/java/io/mosip/registration/bio/service/test/BioServiceTest.java
Four test methods validate SDK-enabled score evaluation, SDK-disabled fallback, BiometricException propagation, and SDK_QUALITY_EVALUATION_TIMEOUT configuration lookup with integer parsing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A biometric hop, now faster and tight,
SDK scores bring quality right,
With timeouts and fallbacks so fine,
Audit trails log each capture in line,
Registration now gleams, audit logs bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main feature: SDK-based biometric quality evaluation with SBI fallback, which matches the primary changes across all modified files.
Linked Issues check ✅ Passed The PR implements all primary objectives from issue #770: SDK-based quality evaluation, SBI fallback, timeout handling, error scenarios, exception codes, and audit logging are all present in the code changes.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing SDK-based biometric quality evaluation as defined in issue #770. No unrelated modifications were introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Signed-off-by: Dev Mishra <mishradev222004@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java`:
- Around line 181-190: The sdkScore is currently a primitive double from
getSDKScoreWithTimeout which will NPE if the SDK returned null; change handling
in BioServiceImpl:getSDKScoreWithTimeout() call site to use a boxed Double (or
keep double but first retrieve a Double) and explicitly check for null before
range validation — if null, log the error, call logAuditEvent("QUALITY_EVAL",
bioAttribute, "SDK_INVALID_SCORE", "SDK returned null score", null, "SDK") and
throw the REG_BIOMETRIC_SDK_INVALID_SCORE RegBaseCheckedException; if non-null
continue with the existing ValueRange validation and error path for out-of-range
values.
- Around line 122-125: In BioServiceImpl, change the SBI quality-score
validation so it only runs when sdkEnabled is false and use direct double
comparisons instead of casting to long: check biometricsDto.getQualityScore() >=
0.0 && biometricsDto.getQualityScore() <=
RegistrationConstants.MAX_BIO_QUALITY_SCORE, and if it fails throw the existing
RegBaseCheckedException with
RegistrationExceptionConstants.REG_BIOMETRIC_QUALITY_SCORE_RANGE_ERROR; ensure
this replaces the current ValueRange.of(...).isValidValue((long)
biometricsDto.getQualityScore()) check and references sdkEnabled and
biometricsDto.getQualityScore() so SDK-enabled flows aren’t blocked.

In
`@registration/registration-services/src/test/java/io/mosip/registration/bio/service/test/BioServiceTest.java`:
- Around line 322-391: Current tests only call getSDKScore() and check
ApplicationContext values; update them to exercise the full capture path by
invoking captureModality(...) on bioService with a mocked capture response so
the SDK vs SBI selection, timeout mapping, and qualityScore replacement are
actually executed. Specifically, in the SDK-enabled, disabled, and exception
scenarios: mock the capture provider (BioProviderImpl_V_0_9 via
bioAPIFactory.getBioProvider) to return a controlled capture result (successful
capture with attribute ISO and modality, and a failing capture for exception
test), call bioService.captureModality(...) and assert the returned
BiometricsDto fields (qualityScore replaced with SDK value, modalityName,
attributeISO present) or that the correct error code/exception is propagated;
also add a test that sets RegistrationConstants.SDK_QUALITY_EVALUATION_TIMEOUT
in ApplicationContext and verifies captureModality respects the timeout mapping.
Use existing symbols captureModality, getSDKScore, BioProviderImpl_V_0_9,
bioAPIFactory, BiometricsDto, and RegistrationConstants to locate code.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2e98276a-9a19-4fe3-87c0-d43ab74aa680

📥 Commits

Reviewing files that changed from the base of the PR and between 22fe01f and d435aff.

📒 Files selected for processing (4)
  • registration/registration-services/src/main/java/io/mosip/registration/constants/RegistrationConstants.java
  • registration/registration-services/src/main/java/io/mosip/registration/exception/RegistrationExceptionConstants.java
  • registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java
  • registration/registration-services/src/test/java/io/mosip/registration/bio/service/test/BioServiceTest.java

Comment on lines +122 to 125
// Validate SBI quality score is in valid range
if (!ValueRange.of(0, RegistrationConstants.MAX_BIO_QUALITY_SCORE).isValidValue((long) biometricsDto.getQualityScore()))
throw new RegBaseCheckedException(RegistrationExceptionConstants.REG_BIOMETRIC_QUALITY_SCORE_RANGE_ERROR.getErrorCode(),
RegistrationExceptionConstants.REG_BIOMETRIC_QUALITY_SCORE_RANGE_ERROR.getErrorMessage());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

fd -t f "BioServiceImpl.java" --exec wc -l {}

Repository: mosip/registration-client

Length of output: 183


🏁 Script executed:

cat -n registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java | head -200

Repository: mosip/registration-client

Length of output: 10151


🏁 Script executed:

cat -n registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java | sed -n '100,250p'

Repository: mosip/registration-client

Length of output: 8613


🏁 Script executed:

# Search for sdkEnabled variable usage
rg "sdkEnabled" registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java -B 2 -A 2

Repository: mosip/registration-client

Length of output: 391


🏁 Script executed:

# Search for RegistrationConstants.MAX_BIO_QUALITY_SCORE definition
rg "MAX_BIO_QUALITY_SCORE" registration/ -A 1

Repository: mosip/registration-client

Length of output: 1233


Skip SBI validation when SDK is enabled; use direct double comparisons for range checks.

Line 123 validates the SBI quality score unconditionally, throwing an exception before the SDK evaluation path (line 137) can execute. When sdkEnabled=true, the SBI score should not block SDK evaluation since it is replaced at line 196. Additionally, both validations cast double to long before range checking, which truncates fractional values and incorrectly allows out-of-range scores like -0.5 (casts to 0) or 100.5 (casts to 100) to pass validation.

Condition the SBI validation on !sdkEnabled since the SBI score is only used when SDK is disabled. Replace the casting-based validation with direct double comparisons to preserve fractional precision.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java`
around lines 122 - 125, In BioServiceImpl, change the SBI quality-score
validation so it only runs when sdkEnabled is false and use direct double
comparisons instead of casting to long: check biometricsDto.getQualityScore() >=
0.0 && biometricsDto.getQualityScore() <=
RegistrationConstants.MAX_BIO_QUALITY_SCORE, and if it fails throw the existing
RegBaseCheckedException with
RegistrationExceptionConstants.REG_BIOMETRIC_QUALITY_SCORE_RANGE_ERROR; ensure
this replaces the current ValueRange.of(...).isValidValue((long)
biometricsDto.getQualityScore()) check and references sdkEnabled and
biometricsDto.getQualityScore() so SDK-enabled flows aren’t blocked.

Comment on lines +181 to +190
double sdkScore = getSDKScoreWithTimeout(biometricsDto);

// Validate SDK score is in valid range
if (!ValueRange.of(0, RegistrationConstants.MAX_BIO_QUALITY_SCORE).isValidValue((long) sdkScore)) {
LOGGER.error("SDK returned invalid quality score {} for attribute: {}", sdkScore, bioAttribute);
logAuditEvent("QUALITY_EVAL", bioAttribute, "SDK_INVALID_SCORE",
"SDK returned score out of valid range: " + sdkScore, sdkScore, "SDK");
throw new RegBaseCheckedException(
RegistrationExceptionConstants.REG_BIOMETRIC_SDK_INVALID_SCORE.getErrorCode(),
RegistrationExceptionConstants.REG_BIOMETRIC_SDK_INVALID_SCORE.getErrorMessage());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "BioServiceImpl.java" | head -20

Repository: mosip/registration-client

Length of output: 179


🏁 Script executed:

cd registration/registration-services && find . -type f -name "BioServiceImpl.java"

Repository: mosip/registration-client

Length of output: 144


🏁 Script executed:

rg -l "BioServiceImpl" --type java

Repository: mosip/registration-client

Length of output: 177


🏁 Script executed:

wc -l registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java

Repository: mosip/registration-client

Length of output: 181


🏁 Script executed:

sed -n '170,260p' registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java

Repository: mosip/registration-client

Length of output: 4352


🏁 Script executed:

sed -n '1,450p' registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java | grep -n "getSDKScore" -A 15 | head -50

Repository: mosip/registration-client

Length of output: 2458


🏁 Script executed:

sed -n '300,450p' registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java

Repository: mosip/registration-client

Length of output: 6202


Auto-unboxing null SDK score causes incorrect exception path.

When getSDKScore returns null (Map.get on missing key), auto-unboxing to primitive double throws NullPointerException before reaching line 184. This NPE is caught as a generic Exception and wrapped into REG_BIOMETRIC_QUALITY_CHECK_ERROR, preventing the explicit REG_BIOMETRIC_SDK_INVALID_SCORE path from being reached. The method should return Double (boxed) or explicitly check for null to match the feature's intended error classification.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@registration/registration-services/src/main/java/io/mosip/registration/service/bio/impl/BioServiceImpl.java`
around lines 181 - 190, The sdkScore is currently a primitive double from
getSDKScoreWithTimeout which will NPE if the SDK returned null; change handling
in BioServiceImpl:getSDKScoreWithTimeout() call site to use a boxed Double (or
keep double but first retrieve a Double) and explicitly check for null before
range validation — if null, log the error, call logAuditEvent("QUALITY_EVAL",
bioAttribute, "SDK_INVALID_SCORE", "SDK returned null score", null, "SDK") and
throw the REG_BIOMETRIC_SDK_INVALID_SCORE RegBaseCheckedException; if non-null
continue with the existing ValueRange validation and error path for out-of-range
values.

Comment on lines +322 to +391
@Test
public void sdkQualityEvaluationEnabledTest() throws BiometricException {
// Enable SDK quality check
ApplicationContext.map().put(RegistrationConstants.QUALITY_CHECK_WITH_SDK, RegistrationConstants.ENABLE);

Map<BiometricType, Float> qualityMap = new HashMap<>();
qualityMap.put(BiometricType.FACE, Float.valueOf("85.0"));
BioProviderImpl_V_0_9 providerImpl_v_0_9 = Mockito.mock(BioProviderImpl_V_0_9.class);
Mockito.when(bioAPIFactory.getBioProvider(Mockito.any(), Mockito.any())).thenReturn(providerImpl_v_0_9);
Mockito.when(providerImpl_v_0_9.getModalityQuality(Mockito.any(), Mockito.any())).thenReturn(qualityMap);

BiometricsDto biometricsDto = new BiometricsDto();
biometricsDto.setBioAttribute("face");
biometricsDto.setQualityScore(70.0);
biometricsDto.setAttributeISO(new byte[]{1, 2, 3});
biometricsDto.setModalityName(Modality.FACE.name());

double sdkScore = bioService.getSDKScore(biometricsDto);
Assert.assertEquals(85.0, sdkScore, 0);

// Cleanup
ApplicationContext.map().remove(RegistrationConstants.QUALITY_CHECK_WITH_SDK);
}

@Test
public void sdkQualityDisabledFallbackToSbiTest() {
// Ensure SDK is disabled
ApplicationContext.map().put(RegistrationConstants.QUALITY_CHECK_WITH_SDK, RegistrationConstants.DISABLE);

boolean sdkEnabled = RegistrationConstants.ENABLE.equalsIgnoreCase(
(String) ApplicationContext.map().getOrDefault(
RegistrationConstants.QUALITY_CHECK_WITH_SDK, RegistrationConstants.DISABLE));
Assert.assertFalse("SDK should be disabled, SBI fallback expected", sdkEnabled);

// Cleanup
ApplicationContext.map().remove(RegistrationConstants.QUALITY_CHECK_WITH_SDK);
}

@Test(expected = BiometricException.class)
public void sdkQualityEvaluationExceptionTest() throws BiometricException {
BioProviderImpl_V_0_9 providerImpl_v_0_9 = Mockito.mock(BioProviderImpl_V_0_9.class);
Mockito.when(bioAPIFactory.getBioProvider(Mockito.any(), Mockito.any())).thenReturn(providerImpl_v_0_9);
Mockito.when(providerImpl_v_0_9.getModalityQuality(Mockito.any(), Mockito.any()))
.thenThrow(new BiometricException("SDK_ERR", "SDK evaluation failed"));

BiometricsDto biometricsDto = new BiometricsDto();
biometricsDto.setBioAttribute("face");
biometricsDto.setQualityScore(70.0);
biometricsDto.setAttributeISO(new byte[]{1, 2, 3});
biometricsDto.setModalityName(Modality.FACE.name());

bioService.getSDKScore(biometricsDto);
}

@Test
public void sdkTimeoutConfigurationTest() {
// Test default timeout when not configured
Integer timeout = ApplicationContext.getIntValueFromApplicationMap(
RegistrationConstants.SDK_QUALITY_EVALUATION_TIMEOUT);
Assert.assertNull("Default timeout config should be null", timeout);

// Test configured timeout
ApplicationContext.map().put(RegistrationConstants.SDK_QUALITY_EVALUATION_TIMEOUT, "5000");
timeout = ApplicationContext.getIntValueFromApplicationMap(
RegistrationConstants.SDK_QUALITY_EVALUATION_TIMEOUT);
Assert.assertEquals(Integer.valueOf(5000), timeout);

// Cleanup
ApplicationContext.map().remove(RegistrationConstants.SDK_QUALITY_EVALUATION_TIMEOUT);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

These tests never hit the new SDK capture path.

They only call getSDKScore() or inspect ApplicationContext, so regressions in captureModality(), SDK/SBI source selection, timeout mapping, or qualityScore replacement would still pass. Please drive the assertions through captureModality() with mocked capture responses and assert the returned BiometricsDto state/error code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@registration/registration-services/src/test/java/io/mosip/registration/bio/service/test/BioServiceTest.java`
around lines 322 - 391, Current tests only call getSDKScore() and check
ApplicationContext values; update them to exercise the full capture path by
invoking captureModality(...) on bioService with a mocked capture response so
the SDK vs SBI selection, timeout mapping, and qualityScore replacement are
actually executed. Specifically, in the SDK-enabled, disabled, and exception
scenarios: mock the capture provider (BioProviderImpl_V_0_9 via
bioAPIFactory.getBioProvider) to return a controlled capture result (successful
capture with attribute ISO and modality, and a failing capture for exception
test), call bioService.captureModality(...) and assert the returned
BiometricsDto fields (qualityScore replaced with SDK value, modalityName,
attributeISO present) or that the correct error code/exception is propagated;
also add a test that sets RegistrationConstants.SDK_QUALITY_EVALUATION_TIMEOUT
in ApplicationContext and verifies captureModality respects the timeout mapping.
Use existing symbols captureModality, getSDKScore, BioProviderImpl_V_0_9,
bioAPIFactory, BiometricsDto, and RegistrationConstants to locate code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DMP 2026]: Define Biometric Quality Through SDK During Biometric Capture

1 participant