Skip to content

Commit

Permalink
Merge pull request #1971 from dhis2/1.8.1-rc
Browse files Browse the repository at this point in the history
fix: [1.8.1-RC] Version 1.8.1
  • Loading branch information
vgarciabnz authored Jun 7, 2023
2 parents 154943b + fe6513a commit 125da2d
Show file tree
Hide file tree
Showing 132 changed files with 3,652 additions and 3,383 deletions.
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.8.0
VERSION_CODE=280
VERSION_NAME=1.8.1
VERSION_CODE=281

GROUP=org.hisp.dhis

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,20 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.android.core

package org.hisp.dhis.android.core;
import android.util.Log
import io.reactivex.schedulers.Schedulers
import org.hisp.dhis.android.core.arch.call.D2Progress
import org.hisp.dhis.android.core.user.User

import android.util.Log;

import io.reactivex.schedulers.Schedulers;

public class MetadataCallRealIntegrationShould extends BaseRealIntegrationTest {
class MetadataCallRealIntegrationShould : BaseRealIntegrationTest() {
/**
* A quick integration test that is probably flaky, but will help with finding bugs related to
* the
* metadataSyncCall. It works against the demo server.
*/

/* How to extract database from tests:
/* How to extract database from tests:
edit: AbsStoreTestCase.java (adding database name.)
DbOpenHelper dbOpenHelper = new DbOpenHelper(InstrumentationRegistry.getTargetContext()
.getApplicationContext(),
Expand All @@ -53,59 +52,55 @@ make a debugger break point where desired (after sync complete)
in datagrip:
pragma foreign_keys = on;
pragma foreign_key_check;*/
// This test is uncommented because technically it is flaky.
// It depends on a live server to operate and the login is hardcoded here.
// Uncomment in order to quickly test changes vs a real server, but keep it uncommented after.

//This test is uncommented because technically it is flaky.
//It depends on a live server to operate and the login is hardcoded here.
//Uncomment in order to quickly test changes vs a real server, but keep it uncommented after.
//@Test
public void response_successful_on_sync_meta_data_once() throws Exception {
d2.userModule().logIn(username, password, url).blockingGet();
// @Test
fun response_successful_on_sync_meta_data_once() {
d2.userModule().logIn(username, password, url).blockingGet()

d2.metadataModule().blockingDownload();
d2.metadataModule().blockingDownload()

//TODO: add additional sync + break point.
//when debugger stops at the new break point manually change metadata online & resume.
//This way I can make sure that additive (updates) work as well.
//The changes could be to one of the programs, adding stuff to it.
// TODO: add additional sync + break point.
// when debugger stops at the new break point manually change metadata online & resume.
// This way I can make sure that additive (updates) work as well.
// The changes could be to one of the programs, adding stuff to it.
// adding a new program..etc.
}

//@Test
public void download_metadata_in_io_scheduler() throws Exception {
// @Test
fun download_metadata_in_io_scheduler() {
d2.userModule().logIn(username, password, url)
.flatMapObservable(user -> d2.metadataModule().download())
.subscribeOn(Schedulers.io())
.subscribe(progress -> Log.i("META", progress.lastCall()));
.flatMapObservable { user: User? -> d2.metadataModule().download() }
.subscribeOn(Schedulers.io())
.subscribe { progress: D2Progress -> Log.i("META", progress.lastCall()!!) }

Thread.sleep(60000);
Thread.sleep(60000)
}

//@Test
public void response_successful_on_sync_meta_data_two_times() throws Exception {
d2.userModule().logIn(username, password, url).blockingGet();
// @Test
fun response_successful_on_sync_meta_data_two_times() {
d2.userModule().logIn(username, password, url).blockingGet()

//first sync:
d2.metadataModule().blockingDownload();
// first sync:
d2.metadataModule().blockingDownload()

//second sync:
d2.metadataModule().blockingDownload();
// second sync:
d2.metadataModule().blockingDownload()
}

//@Test
public void response_successful_on_login_wipe_db_and_login() throws Exception {
d2.userModule().logIn(username, password, url).blockingGet();

d2.wipeModule().wipeEverything();

d2.userModule().logIn(username, password, url).blockingGet();
// @Test
fun response_successful_on_login_wipe_db_and_login() {
d2.userModule().logIn(username, password, url).blockingGet()
d2.wipeModule().wipeEverything()
d2.userModule().logIn(username, password, url).blockingGet()
}

//@Test
public void response_successful_on_login_logout_and_login() throws Exception {
d2.userModule().logIn(username, password, url).blockingGet();

d2.userModule().logOut().blockingAwait();

d2.userModule().logIn(username, password, url).blockingGet();
// @Test
fun response_successful_on_login_logout_and_login() {
d2.userModule().logIn(username, password, url).blockingGet()
d2.userModule().logOut().blockingAwait()
d2.userModule().logIn(username, password, url).blockingGet()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AnalyticsVisualizationRepositoryIntegrationShould : BaseMockIntegrationTes

assertThat(result.dimensions.columns.size).isEqualTo(1)
assertThat(result.dimensions.rows.size).isEqualTo(1)
assertThat(result.dimensionItems[Dimension.Data]!!.size).isEqualTo(2)
assertThat(result.dimensionItems[Dimension.Data]!!.size).isEqualTo(3)
assertThat(result.dimensionItems[Dimension.OrganisationUnit]!!.size).isEqualTo(1)
assertThat(result.dimensionItems[Dimension.Period]!!.size).isEqualTo(3)
assertThat(result.metadata).isNotEmpty()
Expand All @@ -65,7 +65,7 @@ class AnalyticsVisualizationRepositoryIntegrationShould : BaseMockIntegrationTes

assertThat(result.dimensions.columns.size).isEqualTo(1)
assertThat(result.dimensions.rows.size).isEqualTo(1)
assertThat(result.dimensionItems[Dimension.Data]!!.size).isEqualTo(2)
assertThat(result.dimensionItems[Dimension.Data]!!.size).isEqualTo(3)
assertThat(result.dimensionItems[Dimension.OrganisationUnit]!!.size).isEqualTo(1)
assertThat(result.dimensionItems[Dimension.Period]).isEqualTo(
listOf(
Expand Down Expand Up @@ -113,7 +113,7 @@ class AnalyticsVisualizationRepositoryIntegrationShould : BaseMockIntegrationTes

assertThat(result.dimensions.columns.size).isEqualTo(1)
assertThat(result.dimensions.rows.size).isEqualTo(1)
assertThat(result.dimensionItems[Dimension.Data]!!.size).isEqualTo(2)
assertThat(result.dimensionItems[Dimension.Data]!!.size).isEqualTo(3)
assertThat(result.dimensionItems[Dimension.OrganisationUnit]).isEqualTo(
listOf(
DimensionItem.OrganisationUnitItem.Relative(RelativeOrganisationUnit.USER_ORGUNIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,26 @@ import org.hisp.dhis.android.core.common.RelativeOrganisationUnit
import org.hisp.dhis.android.core.common.RelativePeriod
import org.hisp.dhis.android.core.constant.internal.ConstantStore
import org.hisp.dhis.android.core.dataelement.internal.DataElementStore
import org.hisp.dhis.android.core.datavalue.DataValue
import org.hisp.dhis.android.core.datavalue.internal.DataValueStore
import org.hisp.dhis.android.core.enrollment.Enrollment
import org.hisp.dhis.android.core.enrollment.internal.EnrollmentStoreImpl
import org.hisp.dhis.android.core.event.Event
import org.hisp.dhis.android.core.event.internal.EventStoreImpl
import org.hisp.dhis.android.core.expressiondimensionitem.internal.ExpressionDimensionItemStore
import org.hisp.dhis.android.core.indicator.internal.IndicatorStore
import org.hisp.dhis.android.core.indicator.internal.IndicatorTypeStore
import org.hisp.dhis.android.core.organisationunit.internal.OrganisationUnitGroupStore
import org.hisp.dhis.android.core.organisationunit.internal.OrganisationUnitLevelStore
import org.hisp.dhis.android.core.organisationunit.internal.OrganisationUnitStore
import org.hisp.dhis.android.core.parser.internal.service.ExpressionService
import org.hisp.dhis.android.core.period.internal.PeriodStoreImpl
import org.hisp.dhis.android.core.program.internal.ProgramStageStore
import org.hisp.dhis.android.core.program.internal.ProgramStore
import org.hisp.dhis.android.core.relationship.internal.*
import org.hisp.dhis.android.core.trackedentity.TrackedEntityAttributeValue
import org.hisp.dhis.android.core.trackedentity.TrackedEntityDataValue
import org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance
import org.hisp.dhis.android.core.trackedentity.internal.*
import org.hisp.dhis.android.core.utils.integration.mock.BaseMockIntegrationTestEmptyDispatcher
import org.junit.After
Expand Down Expand Up @@ -130,6 +138,15 @@ internal open class BaseEvaluatorIntegrationShould : BaseMockIntegrationTestEmpt

protected val constantStore = ConstantStore.create(databaseAdapter)

protected val expressionDimensionItemStore = ExpressionDimensionItemStore.create(databaseAdapter)

protected val expressionService = ExpressionService(
dataElementStore,
categoryOptionComboStore,
organisationUnitGroupStore,
programStageStore
)

protected val metadata: Map<String, MetadataItem> = mapOf(
orgunitParent.uid() to MetadataItem.OrganisationUnitItem(orgunitParent),
orgunitChild1.uid() to MetadataItem.OrganisationUnitItem(orgunitChild1),
Expand Down Expand Up @@ -181,6 +198,7 @@ internal open class BaseEvaluatorIntegrationShould : BaseMockIntegrationTestEmpt

@Before
fun setUpBase() {
println("AAAA setUpBase")
organisationUnitLevelStore.insert(level1)
organisationUnitLevelStore.insert(level2)

Expand Down Expand Up @@ -233,6 +251,7 @@ internal open class BaseEvaluatorIntegrationShould : BaseMockIntegrationTestEmpt

@After
fun tearDown() {
println("AAAA tearDown")
organisationUnitLevelStore.delete()
organisationUnitStore.delete()
organisationUnitGroupStore.delete()
Expand All @@ -256,4 +275,99 @@ internal open class BaseEvaluatorIntegrationShould : BaseMockIntegrationTestEmpt
relationshipConstraintStore.delete()
constantStore.delete()
}

protected fun createDataValue(
value: String,
dataElementUid: String = dataElement1.uid(),
orgunitUid: String = orgunitParent.uid(),
periodId: String = period201912.periodId()!!,
categoryOptionComboUid: String = categoryOptionCombo.uid(),
attributeOptionComboUid: String = attributeOptionCombo.uid()
) {
val dataValue = DataValue.builder()
.value(value)
.dataElement(dataElementUid)
.period(periodId)
.organisationUnit(orgunitUid)
.categoryOptionCombo(categoryOptionComboUid)
.attributeOptionCombo(attributeOptionComboUid)
.build()

dataValueStore.insert(dataValue)
}

protected fun createEventAndValue(
value: String,
dataElementUid: String,
enrollmentUid: String? = null
) {
val event = Event.builder()
.uid(BaseEvaluatorSamples.generator.generate())
.eventDate(period201912.startDate())
.enrollment(enrollmentUid)
.program(program.uid())
.programStage(programStage1.uid())
.organisationUnit(orgunitChild1.uid())
.deleted(false)
.build()

eventStore.insert(event)

val dataValue = TrackedEntityDataValue.builder()
.event(event.uid())
.dataElement(dataElementUid)
.value(value)
.build()

trackedEntityDataValueStore.insert(dataValue)
}

protected fun createTEIAndAttribute(
value: String?,
attributeUid: String
) {
val tei = TrackedEntityInstance.builder()
.uid(BaseEvaluatorSamples.generator.generate())
.trackedEntityType(trackedEntityType.uid())
.organisationUnit(orgunitChild1.uid())
.deleted(false)
.build()

trackedEntityStore.insert(tei)

val enrollment = Enrollment.builder()
.uid(BaseEvaluatorSamples.generator.generate())
.trackedEntityInstance(tei.uid())
.organisationUnit(orgunitChild1.uid())
.program(program.uid())
.deleted(false)
.build()

enrollmentStore.insert(enrollment)

val attributeValue = TrackedEntityAttributeValue.builder()
.trackedEntityInstance(tei.uid())
.trackedEntityAttribute(attributeUid)
.value(value)
.build()

trackedEntityAttributeValueStore.insert(attributeValue)
createEventAndValue("0", dataElement1.uid(), enrollment.uid())
}

protected fun de(dataElementUid: String): String {
return "#{$dataElementUid}"
}

protected fun eventDE(programUid: String, dataElementUid: String): String {
return "D{$programUid.$dataElementUid}"
}

protected fun eventAtt(programUid: String, attributeUid: String): String {
return "A{$programUid.$attributeUid}"
}

protected fun cons(constantUid: String): String {
return "C{$constantUid}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import org.hisp.dhis.android.core.analytics.aggregated.internal.evaluator.BaseEv
import org.hisp.dhis.android.core.common.AggregationType
import org.hisp.dhis.android.core.common.RelativeOrganisationUnit
import org.hisp.dhis.android.core.common.RelativePeriod
import org.hisp.dhis.android.core.datavalue.DataValue
import org.hisp.dhis.android.core.utils.runner.D2JunitRunner
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -454,26 +453,6 @@ internal class DataElementSQLEvaluatorIntegrationShould : BaseEvaluatorIntegrati
assertThat(dataElementEvaluator.evaluate(overrideEvaluationItem, metadata)).isEqualTo("5.5")
}

private fun createDataValue(
value: String,
dataElementUid: String = dataElement1.uid(),
orgunitUid: String = orgunitParent.uid(),
periodId: String = period201912.periodId()!!,
categoryOptionComboUid: String = categoryOptionCombo.uid(),
attributeOptionComboUid: String = attributeOptionCombo.uid()
) {
val dataValue = DataValue.builder()
.value(value)
.dataElement(dataElementUid)
.period(periodId)
.organisationUnit(orgunitUid)
.categoryOptionCombo(categoryOptionComboUid)
.attributeOptionCombo(attributeOptionComboUid)
.build()

dataValueStore.insert(dataValue)
}

private fun evaluateAggregation(
periodId: String,
aggregator: AggregationType
Expand Down
Loading

0 comments on commit 125da2d

Please sign in to comment.