Skip to content

Move all remaining usecases to :core:domain - #3902

Merged
shobhitagarwal1612 merged 7 commits into
masterfrom
usecase-refactor
Aug 27, 2026
Merged

Move all remaining usecases to :core:domain#3902
shobhitagarwal1612 merged 7 commits into
masterfrom
usecase-refactor

Conversation

@shobhitagarwal1612

Copy link
Copy Markdown
Member

Towards #3633

Migrates all survey use cases from :app to :core:domain (KMP) and abstracts network connectivity behind an interface.

Key changes:

  • Domain Use Cases: Moved ActivateSurveyUseCase, MakeSurveyAvailableOfflineUseCase, ReactivateLastSurveyUseCase, and ListAvailableSurveysUseCase to :core:domain.
  • Network Abstraction: Introduced NetworkManagerInterface in :core:domain and FakeNetworkManager in :core:testing, decoupling use cases and repositories from Android connectivity APIs.
  • Repository Decoupling: Exposed lastActiveSurveyId and isSurveyActive() on SurveyRepositoryInterface to remove use case dependencies on Android's LocalValueStore.
  • Tests: Replaced slow Robolectric use case tests with fast KMP unit tests in :core:domain:commonTest, and modernized ViewModel tests to use FakeNetworkManager.

@andreia-ferreira PTAL?

Relocate MakeSurveyAvailableOfflineUseCase, ActivateSurveyUseCase, and ReactivateLastSurveyUseCase to :core:domain. Expose lastActiveSurveyId and isSurveyActive on SurveyRepositoryInterface to decouple use cases from Android-specific LocalValueStore. Add fast, pure KMP unit tests and remove legacy Robolectric tests.
…SurveysUseCase to :core:domain

Abstract network state behind NetworkManagerInterface in :core:domain and provide FakeNetworkManager in :core:testing. Relocate ListAvailableSurveysUseCase to :core:domain, decoupling it from Android framework connectivity APIs. Update SurveySelectorFragmentTest to test through real use cases.
…odels

Update UserRepository, TermsOfServiceRepository, SignInViewModel, and OfflineAreaSelectorViewModel to depend on NetworkManagerInterface rather than the Android platform implementation. Modernize SignInViewModelTest and OfflineAreaSelectorViewModelTest to use FakeNetworkManager instead of Mockito stubs.
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.99%. Comparing base (221cb48) to head (f804520).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3902      +/-   ##
============================================
- Coverage     69.02%   68.99%   -0.03%     
+ Complexity     1944     1943       -1     
============================================
  Files           411      412       +1     
  Lines         10966    10963       -3     
  Branches       1428     1429       +1     
============================================
- Hits           7569     7564       -5     
- Misses         2652     2654       +2     
  Partials        745      745              
Files with missing lines Coverage Δ
...undplatform/android/repository/SurveyRepository.kt 80.00% <100.00%> (-2.06%) ⬇️
...orm/android/repository/TermsOfServiceRepository.kt 100.00% <100.00%> (ø)
...roundplatform/android/repository/UserRepository.kt 83.05% <100.00%> (ø)
...rg/groundplatform/android/system/NetworkManager.kt 50.00% <100.00%> (-4.55%) ⬇️
...rg/groundplatform/android/ui/main/MainViewModel.kt 65.57% <ø> (ø)
...lineareas/selector/OfflineAreaSelectorViewModel.kt 88.42% <100.00%> (ø)
...roundplatform/android/ui/signin/SignInViewModel.kt 100.00% <ø> (ø)
...droid/ui/surveyselector/SurveySelectorViewModel.kt 79.34% <ø> (ø)
...dplatform/domain/system/NetworkManagerInterface.kt 100.00% <100.00%> (ø)
...rm/domain/usecases/survey/ActivateSurveyUseCase.kt 100.00% <100.00%> (ø)
... and 3 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread app/src/main/java/org/groundplatform/android/system/NetworkManager.kt Outdated
@shobhitagarwal1612
shobhitagarwal1612 merged commit 14f15ed into master Aug 27, 2026
19 checks passed
@shobhitagarwal1612
shobhitagarwal1612 deleted the usecase-refactor branch August 27, 2026 12:14
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