Skip to content

Commit

Permalink
Merge pull request #1335 from dhis2/1.2.0
Browse files Browse the repository at this point in the history
feat: [MASTER] Version 1.2.0
  • Loading branch information
vgarciabnz authored Jul 31, 2020
2 parents 4dc6ad8 + e75ed44 commit 244b47e
Show file tree
Hide file tree
Showing 568 changed files with 22,391 additions and 7,357 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ branches:
only:
- master
- develop
- master-sms
- master-dev
- validation-rules
script:
- travis_wait 70 "./build.sh"
before_script:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Main goals:

## Documentation

User-oriented documentation can be found in [Documentation section](https://docs.dhis2.org/master/en/dhis2_android_sdk_developer_guide/about-this-guide.html) in DHIS2 web. It is intended to be used by developers.
Developer-oriented documentation can be found in [Documentation section](https://docs.dhis2.org/master/en/dhis2_android_sdk_developer_guide/about-this-guide.html) in DHIS2 web. It is intended to be used by developers.

## Examples

Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: "com.gradle.build-scan"

buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
mavenLocal()
Expand All @@ -20,12 +21,14 @@ buildscript {

// enables cloud features of gradle plugin
classpath "com.gradle:build-scan-plugin:2.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
maven { url "https://maven.google.com" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
jcenter()
google()
maven { url "https://jitpack.io" }
Expand Down
3 changes: 3 additions & 0 deletions core/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/build
gradle/wrapper
gradlew
gradlew.bat
18 changes: 15 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
*/

apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
apply from: project.file("plugins/android-checkstyle.gradle")
apply from: project.file("plugins/android-findbugs.gradle")
apply from: project.file("plugins/android-pmd.gradle")
Expand All @@ -36,8 +38,8 @@ ext {
buildToolsVersion: "28.0.3",
minSdkVersion : 19,
targetSdkVersion : 28,
versionCode : 212,
versionName : "1.1.2"
versionCode : 220,
versionName : "1.2.0"
]

libraries = [
Expand Down Expand Up @@ -66,7 +68,7 @@ ext {
assertj : "3.11.1",
mockito : "2.24.5",
dexmaker : "2.21.0",
truth : "0.31",
truth : "0.30",
testrunner : '1.1.0-alpha4',
equalsverifier : "2.1.8",
stetho : "1.5.0",
Expand Down Expand Up @@ -190,6 +192,9 @@ dependencies {
// sms compression library
api 'com.github.dhis2:sms-compression:0.2.0'

// DHIS 2 antlr expression parser
api "org.hisp.dhis.parser:dhis-antlr-expression-parser:1.0.7-SNAPSHOT"

// Extension which generates mappers for work with cursor and content values
api "com.gabrielittner.auto.value:auto-value-cursor-annotations:${libraries.autovaluecursor}"
annotationProcessor "com.gabrielittner.auto.value:auto-value-cursor:${libraries.autovaluecursor}"
Expand All @@ -198,6 +203,8 @@ dependencies {

api "com.google.code.findbugs:annotations:${libraries.findbugs}"

api "org.antlr:antlr4-runtime:4.7.2"

api "com.squareup.okhttp3:mockwebserver:${libraries.okhttp}"

// Java test dependencies
Expand Down Expand Up @@ -226,6 +233,11 @@ dependencies {
exclude module: 'okhttp'
exclude module: 'jsr305'
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

apply from: project.file("plugins/gradle-mvn-push.gradle")
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
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.1.2
VERSION_CODE=212
VERSION_NAME=1.2.0
VERSION_CODE=220

GROUP=org.hisp.dhis

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2004-2019, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (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;

import android.content.Context;

import androidx.test.InstrumentationRegistry;

import org.hisp.dhis.android.core.arch.db.access.DatabaseAdapter;
import org.hisp.dhis.android.core.arch.db.access.internal.DatabaseAdapterFactory;
import org.hisp.dhis.android.core.arch.storage.internal.InMemorySecureStore;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;

public abstract class BaseIntegrationTestWithDatabase {
private DatabaseAdapter databaseAdapter;

@Before
public void setUp() throws IOException {
Context context = InstrumentationRegistry.getTargetContext().getApplicationContext();
DatabaseAdapterFactory databaseAdapterFactory = DatabaseAdapterFactory.create(context, new InMemorySecureStore());
databaseAdapter = databaseAdapterFactory.newParentDatabaseAdapter();
databaseAdapterFactory.createOrOpenDatabase(databaseAdapter, null, false);
}

@After
public void tearDown() {
databaseAdapter.close();
}

protected DatabaseAdapter databaseAdapter() {
return databaseAdapter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,13 @@

import org.hisp.dhis.android.core.arch.call.internal.GenericCallData;
import org.hisp.dhis.android.core.arch.d2.internal.D2DIComponent;
import org.hisp.dhis.android.core.arch.db.access.DatabaseAdapter;
import org.hisp.dhis.android.core.arch.db.access.internal.DatabaseAdapterFactory;
import org.hisp.dhis.android.core.arch.storage.internal.InMemorySecureStore;
import org.hisp.dhis.android.core.data.server.RealServerMother;
import org.hisp.dhis.android.core.resource.internal.ResourceHandler;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;
import java.util.Date;

import static com.google.common.truth.Truth.assertThat;

public abstract class BaseRealIntegrationTest {
private DatabaseAdapter databaseAdapter;

protected Date serverDate = new Date();
protected ResourceHandler resourceHandler;

protected String username = RealServerMother.username;
protected String password = RealServerMother.password;
Expand All @@ -62,28 +51,13 @@ public abstract class BaseRealIntegrationTest {
@Before
public void setUp() throws IOException {
Context context = InstrumentationRegistry.getTargetContext().getApplicationContext();

DatabaseAdapterFactory databaseAdapterFactory = DatabaseAdapterFactory.create(context, new InMemorySecureStore());
databaseAdapter = databaseAdapterFactory.newParentDatabaseAdapter();
databaseAdapterFactory.createOrOpenDatabase(databaseAdapter, null, false);
resourceHandler = ResourceHandler.create(databaseAdapter);
resourceHandler.setServerDate(serverDate);
Stetho.initializeWithDefaults(context);
}

@After
public void tearDown() throws IOException {
assertThat(databaseAdapter).isNotNull();
databaseAdapter.close();
}

protected DatabaseAdapter databaseAdapter() {
return databaseAdapter;
}

protected GenericCallData getGenericCallData(D2 d2) {
return GenericCallData.create(
databaseAdapter(), d2.retrofit(), resourceHandler, d2.systemInfoModule().versionManager());
d2.databaseAdapter(), d2.retrofit(), ResourceHandler.create(d2.databaseAdapter()),
d2.systemInfoModule().versionManager());
}

protected D2DIComponent getD2DIComponent(D2 d2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
* (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.program.programindicatorengine;
import org.hisp.dhis.android.core.arch.d2.internal.D2DIComponent

final class StringUtils {

private StringUtils() {
// no instances
}

static boolean isEmpty(CharSequence charSequence) {
return charSequence == null || charSequence.length() == 0;
object D2DIComponentAccessor {
fun getD2DIComponent(d2: D2): D2DIComponent {
return d2.d2DIComponent
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static D2 forNewDatabaseInternal(SecureStore secureStore, InsecureStore
return d2;
}

private static D2Configuration d2Configuration(Context context) {
public static D2Configuration d2Configuration(Context context) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
return D2Configuration.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import android.util.Log;

import org.hisp.dhis.android.core.arch.call.D2Progress;
import org.hisp.dhis.android.core.trackedentity.internal.TrackedEntityInstanceStoreImpl;
import org.junit.Before;

import java.io.IOException;
Expand Down Expand Up @@ -64,10 +63,8 @@ public void download_tracked_entity_instances() {

testObserver.awaitTerminalEvent();

int count = TrackedEntityInstanceStoreImpl.create(databaseAdapter()).count();
int count = d2.trackedEntityModule().trackedEntityInstances().blockingCount();

assertThat(count >= 5).isTrue();

testObserver.dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,28 @@

import org.hisp.dhis.android.core.arch.handlers.internal.Handler;
import org.hisp.dhis.android.core.arch.repositories.object.ReadOnlyOneObjectRepositoryFinalImpl;
import org.hisp.dhis.android.core.data.trackedentity.TrackedEntityTypeSamples;
import org.hisp.dhis.android.core.relationship.RelationshipConstraintType;
import org.hisp.dhis.android.core.relationship.RelationshipEntityType;
import org.hisp.dhis.android.core.relationship.RelationshipType;
import org.hisp.dhis.android.core.relationship.RelationshipTypeCollectionRepository;
import org.hisp.dhis.android.core.trackedentity.TrackedEntityType;
import org.hisp.dhis.android.core.utils.integration.mock.BaseMockIntegrationTestEmptyDispatcher;
import org.hisp.dhis.android.core.utils.runner.D2JunitRunner;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.List;

import static com.google.common.truth.Truth.assertThat;
import static org.hisp.dhis.android.core.arch.repositories.collection.RelationshipTypeAsserts.assertTypesWithoutConstraints;
import static org.hisp.dhis.android.core.data.relationship.RelationshipTypeSamples.RELATIONSHIP_TYPE_1;
import static org.hisp.dhis.android.core.data.relationship.RelationshipTypeSamples.RELATIONSHIP_TYPE_2;
import static org.hisp.dhis.android.core.data.relationship.RelationshipTypeSamples.RELATIONSHIP_TYPE_3;
import static org.hisp.dhis.android.core.data.relationship.RelationshipTypeSamples.RELATIONSHIP_TYPE_UID_1;
import static org.hisp.dhis.android.core.data.relationship.RelationshipTypeSamples.RELATIONSHIP_TYPE_UID_2;
import static org.hisp.dhis.android.core.data.relationship.RelationshipTypeSamples.TET_FOR_RELATIONSHIP_3_UID;

@RunWith(D2JunitRunner.class)
public class ReadOnlyIdentifiableCollectionRepositoryImplIntegrationShould extends BaseMockIntegrationTestEmptyDispatcher {
Expand All @@ -55,9 +63,12 @@ public static void setUpClass() throws Exception {
BaseMockIntegrationTestEmptyDispatcher.setUpClass();

Handler<RelationshipType> handler = objects.d2DIComponent.relationshipTypeHandler();
Handler<TrackedEntityType> tetHandler = objects.d2DIComponent.trackedEntityTypeHandler();

tetHandler.handle(TrackedEntityTypeSamples.get());
handler.handle(RELATIONSHIP_TYPE_1);
handler.handle(RELATIONSHIP_TYPE_2);
handler.handle(RELATIONSHIP_TYPE_3);

relationshipTypeCollectionRepository = d2.relationshipModule().relationshipTypes();
}
Expand All @@ -70,6 +81,32 @@ public void get_relationship_1_from_object_repository_without_children() {
assertTypesWithoutConstraints(typeFromRepository, RELATIONSHIP_TYPE_1);
}

@Test
public void get_relationship_by_from_tracked_entity_type() {
List<RelationshipType> typesFromRepository = relationshipTypeCollectionRepository
.byConstraint(RelationshipEntityType.TRACKED_ENTITY_INSTANCE, TET_FOR_RELATIONSHIP_3_UID)
.withConstraints()
.blockingGet();

assertThat(typesFromRepository.size()).isEqualTo(2);
}

@Test
public void get_relationship_by_from_tracked_entity_type_and_constraint_type() {
List<RelationshipType> typesFromRepository = relationshipTypeCollectionRepository
.byConstraint(
RelationshipEntityType.TRACKED_ENTITY_INSTANCE,
TET_FOR_RELATIONSHIP_3_UID,
RelationshipConstraintType.FROM)
.withConstraints()
.blockingGet();

assertThat(typesFromRepository.size()).isEqualTo(1);
assertThat(typesFromRepository.get(0).uid()).isEqualTo(RELATIONSHIP_TYPE_3.uid());
assertThat(typesFromRepository.get(0).fromConstraint().trackedEntityType().uid())
.isEqualTo(TET_FOR_RELATIONSHIP_3_UID);
}

@Test
public void get_relationship_2_from_object_repository_without_children() {
ReadOnlyOneObjectRepositoryFinalImpl<RelationshipType> type1Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
import org.hisp.dhis.android.core.data.database.LinkStoreAbstractIntegrationShould;
import org.hisp.dhis.android.core.utils.integration.mock.TestDatabaseAdapterFactory;
import org.hisp.dhis.android.core.utils.runner.D2JunitRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Map;

import static com.google.common.truth.Truth.assertThat;

@RunWith(D2JunitRunner.class)
public class CategoryCategoryComboLinkStoreIntegrationShould
extends LinkStoreAbstractIntegrationShould<CategoryCategoryComboLink> {
Expand All @@ -61,4 +66,14 @@ protected CategoryCategoryComboLink buildObjectWithOtherMasterUid() {
.categoryCombo("new_category_combo")
.build();
}

@Test
public void count_by_master_column() {
store.insert(buildObjectWithOtherMasterUid());
store.insert(buildObject());
Map<String, Integer> count = store.groupAndGetCountBy(CategoryCategoryComboLinkTableInfo.Columns.CATEGORY_COMBO);
assertThat(count.keySet().size()).isEqualTo(2);
assertThat(count.get(buildObjectWithOtherMasterUid().categoryCombo())).isEqualTo(1);
assertThat(count.get(buildObject().categoryCombo())).isEqualTo(1);
}
}
Loading

0 comments on commit 244b47e

Please sign in to comment.