From f4b136d202529a469d438c261de25966cd5d8d96 Mon Sep 17 00:00:00 2001 From: Victor Garcia Date: Fri, 9 Aug 2024 13:26:26 +0200 Subject: [PATCH 1/4] [ANDROSDK-1906] Add failing test for fileResource download --- .../new_tracker_importer_tracked_entities.json | 6 ++++++ .../resources/trackedentity/tracked_entity_instances.json | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/core/src/sharedTest/resources/trackedentity/new_tracker_importer_tracked_entities.json b/core/src/sharedTest/resources/trackedentity/new_tracker_importer_tracked_entities.json index 35740298e2..050f131a43 100644 --- a/core/src/sharedTest/resources/trackedentity/new_tracker_importer_tracked_entities.json +++ b/core/src/sharedTest/resources/trackedentity/new_tracker_importer_tracked_entities.json @@ -231,6 +231,12 @@ "createdAt": "2018-01-10T13:40:28.000", "attribute": "cejWyOfXge6", "value": "654321" + }, + { + "updatedAt": "2019-01-11T13:40:28.000", + "createdAt": "2019-01-11T13:40:28.000", + "attribute": "aejWyOfXge6", + "value": "aefryrfXge5" } ], "enrollments": [ diff --git a/core/src/sharedTest/resources/trackedentity/tracked_entity_instances.json b/core/src/sharedTest/resources/trackedentity/tracked_entity_instances.json index aeb27b33d3..fa71c3f020 100644 --- a/core/src/sharedTest/resources/trackedentity/tracked_entity_instances.json +++ b/core/src/sharedTest/resources/trackedentity/tracked_entity_instances.json @@ -226,6 +226,12 @@ "created": "2018-01-10T13:40:28.000", "attribute": "cejWyOfXge6", "value": "654321" + }, + { + "lastUpdated": "2019-01-11T13:40:28.000", + "created": "2019-01-11T13:40:28.000", + "attribute": "aejWyOfXge6", + "value": "aefryrfXge5" } ], "enrollments": [ From 5404c50b3acbcf23af947f51dcf449f93419ac23 Mon Sep 17 00:00:00 2001 From: Victor Garcia Date: Mon, 12 Aug 2024 09:05:38 +0200 Subject: [PATCH 2/4] [ANDROSDK-1906] Continue fileResource download when error --- ...CollectionRepositoryMockIntegrationShould.java | 4 ++-- .../MaintenanceMockIntegrationShould.java | 2 +- ...CollectionRepositoryMockIntegrationShould.java | 2 +- ...CollectionRepositoryMockIntegrationShould.java | 2 +- ...chCollectionRepositoryMockIntegrationShould.kt | 2 +- .../internal/FileResourceDownloadCall.kt | 15 ++++++++++++--- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/core/src/androidTest/java/org/hisp/dhis/android/testapp/maintenance/D2ErrorCollectionRepositoryMockIntegrationShould.java b/core/src/androidTest/java/org/hisp/dhis/android/testapp/maintenance/D2ErrorCollectionRepositoryMockIntegrationShould.java index 80438efe03..45e9945ee5 100644 --- a/core/src/androidTest/java/org/hisp/dhis/android/testapp/maintenance/D2ErrorCollectionRepositoryMockIntegrationShould.java +++ b/core/src/androidTest/java/org/hisp/dhis/android/testapp/maintenance/D2ErrorCollectionRepositoryMockIntegrationShould.java @@ -67,7 +67,7 @@ public void filter_d2_error_by_d2_error_code() { public void filter_d2_error_by_d2_error_component() { List d2Errors = d2.maintenanceModule().d2Errors() .byD2ErrorComponent().eq(D2ErrorComponent.Server).blockingGet(); - assertThat(d2Errors.size()).isEqualTo(2); + assertThat(d2Errors.size()).isEqualTo(4); } @Test @@ -105,6 +105,6 @@ public void filter_d2_error_by_created() { List d2Errors = d2.maintenanceModule().d2Errors() .byCreated().inPeriods(Lists.newArrayList(todayPeriod)).blockingGet(); - assertThat(d2Errors.size()).isEqualTo(3); + assertThat(d2Errors.size()).isEqualTo(5); } } \ No newline at end of file diff --git a/core/src/androidTest/java/org/hisp/dhis/android/testapp/maintenance/MaintenanceMockIntegrationShould.java b/core/src/androidTest/java/org/hisp/dhis/android/testapp/maintenance/MaintenanceMockIntegrationShould.java index b10674fd8e..e9a89c9c23 100644 --- a/core/src/androidTest/java/org/hisp/dhis/android/testapp/maintenance/MaintenanceMockIntegrationShould.java +++ b/core/src/androidTest/java/org/hisp/dhis/android/testapp/maintenance/MaintenanceMockIntegrationShould.java @@ -83,6 +83,6 @@ public void get_vulnerabilities_for_low_threshold() { @Test public void allow_access_to_d2_errors() { List d2Errors = d2.maintenanceModule().d2Errors().blockingGet(); - assertThat(d2Errors.size()).isEqualTo(3); + assertThat(d2Errors.size()).isEqualTo(5); } } \ No newline at end of file diff --git a/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityAttributeValueCollectionRepositoryMockIntegrationShould.java b/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityAttributeValueCollectionRepositoryMockIntegrationShould.java index 848dde12f0..8bbc10942a 100644 --- a/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityAttributeValueCollectionRepositoryMockIntegrationShould.java +++ b/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityAttributeValueCollectionRepositoryMockIntegrationShould.java @@ -51,7 +51,7 @@ public class TrackedEntityAttributeValueCollectionRepositoryMockIntegrationShoul public void allow_access_to_all_tracked_entity_data_values() { List trackedEntityAttributeValues = d2.trackedEntityModule().trackedEntityAttributeValues().blockingGet(); - assertThat(trackedEntityAttributeValues.size()).isEqualTo(3); + assertThat(trackedEntityAttributeValues.size()).isEqualTo(4); } @Test diff --git a/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityInstanceCollectionRepositoryMockIntegrationShould.java b/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityInstanceCollectionRepositoryMockIntegrationShould.java index de27979021..e2287dba34 100644 --- a/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityInstanceCollectionRepositoryMockIntegrationShould.java +++ b/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityInstanceCollectionRepositoryMockIntegrationShould.java @@ -69,7 +69,7 @@ public void include_tracked_entity_attribute_values_as_children() { TrackedEntityInstance tei = d2.trackedEntityModule().trackedEntityInstances() .withTrackedEntityAttributeValues().uid("nWrB0TfWlvD").blockingGet(); - assertThat(tei.trackedEntityAttributeValues().size()).isEqualTo(1); + assertThat(tei.trackedEntityAttributeValues().size()).isEqualTo(2); assertThat(tei.trackedEntityAttributeValues().get(0).trackedEntityAttribute()).isEqualTo("cejWyOfXge6"); diff --git a/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/search/TrackedEntitySearchCollectionRepositoryMockIntegrationShould.kt b/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/search/TrackedEntitySearchCollectionRepositoryMockIntegrationShould.kt index 03c269e854..9b79f88c3e 100644 --- a/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/search/TrackedEntitySearchCollectionRepositoryMockIntegrationShould.kt +++ b/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/search/TrackedEntitySearchCollectionRepositoryMockIntegrationShould.kt @@ -77,7 +77,7 @@ class TrackedEntitySearchCollectionRepositoryMockIntegrationShould : .blockingGet() assertThat(trackedEntityInstances[0].header).isEqualTo("4081507, befryEfXge5") - assertThat(trackedEntityInstances[1].header).isEqualTo("654321, ") + assertThat(trackedEntityInstances[1].header).isEqualTo("654321, aefryrfXge5") } @Test diff --git a/core/src/main/java/org/hisp/dhis/android/core/fileresource/internal/FileResourceDownloadCall.kt b/core/src/main/java/org/hisp/dhis/android/core/fileresource/internal/FileResourceDownloadCall.kt index 574bbb8f38..c7c90f1a48 100644 --- a/core/src/main/java/org/hisp/dhis/android/core/fileresource/internal/FileResourceDownloadCall.kt +++ b/core/src/main/java/org/hisp/dhis/android/core/fileresource/internal/FileResourceDownloadCall.kt @@ -39,6 +39,7 @@ import org.hisp.dhis.android.core.arch.call.fetchers.internal.UidsNoResourceCall import org.hisp.dhis.android.core.arch.call.internal.D2ProgressManager import org.hisp.dhis.android.core.arch.call.queries.internal.UidsQuery import org.hisp.dhis.android.core.arch.helpers.FileResizerHelper +import org.hisp.dhis.android.core.arch.helpers.Result import org.hisp.dhis.android.core.common.State import org.hisp.dhis.android.core.common.ValueType import org.hisp.dhis.android.core.fileresource.FileResource @@ -253,12 +254,20 @@ internal class FileResourceDownloadCall( private suspend fun getIdsValuePairsSequentially(valueMap: Map): List> { return valueMap.mapNotNull { (uid, value) -> uid?.let { - val fileResource = coroutineAPICallExecutor.wrap { + val frResult = coroutineAPICallExecutor.wrap { fileResourceService.getFileResource( uid, ) - }.getOrThrow() - Pair(fileResource, value) + } + when (frResult) { + is Result.Success -> { + Pair(frResult.value, value) + } + is Result.Failure -> { + Log.v(FileResourceDownloadCall::class.java.canonicalName, frResult.failure.errorDescription()) + null + } + } } } } From 76fc1f76bb7d0cae34db92b397a9fe975717c695 Mon Sep 17 00:00:00 2001 From: Victor Garcia Date: Mon, 12 Aug 2024 13:08:53 +0200 Subject: [PATCH 3/4] [ANDROSDK-1906] Fix modified test --- ...tityInstanceCollectionRepositoryMockIntegrationShould.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityInstanceCollectionRepositoryMockIntegrationShould.java b/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityInstanceCollectionRepositoryMockIntegrationShould.java index e2287dba34..f5537536d6 100644 --- a/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityInstanceCollectionRepositoryMockIntegrationShould.java +++ b/core/src/androidTest/java/org/hisp/dhis/android/testapp/trackedentity/TrackedEntityInstanceCollectionRepositoryMockIntegrationShould.java @@ -72,8 +72,8 @@ public void include_tracked_entity_attribute_values_as_children() { assertThat(tei.trackedEntityAttributeValues().size()).isEqualTo(2); - assertThat(tei.trackedEntityAttributeValues().get(0).trackedEntityAttribute()).isEqualTo("cejWyOfXge6"); - assertThat(tei.trackedEntityAttributeValues().get(0).value()).isEqualTo("654321"); + assertThat(tei.trackedEntityAttributeValues().get(0).trackedEntityAttribute()).isEqualTo("aejWyOfXge6"); + assertThat(tei.trackedEntityAttributeValues().get(0).value()).isEqualTo("aefryrfXge5"); } @Test From 0415e360ec79eebfa22107f45be3e3a816cf3ecf Mon Sep 17 00:00:00 2001 From: Victor Garcia Date: Tue, 13 Aug 2024 10:26:21 +0200 Subject: [PATCH 4/4] [1.10.1-RC] Update docs version --- docs/content/developer/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/developer/getting-started.md b/docs/content/developer/getting-started.md index 271f91bae7..8f767ae9ea 100644 --- a/docs/content/developer/getting-started.md +++ b/docs/content/developer/getting-started.md @@ -6,7 +6,7 @@ Include dependency in build.gradle. ```gradle dependencies { - implementation "org.hisp.dhis:android-core:1.10.0.1" + implementation "org.hisp.dhis:android-core:1.10.1" ... } ```