-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching questionnaires and their SM #3461
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3461 +/- ##
=========================================
+ Coverage 27.2% 28.1% +0.8%
- Complexity 756 760 +4
=========================================
Files 278 277 -1
Lines 14219 13762 -457
Branches 2581 2490 -91
=========================================
- Hits 3880 3868 -12
+ Misses 9801 9358 -443
+ Partials 538 536 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@aurangzaibumer could we add a unit test for the ViewModel itself? You can mock anything you don't need/already tested in the Cache test if need be. |
android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/ContentCache.kt
Outdated
Show resolved
Hide resolved
...st/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt
Outdated
Show resolved
Hide resolved
android/engine/src/main/java/org/smartregister/fhircore/engine/task/FhirCarePlanGenerator.kt
Outdated
Show resolved
Hide resolved
ContentCache.getResource(ResourceType.Questionnaire.name + "/" + questionnaireConfig.id), | ||
) | ||
Assert.assertNotNull(questionnaire) | ||
Assert.assertEquals(questionnaireConfig.id, questionnaire?.id?.extractLogicalIdUuid()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add a verify assertion here to verify that the
defaultRepository.loadResource<Questionnaire>(questionnaireConfig.id)
method was not called (i.e. was called zero times)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we can probably split this to 2 unit tests to get better coverage for the changes in this class.
- Test case 1 to test for when the questionnaire is Found in the cache
- Test case 2 to test for when the questionnaire is Not Found in the cache
So basically use the:
val questionnaire =
questionnaireViewModel.retrieveQuestionnaire(
questionnaireConfig = questionnaireConfig,
)
method as the focus of the test case and leave out the ContentCache.save invocations since those are already tested in the ContentCacheTest
class
structureMapUrl?.substringAfterLast("/")?.let { smID -> | ||
ContentCache.getResource(ResourceType.StructureMap.name + "/" + smID)?.let { | ||
it as StructureMap | ||
} | ||
?: run { | ||
defaultRepository.loadResource<StructureMap>(smID)?.also { | ||
ContentCache.saveResource(smID, it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add some test cases for the Structure Map caching as well
IMPORTANT: Where possible all PRs must be linked to a Github issue
Fixes [link to issue]
Engineer Checklist
strings.xml
file./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the project's style guideCode Reviewer Checklist
strings.xml
file