Skip to content

Commit

Permalink
Merge pull request #1577 from dhis2/master-dev
Browse files Browse the repository at this point in the history
fix: [MASTER-DEV] Release 1.4.1
  • Loading branch information
vgarciabnz authored Jun 11, 2021
2 parents 2f00a1d + ec9f664 commit 5c8455f
Show file tree
Hide file tree
Showing 46 changed files with 848 additions and 406 deletions.
4 changes: 2 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ ext {
buildToolsVersion: "29.0.3",
minSdkVersion : 19,
targetSdkVersion : 29,
versionCode : 240,
versionName : "1.4.0"
versionCode : 241,
versionName : "1.4.1"
]

libraries = [
Expand Down
4 changes: 2 additions & 2 deletions core/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
# Properties which are consumed by plugins/gradle-mvn-push.gradle plugin.
# They are used for publishing artifact to snapshot repository.

VERSION_NAME=1.4.0
VERSION_CODE=240
VERSION_NAME=1.4.1
VERSION_CODE=241

GROUP=org.hisp.dhis

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package org.hisp.dhis.android.core.datavalue.internal

import com.google.common.truth.Truth.assertThat
import org.hisp.dhis.android.core.common.State
import org.hisp.dhis.android.core.maintenance.D2Error
import org.hisp.dhis.android.core.utils.integration.mock.BaseMockIntegrationTestMetadataEnqueable
import org.hisp.dhis.android.core.utils.runner.D2JunitRunner
import org.junit.After
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(D2JunitRunner::class)
class DataValuePostCallMockIntegrationShould : BaseMockIntegrationTestMetadataEnqueable() {

@After
@Throws(D2Error::class)
fun tearDown() {
d2.wipeModule().wipeData()
}

@Test
fun post_dataValues_success() {
// Given user sets correct data values
dhis2MockServer.enqueueMockResponse("datavalueset/data_value_set_success.json")
provideDataValues("30", "40")

// When user sync data in order to upload the data values
d2.dataValueModule().dataValues().blockingUpload()

// Then all data set should be properly synced
val warnings = d2.dataValueModule().dataValues().byState().eq(State.SYNCED).blockingGet()
assertThat(warnings.size).isEqualTo(2)
}

@Test
fun post_dataValues_warning() {
// Given user sets one unsupported type of data value
dhis2MockServer.enqueueMockResponse("datavalueset/data_value_set_warning.json")
provideDataValues("30", "40L")

// When user sync data in order to upload the data values
d2.dataValueModule().dataValues().blockingUpload()

// Then one data set should marked as WARNING
val warnings = d2.dataValueModule().dataValues().byState().eq(State.WARNING).blockingGet()
assertThat(warnings.size).isEqualTo(1)
}

@Test
fun post_dataValues_undetermined_warning() {
// Given user sets one undetermined data value
dhis2MockServer.enqueueMockResponse("datavalueset/data_value_set_warning.json")
provideDataValues("40", "50L")

// When user sync data in order to upload the data values
d2.dataValueModule().dataValues().blockingUpload()

// Then all data values should be marked as WARNING
val warnings = d2.dataValueModule().dataValues().byState().eq(State.WARNING).blockingGet()
assertThat(warnings.size).isEqualTo(2)
}

private fun provideDataValues(value1: String, value2: String) {
d2.dataValueModule().dataValues().value(
"20191021",
"DiszpKrYNg8",
"Ok9OQpitjQr",
"DwrQJzeChWp",
"DwrQJzeChWp"
).blockingSet(value1)
d2.dataValueModule().dataValues().value(
"20191021",
"DiszpKrYNg8",
"vANAXwtLwcT",
"bRowv6yZOF2",
"bRowv6yZOF2"
).blockingSet(value2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class CreateProgramStageUtils {
private static final String DISPLAY_NAME = "test_display_name";

private static final String EXECUTION_DATE_LABEL = "test_executionDateLabel";
private static final String DUE_DATE_LABEL = "test_dueDateLabel";
private static final Integer ALLOW_GENERATE_NEXT_VISIT = 0;
private static final Integer VALID_COMPLETE_ONLY = 0;
private static final String REPORT_DATE_TO_USE = "test_reportDateToUse";
Expand Down Expand Up @@ -69,6 +70,7 @@ public static ContentValues create(long id, String uid, String programId) {
programStage.put(IdentifiableColumns.CREATED, DATE);
programStage.put(IdentifiableColumns.LAST_UPDATED, DATE);
programStage.put(ProgramStageTableInfo.Columns.EXECUTION_DATE_LABEL, EXECUTION_DATE_LABEL);
programStage.put(ProgramStageTableInfo.Columns.DUE_DATE_LABEL, DUE_DATE_LABEL);
programStage.put(ProgramStageTableInfo.Columns.ALLOW_GENERATE_NEXT_VISIT, ALLOW_GENERATE_NEXT_VISIT);
programStage.put(ProgramStageTableInfo.Columns.VALID_COMPLETE_ONLY, VALID_COMPLETE_ONLY);
programStage.put(ProgramStageTableInfo.Columns.REPORT_DATE_TO_USE, REPORT_DATE_TO_USE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
createEnrollment()
createTrackerEvent(eventUid = event1, programStageUid = programStage1, eventDate = Date())
insertTrackedEntityDataValue(event1, dataElement1, "4")
setProgramIndicatorExpressionAsAvg(de(programStage1, dataElement1))
setProgramIndicatorExpression(de(programStage1, dataElement1))
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(enrollmentUid, programIndicatorUid)
assertThat(result).isEqualTo("4")
}
Expand All @@ -151,7 +151,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
createEnrollment()
createTrackerEvent(eventUid = event1, programStageUid = programStage1, eventDate = Date())
insertTrackedEntityDataValue(event1, dataElement1, "text data-value")
setProgramIndicatorExpressionAsAvg(de(programStage1, dataElement1))
setProgramIndicatorExpression(de(programStage1, dataElement1))
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(enrollmentUid, programIndicatorUid)
assertThat(result).isEqualTo("text data-value")
}
Expand All @@ -162,7 +162,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
createTrackerEvent(eventUid = event1, programStageUid = programStage1)
insertTrackedEntityDataValue(event1, dataElement1, "5")
insertTrackedEntityDataValue(event1, dataElement2, "3")
setProgramIndicatorExpressionAsAvg("${de(programStage1, dataElement1)} * ${de(programStage1, dataElement2)}")
setProgramIndicatorExpression("${de(programStage1, dataElement1)} * ${de(programStage1, dataElement2)}")
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(enrollmentUid, programIndicatorUid)
assertThat(result).isEqualTo("15")
}
Expand All @@ -173,13 +173,13 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
createTrackerEvent(eventUid = event1, programStageUid = programStage1)
insertTrackedEntityDataValue(event1, dataElement1, "3")
insertTrackedEntityDataValue(event1, dataElement2, "5")
setProgramIndicatorExpressionAsAvg("${de(programStage1, dataElement1)} / ${de(programStage1, dataElement2)}")
setProgramIndicatorExpression("${de(programStage1, dataElement1)} / ${de(programStage1, dataElement2)}")
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(enrollmentUid, programIndicatorUid)
assertThat(result).isEqualTo("0.6")
}

@Test
fun evaluate_last_value_indicators_different_dates() {
fun evaluate_last_value_in_repeatable_stages() {
createEnrollment()
createTrackerEvent(
eventUid = event1, programStageUid = programStage1,
Expand All @@ -196,7 +196,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
insertTrackedEntityDataValue(event1, dataElement1, "1")
insertTrackedEntityDataValue(event2, dataElement1, "2") // Expected as last value
insertTrackedEntityDataValue(event3, dataElement1, "3")
setProgramIndicatorExpressionAsLast(de(programStage1, dataElement1))
setProgramIndicatorExpression(de(programStage1, dataElement1))
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(enrollmentUid, programIndicatorUid)
assertThat(result).isEqualTo("2")
}
Expand All @@ -220,7 +220,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
insertTrackedEntityDataValue(event1, dataElement1, "1")
insertTrackedEntityDataValue(event2, dataElement1, "2") // Expected as last value
insertTrackedEntityDataValue(event3, dataElement1, "3")
setProgramIndicatorExpressionAsLast(de(programStage1, dataElement1))
setProgramIndicatorExpression(de(programStage1, dataElement1))
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(enrollmentUid, programIndicatorUid)
assertThat(result).isEqualTo("2")
}
Expand All @@ -233,7 +233,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
insertTrackedEntityDataValue(event1, dataElement1, "5")
insertTrackedEntityDataValue(event2, dataElement2, "1.5")
insertTrackedEntityAttributeValue(attribute1, "2")
setProgramIndicatorExpressionAsAvg(
setProgramIndicatorExpression(
"(${de(programStage1, dataElement1)} + ${de(programStage2, dataElement2)})" +
" / ${att(attribute1)}"
)
Expand All @@ -254,7 +254,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
createTrackerEvent(event1, programStage1)
createTrackerEvent(event2, programStage2)
createTrackerEvent(event3, programStage2, deleted = true)
setProgramIndicatorExpressionAsAvg(`var`("event_count"))
setProgramIndicatorExpression(`var`("event_count"))
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(
enrollmentUid,
programIndicatorUid
Expand All @@ -268,7 +268,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
createTrackerEvent(event1, programStage1)
insertTrackedEntityDataValue(event1, dataElement1, "4.8")
insertTrackedEntityDataValue(event1, dataElement2, "3")
setProgramIndicatorExpressionAsAvg(
setProgramIndicatorExpression(
"d2:round(${de(programStage1, dataElement1)}) * ${de(programStage1, dataElement2)}"
)
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(enrollmentUid, programIndicatorUid)
Expand All @@ -281,7 +281,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
val enrollmentDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2018-05-05T00:00:00.000")
val incidentDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2018-05-21T00:00:00.000")
createEnrollment(enrollmentDate, incidentDate)
setProgramIndicatorExpressionAsAvg("d2:daysBetween(V{enrollment_date}, V{incident_date})")
setProgramIndicatorExpression("d2:daysBetween(V{enrollment_date}, V{incident_date})")
val result = programIndicatorEngine!!.getEnrollmentProgramIndicatorValue(enrollmentUid, programIndicatorUid)
assertThat(result).isEqualTo("16")
}
Expand All @@ -291,7 +291,7 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
createSingleEvent(eventUid = event1, programStageUid = programStage1)
insertTrackedEntityDataValue(event1, dataElement1, "3.0")
insertTrackedEntityDataValue(event1, dataElement2, "4.0")
setProgramIndicatorExpressionAsLast("${de(programStage1, dataElement1)} + ${de(programStage1, dataElement2)}")
setProgramIndicatorExpression("${de(programStage1, dataElement1)} + ${de(programStage1, dataElement2)}")
val result = programIndicatorEngine!!.getEventProgramIndicatorValue(event1, programIndicatorUid)
assertThat(result).isEqualTo("7")
}
Expand Down Expand Up @@ -350,14 +350,10 @@ class ProgramIndicatorEngineIntegrationShould : BaseMockIntegrationTestEmptyDisp
)
}

private fun setProgramIndicatorExpressionAsAvg(expression: String) {
private fun setProgramIndicatorExpression(expression: String) {
insertProgramIndicator(expression, AggregationType.AVERAGE)
}

private fun setProgramIndicatorExpressionAsLast(expression: String) {
insertProgramIndicator(expression, AggregationType.LAST)
}

private fun insertProgramIndicator(expression: String, aggregationType: AggregationType) {
val programIndicator = ProgramIndicator.builder().uid(programIndicatorUid)
.program(ObjectWithUid.create(programUid)).expression(expression).aggregationType(aggregationType).build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void filter_by_program() {

@Test
public void filter_by_enrollment_date() throws ParseException {
Date created = BaseIdentifiableObject.DATE_FORMAT.parse("2018-01-10T00:00:00.000");
Date created = BaseIdentifiableObject.DATE_FORMAT.parse("2018-01-10T13:45:00.000");
List<Enrollment> enrollments = d2.enrollmentModule().enrollments()
.byEnrollmentDate().eq(created)
.blockingGet();
Expand All @@ -147,7 +147,7 @@ public void filter_by_enrollment_date() throws ParseException {

@Test
public void filter_by_incident_date() throws ParseException {
Date lastUpdated = BaseIdentifiableObject.DATE_FORMAT.parse("2019-01-10T00:00:00.000");
Date lastUpdated = BaseIdentifiableObject.DATE_FORMAT.parse("2019-01-10T12:23:00.000");
List<Enrollment> enrollments = d2.enrollmentModule().enrollments()
.byIncidentDate().eq(lastUpdated)
.blockingGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
import org.hisp.dhis.android.core.event.EventCreateProjection;
import org.hisp.dhis.android.core.event.EventStatus;
import org.hisp.dhis.android.core.maintenance.D2Error;
import org.hisp.dhis.android.core.period.Period;
import org.hisp.dhis.android.core.utils.integration.mock.BaseMockIntegrationTestFullDispatcher;
import org.hisp.dhis.android.core.utils.runner.D2JunitRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -181,9 +183,14 @@ public void filter_by_organization_unit() {

@Test
public void filter_by_event_date() throws ParseException {
List<Period> periods = new ArrayList<>();
periods.add(Period.builder()
.startDate(BaseNameableObject.DATE_FORMAT.parse("2017-02-27T00:00:00.000"))
.endDate(BaseNameableObject.DATE_FORMAT.parse("2017-02-27T00:00:00.000"))
.build());
List<Event> events =
d2.eventModule().events()
.byEventDate().eq(BaseNameableObject.DATE_FORMAT.parse("2017-02-27T00:00:00.000"))
.byEventDate().inPeriods(periods)
.blockingGet();

assertThat(events.size()).isEqualTo(1);
Expand All @@ -193,7 +200,7 @@ public void filter_by_event_date() throws ParseException {
public void filter_by_complete_date() throws ParseException {
List<Event> events =
d2.eventModule().events()
.byCompleteDate().eq(BaseNameableObject.DATE_FORMAT.parse("2016-02-27T00:00:00.000"))
.byCompleteDate().eq(BaseNameableObject.DATE_FORMAT.parse("2016-02-27T14:34:00.000"))
.blockingGet();

assertThat(events.size()).isEqualTo(1);
Expand All @@ -203,10 +210,11 @@ public void filter_by_complete_date() throws ParseException {
public void filter_by_due_date() throws ParseException {
List<Event> events =
d2.eventModule().events()
.byDueDate().eq(BaseNameableObject.DATE_FORMAT.parse("2017-01-28T00:00:00.000"))
.byDueDate()
.afterOrEqual(BaseNameableObject.DATE_FORMAT.parse("2017-01-28T12:35:00.000"))
.blockingGet();

assertThat(events.size()).isEqualTo(1);
assertThat(events.size()).isEqualTo(2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ public void filter_by_execution_date_label() {
assertThat(programStages.size()).isEqualTo(1);
}

@Test
public void filter_by_due_date_label() {
List<ProgramStage> programStages =
d2.programModule().programStages()
.byDueDateLabel()
.eq("Due date")
.blockingGet();

assertThat(programStages.size()).isEqualTo(1);
}

@Test
public void filter_by_allow_generate_next_visit() {
List<ProgramStage> programStages =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@

package org.hisp.dhis.android.testapp.trackedentity.search;

import org.hisp.dhis.android.core.arch.helpers.DateUtils;
import org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.android.core.trackedentity.search.TrackedEntityInstanceQueryRepositoryScope;
import org.hisp.dhis.android.core.utils.integration.mock.BaseMockIntegrationTestFullDispatcher;
import org.hisp.dhis.android.core.utils.runner.D2JunitRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import static com.google.common.truth.Truth.assertThat;
Expand Down Expand Up @@ -63,6 +66,34 @@ public void find_uids_by_program() {
assertThat(trackedEntityInstanceUids.size()).isEqualTo(2);
}

@Test
public void find_by_enrollment_date() throws ParseException {
Date refDate = DateUtils.DATE_FORMAT.parse("2018-01-10T00:00:00.000");

List<TrackedEntityInstance> trackedEntityInstances =
d2.trackedEntityModule().trackedEntityInstanceQuery()
.byProgram().eq("lxAQ7Zs9VYR")
.byProgramDate().afterOrEqual(refDate)
.byProgramDate().beforeOrEqual(refDate)
.blockingGet();

assertThat(trackedEntityInstances.size()).isEqualTo(1);
}

@Test
public void find_by_event_date() throws ParseException {
Date refDate = DateUtils.DATE_FORMAT.parse("2015-05-01T00:00:00.000");

List<TrackedEntityInstance> trackedEntityInstances =
d2.trackedEntityModule().trackedEntityInstanceQuery()
.byProgram().eq("lxAQ7Zs9VYR")
.byEventDate().afterOrEqual(refDate)
.byEventDate().beforeOrEqual(refDate)
.blockingGet();

assertThat(trackedEntityInstances.size()).isEqualTo(1);
}

@Test
public void get_scope() {
TrackedEntityInstanceQueryRepositoryScope scope =
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/assets/migrations/99.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Adds column ProgramStage.dueDateLabel
ALTER TABLE ProgramStage ADD COLUMN dueDateLabel TEXT;
Loading

0 comments on commit 5c8455f

Please sign in to comment.