Unit tests for Download Claims #116
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 claim download feature using the FetchClaims service. These tests verify that claims are correctly retrieved when the network is available and that proper errors are raised when the network is unavailable. The Android environment and global configuration are simulated using mocks, while claim data is fully mocked to validate returned content (services, medications, and claim metadata).
Type of change
Chore (Testing / CI)
CheckLists
Unit Tests added:
Download Claims – Network available
testDownloadClaims_WhenNetworkAvailable_ReturnsClaimsList – PASSED ✅
Ensures a non-empty list of claims is returned
Verifies claim number, patient name, and status
Verifies that services and medications are included
Download Claims – Network unavailable
testDownloadClaims_WhenNetworkUnavailable_ThrowsException – PASSED ✅
Ensures an exception is thrown when there is no network
Backend communication is not executed; FetchClaims is mocked to isolate business logic.
Global.isNetworkAvailable() is used to simulate online/offline states.
A complete Claim object is used to ensure the returned structure matches production expectations.