Skip to content

Conversation

@Blue-B-code
Copy link

Description

This PR introduces unit tests for the MapItems feature in the mobile claims module. The tests validate that item mapping logic, list binding, user interactions, filtering, persistence behavior, and dialog handling are correctly processed and exposed by the activity layer.
The Android environment and database interactions are mocked to isolate UI and business logic, ensuring deterministic behavior without relying on a real database.

Type of change

Chore (Testing / CI)

CheckLists
Unit Tests added:
MapItems – Item loading and binding

bindItemList_loadsItemsCorrectly – PASSED ✅
Ensures items retrieved from the database cursor are correctly loaded into the ItemsList, with proper handling of unmapped items and resource cleanup.

MapItems – Item selection handling

clickingItem_togglesIsMapped – PASSED ✅
Ensures clicking on a list item correctly toggles its isMapped state.

MapItems – Bulk selection logic

checkAll_setsAllItemsMapped – PASSED ✅
Ensures the “check/uncheck all” action correctly updates the isMapped flag for all items in the list.

MapItems – Save and persistence logic

save_returnsCorrectCodes – PASSED ✅
Ensures the save operation returns the correct status code depending on whether items are mapped or unmapped.

save_returns2_whenInsertFails – PASSED ✅
Ensures the save operation returns error code 2 when database insertion fails.

MapItems – Filtering logic

filter_searchWorksCorrectly – PASSED ✅
Ensures the adapter filter correctly narrows the item list based on the search query.

MapItems – Adapter view rendering

adapter_getView_setsCorrectValues – PASSED ✅
Ensures the adapter correctly inflates and populates the list item view.

MapItems – Dialog handling

showDialog_createsAlertDialog – PASSED ✅
Ensures the activity correctly creates and returns an AlertDialog when requested.

Notes

Database operations are fully mocked via SQLHandler to isolate activity logic.

Cursor behavior is simulated to control dataset iteration and edge cases.

UI components and lifecycle are handled using Robolectric.

Tests ensure correct item mapping behavior, filtering, persistence logic, and user interaction handling without real database access.

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