Unit tests for Download Family #223
Open
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.
Description
Here I implemented unit tests for the ModifyFamily feature in ClientAndroidInterface. These tests verify that families, members, and policies are correctly imported when the insured does not exist in the database, and that proper handling occurs when the insured exists or when errors occur (family not found or server error). The Android environment and global configuration are simulated using mocks, while family, member, and policy data are fully mocked to validate returned content and database insertions.
Type of change
Chore (Testing / CI)
CheckLists
Unit Tests added:
ModifyFamily – Import family successfully
testModifyFamily_ShouldImportFamilyInsureesAndPolicies – PASSED ✅
Ensures a new family, its members, and policies are inserted correctly
Verifies database insertion in tblFamilies, tblInsuree, and tblPolicy
ModifyFamily – Insuree already exists
testModifyFamily_ShouldNotImportIfInsureeExists – PASSED ✅
Ensures no data is imported if the insured exists
Verifies that the user is notified via ShowDialog()
ModifyFamily – Family not found on server
testModifyFamily_ShouldHandleFamilyNotFound – PASSED ✅
Ensures method handles HttpException 404 gracefully
Verifies that the user is notified via ShowDialog()
ModifyFamily – Server error handling
testModifyFamily_ShouldHandleServerError – PASSED ✅
Ensures method handles generic server errors (RuntimeException)
Verifies that the user is notified via ShowDialog()
Notes
Backend communication is not executed; Family, Member, Policy, and newFetchFamilyExecute() are mocked to isolate business logic.
ShowDialog() is mocked to simulate user notifications.
sqlHandler is mocked to simulate database interactions (count and insert operations).