Merged
Conversation
…ication classes This commit adds test coverage for all Dana driver execution services and communication layer classes that were previously untested: Execution Services: - AbstractDanaRExecutionService: Base class tests covering connection management, bolus stop, history loading, sanity checks, and Bluetooth socket initialization - DanaRExecutionService: Tests for Dana R-specific operations including temp basal, extended bolus, profile updates, and user options - DanaRKoreanExecutionService: Tests for Korean variant with specific basal rates and profile handling - DanaRv2ExecutionService: Tests for v2 protocol including high temp basal, short duration temp basals, and event loading - DanaRSService: Tests for BLE-based Dana RS including connection management, bolus operations, temp basals, extended bolus, and history loading Communication Classes: - SerialIOThread: Tests for Bluetooth Serial communication thread covering disconnect, message sending, and thread lifecycle - BLEComm: Tests for Bluetooth Low Energy communication covering connection, disconnection, device bonding, and message sending All tests follow the existing test patterns in the codebase using JUnit 5, Mockito, and Google Truth assertions. Tests verify both success and failure paths, including null checks, connection state validation, and proper error handling.
Update all Dana driver tests to be compatible with dev branch changes: - Replace instantiator with pumpEnactResultProvider (Provider<PumpEnactResult>) - Update bolus() method signature to use DetailedBolusInfo instead of multiple parameters - Add messageHashTable() abstract method implementation - Update Preferences import path to app.aaps.core.keys.interfaces.Preferences - Remove EventOverviewBolusProgress.Treatment references - Fix all compilation errors caused by API changes in dev branch These changes ensure tests compile with the updated Dana driver APIs while maintaining full test coverage.
…Q47YWSz39ES8MjmZcK5fMF
Add Mock Provider instances and packet mocks for: - DanaRSPacketGeneralInitialScreenInformation - DanaRSPacketOptionSetUserOption - DanaRSPacketBolusSetStepBolusStop - DanaRSPacketAPSBasalSetTemporaryBasal - DanaRSPacketBasalSetCancelTemporaryBasal These providers are used by the service via dependency injection and were causing UninitializedPropertyAccessException in tests: - testHighTempBasal - testSetUserSettings - testBolusStop - testTempBasalShortDuration_validDuration15 - testTempBasalShortDuration_validDuration30
Add missing @mock declaration for HasAndroidInjector which was being used in setup() but not declared, causing MissingMethodInvocationException.
Add mock for PumpEnactResult and configure it to return success=true in the testLoadEvents test. The loadEvents() method returns pumpEnactResultProvider.get() which needs to have success set to true for the test to pass.
…t for DanaPump Changed from using when() to direct property assignment for DanaPump var properties. Mockito doesn't work correctly with when() on var properties of concrete Kotlin classes. This fixes the tests: - testDoSanityCheck_temporaryBasalInAAPSButNotInPump - testDoSanityCheck_extendedBolusMismatch The tests were failing because uiInteraction.addNotification() was not being called due to incorrect mock setup.
Changed DanaPump from @mock to real instance. The issue was that direct property assignment doesn't work on Mock objects - mocks need when() for configuring getters. By using a real DanaPump instance, we can directly set properties like isTempBasalInProgress, isExtendedInProgress, etc. This fixes the doSanityCheck tests where uiInteraction.addNotification() was not being called because the mock properties weren't being set correctly.
Fixed issues with DanaPump property setters that only allow setting to false: 1. Removed direct assignments to isTempBasalInProgress and isExtendedInProgress 2. Instead set underlying properties (tempBasalStart, tempBasalDuration, extendedBolusStart, extendedBolusDuration) which the getters use 3. Fixed duration values to be in milliseconds (not minutes) 4. Adjusted dateUtil.now() to return values within the active range The properties have custom setters that throw IllegalArgumentException when trying to set to true. The getters calculate the status based on start time, duration, and current time.
…cturing Changed from mocking PumpState to creating real instances. The doSanityCheck method uses Kotlin destructuring: val (temporaryBasal, extendedBolus) = pumpSync.expectedPumpState() Mockito mocks don't support Kotlin data class destructuring (component1/component2 methods). By using real PumpState instances with mock TemporaryBasal and ExtendedBolus objects, the destructuring works correctly. This fixes tests where uiInteraction.addNotification() was not being called because the destructuring was failing silently with mocked PumpState.
Removed the assignment of danaPump.tempBasalStart in the extended bolus mismatch test. Setting tempBasalStart without tempBasalDuration could interfere with the test logic, even though the temp basal should not be active in this test case. Leaving tempBasalStart at its default value (0) ensures that isTempBasalInProgress returns false, allowing the test to focus solely on the extended bolus mismatch scenario.
…ions Fixed two issues: 1. Set dateUtil.now() mock BEFORE accessing danaPump properties that use isExtendedInProgress getter (which calls dateUtil.now()) 2. Changed extendedBolus.timestamp to 500000L to create a timestamp difference of 500000ms (> 10000ms threshold) This ensures both mismatch conditions are met: - Rate mismatch: 1.5 != 2.0 - Timestamp mismatch: abs(500000 - 1000000) = 500000 > 10000 The notification should now be triggered as expected.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #4330 +/- ##
============================================
+ Coverage 30.63% 30.84% +0.21%
- Complexity 7610 7741 +131
============================================
Files 2381 2381
Lines 122012 122012
Branches 15725 15725
============================================
+ Hits 37376 37634 +258
+ Misses 81766 81446 -320
- Partials 2870 2932 +62 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.




No description provided.