Skip to content

Conversation

@Blue-B-code
Copy link

@Blue-B-code Blue-B-code commented Jan 27, 2026

Description

This PR introduces unit tests for the Acquire feature in the mobile policies module. The tests validate CHFID input handling, scan and camera interactions, image validation, file creation, database updates, menu behavior, and photo processing logic as handled by the activity layer.
The Android environment and external dependencies are mocked to isolate UI and business logic and ensure consistent behavior without relying on real camera hardware, file system, or database access.

Type of change

Chore (Testing / CI)

CheckLists

Unit Tests added:
Acquire – Scan and camera interactions

clickingScan_shouldLaunchZXing – PASSED ✅
Ensures the QR code scanner activity is launched with the correct intent and scan mode.

clickingTakePhoto_withCHF_shouldLaunchCamera – PASSED ✅
Ensures the camera intent is launched when a valid CHFID is provided, with a proper output URI.

Acquire – Activity result handling

onActivityResult_scan_shouldFillCHFID – PASSED ✅
Ensures the CHFID field is correctly populated when a scan result is returned.

Acquire – Validation logic

isValidate_missingImage_returnsFalse – PASSED ✅
Ensures validation fails when the insuree image is missing.

isValidate_valid_returnsTrue – PASSED ✅
Ensures validation succeeds when both CHFID and image are present.

Acquire – Menu handling

menuStatistics_withoutInternet_returnsFalse – PASSED ✅
Ensures the statistics menu action is not processed when network connectivity is unavailable.

Acquire – Data submission and persistence

submitData_shouldCreateFile_andUpdateSql – PASSED ✅
Ensures image data is written to a file and insuree data is correctly updated in the local database.

submitData_emptyFile_returnsZero – PASSED ✅
Ensures no database update occurs when the generated image file is empty.

Notes

Backend and network calls are not executed; database access and external services are fully mocked.

Android system components (Intents, ImageView, EditText, MenuItem) are simulated using Robolectric.

Image handling, file creation, and compression logic are tested without accessing the real filesystem.

Network availability and application configuration are mocked via the Global dependency.

Tests ensure reliable validation, correct intent triggering, robust error handling, and proper data persistence behavior.

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.

2 participants