Skip to content

Commit

Permalink
Merge pull request #836 from dhis2/develop
Browse files Browse the repository at this point in the history
Develop 0.16.0
  • Loading branch information
vgarciabnz authored May 22, 2019
2 parents ac1d96b + 6762ce8 commit aea368e
Show file tree
Hide file tree
Showing 322 changed files with 9,959 additions and 2,360 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_DIR=$DIR/

# This will: compile the project, run lint, run tests under JVM, package apk, check the code quality and run tests on the device/emulator.
"$PROJECT_DIR"/gradlew clean build --scan connectedAndroidTest
"$PROJECT_DIR"/gradlew clean build --scan
22 changes: 14 additions & 8 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ext {
buildToolsVersion: "28.0.3",
minSdkVersion : 19,
targetSdkVersion : 28,
versionCode : 130,
versionName : "0.15.5-SNAPSHOT"
versionCode : 131,
versionName : "0.16.0-SNAPSHOT"
]

libraries = [
Expand All @@ -46,13 +46,14 @@ ext {
paging : '2.1.0',

// java
jackson : "2.8.5",
jackson : "2.9.8",
autovalue : "1.3",
autovaluecursor : "1.0.1",
retrofit : "2.1.0",
okhttp : "3.5.0",
retrofit : "2.5.0",
okhttp : "3.14.0",
duktape : "1.1.0",
dagger : "2.14.1",
rxjava : "2.2.8",

// code checks
findbugs : "3.0.0",
Expand Down Expand Up @@ -147,13 +148,17 @@ android {

dependencies {

api "io.reactivex.rxjava2:rxjava:${libraries.rxjava}"

// sqlbrite-migrations library
api "com.github.lykmapipo:sqlbrite-migrations:${libraries.sqlbritemigrations}"
api ("com.github.lykmapipo:sqlbrite-migrations:${libraries.sqlbritemigrations}") {
exclude group: 'io.reactivex.rxjava2', module: 'rxjava'
}

// Support libraries
api "androidx.annotation:annotation:${libraries.support}"

api "android.arch.paging:runtime:${libraries.paging}"
api "androidx.paging:paging-runtime:${libraries.paging}"

// Google's auto-value. Annotations are used only during compilation time, as well as

Expand All @@ -175,6 +180,7 @@ dependencies {
api "com.squareup.okhttp3:okhttp:${libraries.okhttp}"
api "com.squareup.retrofit2:retrofit:${libraries.retrofit}"
api "com.squareup.retrofit2:converter-jackson:${libraries.retrofit}"
api "com.squareup.retrofit2:adapter-rxjava2:${libraries.retrofit}"

// Apache libraries
api "org.apache.commons:commons-lang3:3.7"
Expand All @@ -187,7 +193,7 @@ dependencies {
api "joda-time:joda-time:2.9.9"

// sms compression library
compile 'com.github.eHealthAfrica:dhis2-sms-compression:0.0.9'
api 'com.github.eHealthAfrica:dhis2-sms-compression:0.0.9'

// Extension which generates mappers for work with cursor and content values
api "com.gabrielittner.auto.value:auto-value-cursor-annotations:${libraries.autovaluecursor}"
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=0.15.5-SNAPSHOT
VERSION_CODE=130
VERSION_NAME=0.16.0-SNAPSHOT
VERSION_CODE=131

GROUP=org.hisp.dhis

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@

package org.hisp.dhis.android.core;

import androidx.test.runner.AndroidJUnit4;

import org.hisp.dhis.android.core.common.D2Factory;
import org.hisp.dhis.android.core.data.database.AbsStoreTestCase;
import org.hisp.dhis.android.core.data.file.ResourcesFileReader;
import org.hisp.dhis.android.core.data.server.Dhis2MockServer;
import org.hisp.dhis.android.core.event.Event;
import org.hisp.dhis.android.core.event.EventStore;
Expand All @@ -45,6 +42,8 @@
import java.io.IOException;
import java.util.List;

import androidx.test.runner.AndroidJUnit4;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

Expand All @@ -59,7 +58,7 @@ public class EventWithLimitCallMockIntegrationShould extends AbsStoreTestCase {
public void setUp() throws IOException {
super.setUp();

dhis2MockServer = new Dhis2MockServer(new ResourcesFileReader());
dhis2MockServer = new Dhis2MockServer();

d2 = D2Factory.create(dhis2MockServer.getBaseEndpoint(), databaseAdapter());
}
Expand All @@ -81,7 +80,7 @@ public void download_events() throws Exception {
dhis2MockServer.enqueueMockResponse("systeminfo/system_info.json");
dhis2MockServer.enqueueMockResponse("event/events_1.json");

d2.eventModule().downloadSingleEvents(eventLimitByOrgUnit, false).call();
d2.eventModule().downloadSingleEvents(eventLimitByOrgUnit, false, false).call();

EventStore eventStore = EventStoreImpl.create(databaseAdapter());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

package org.hisp.dhis.android.core;

import android.util.Log;

import org.hisp.dhis.android.core.arch.call.D2Progress;
import org.hisp.dhis.android.core.common.D2Factory;
import org.hisp.dhis.android.core.data.database.AbsStoreTestCase;
import org.hisp.dhis.android.core.data.server.RealServerMother;
Expand All @@ -36,6 +39,8 @@

import java.io.IOException;

import io.reactivex.observers.TestObserver;

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

public class TeisCallRealIntegrationShould extends AbsStoreTestCase {
Expand All @@ -56,8 +61,15 @@ public void download_tracked_entity_instances() throws Exception {

d2.syncMetaData().call();

d2.trackedEntityModule().downloadTrackedEntityInstances(5, false).call();
TestObserver<D2Progress> testObserver = d2.trackedEntityModule().downloadTrackedEntityInstances(5, false, false)
.asObservable()
.doOnEach(e -> Log.w("EVENT", e.toString()))
.test();

testObserver.awaitTerminalEvent();

int count = TrackedEntityInstanceStoreImpl.create(databaseAdapter()).count();

assertThat(TrackedEntityInstanceStoreImpl.create(databaseAdapter()).count() >= 5).isTrue();
assertThat(count >= 5).isTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.hisp.dhis.android.core.D2;
import org.hisp.dhis.android.core.common.D2Factory;
import org.hisp.dhis.android.core.data.database.AbsStoreTestCase;
import org.hisp.dhis.android.core.data.file.ResourcesFileReader;
import org.hisp.dhis.android.core.data.server.Dhis2MockServer;
import org.junit.After;
import org.junit.Before;
Expand All @@ -54,7 +53,7 @@ public class CategoryEndpointCallShould extends AbsStoreTestCase {
@Before
public void setUp() throws IOException {
super.setUp();
dhis2MockServer = new Dhis2MockServer(new ResourcesFileReader());
dhis2MockServer = new Dhis2MockServer();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@

package org.hisp.dhis.android.core.common;

import androidx.test.InstrumentationRegistry;

import com.facebook.stetho.okhttp3.StethoInterceptor;

import org.hisp.dhis.android.core.D2;
import org.hisp.dhis.android.core.arch.api.retrofit.PreventURLDecodeInterceptor;
import org.hisp.dhis.android.core.configuration.Configuration;
import org.hisp.dhis.android.core.data.api.BasicAuthenticatorFactory;
import org.hisp.dhis.android.core.data.database.DatabaseAdapter;

import java.util.concurrent.TimeUnit;

import androidx.test.InstrumentationRegistry;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
Expand All @@ -49,21 +49,23 @@ public static D2 create(String url, DatabaseAdapter databaseAdapter) {
.serverUrl(HttpUrl.parse(url))
.build();

HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);

return new D2.Builder()
.configuration(config)
.databaseAdapter(databaseAdapter)
.okHttpClient(
new OkHttpClient.Builder()
.addInterceptor(BasicAuthenticatorFactory.create(databaseAdapter))
.addInterceptor(loggingInterceptor)
.addNetworkInterceptor(new StethoInterceptor())
.readTimeout(30, TimeUnit.SECONDS)
.build()
)
.okHttpClient(okHttpClient(databaseAdapter))
.context(InstrumentationRegistry.getTargetContext().getApplicationContext())
.build();
}

private static OkHttpClient okHttpClient(DatabaseAdapter databaseAdapter) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
return new OkHttpClient.Builder()
.addInterceptor(new PreventURLDecodeInterceptor())
.addInterceptor(BasicAuthenticatorFactory.create(databaseAdapter))
.addInterceptor(loggingInterceptor)
.addNetworkInterceptor(new StethoInterceptor())
.readTimeout(30, TimeUnit.SECONDS)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
import org.hisp.dhis.android.core.arch.api.retrofit.APIClientDIModule;
import org.hisp.dhis.android.core.common.D2Factory;
import org.hisp.dhis.android.core.common.ObjectStore;
import org.hisp.dhis.android.core.data.file.ResourcesFileReader;
import org.hisp.dhis.android.core.data.imports.TrackerImportConflictSamples;
import org.hisp.dhis.android.core.data.maintenance.D2ErrorSamples;
import org.hisp.dhis.android.core.data.server.Dhis2MockServer;
import org.hisp.dhis.android.core.imports.ImportStatus;
import org.hisp.dhis.android.core.imports.TrackerImportConflict;
import org.hisp.dhis.android.core.imports.TrackerImportConflictStore;
import org.hisp.dhis.android.core.maintenance.D2Error;
import org.hisp.dhis.android.core.maintenance.D2ErrorCode;
import org.hisp.dhis.android.core.maintenance.D2ErrorComponent;
Expand Down Expand Up @@ -71,50 +74,47 @@ public static void setUpClass() throws Exception {
InstrumentationRegistry.getTargetContext().getApplicationContext(), "synced.db");
sqLiteDatabase = dbOpenHelper.getWritableDatabase();
databaseAdapter = new SqLiteDatabaseAdapter(dbOpenHelper);
dhis2MockServer = new Dhis2MockServer(new ResourcesFileReader());
dhis2MockServer = new Dhis2MockServer();
d2 = D2Factory.create(dhis2MockServer.getBaseEndpoint(), databaseAdapter);
Stetho.initializeWithDefaults(InstrumentationRegistry.getTargetContext().getApplicationContext());

d2.wipeModule().wipeEverything();

dhis2MockServer.setRequestDispatcher();

login();
downloadMetadata();
downloadTrackedEntityInstances();
downloadEvents();
downloadAggregatedData();
storeSomeD2Errors();
storeSomeConflicts();
}
}

@AfterClass
public static void tearDownClass() throws IOException {
dhis2MockServer.shutdown();
sqLiteDatabase.close();
}

private static void login() throws Exception {
dhis2MockServer.enqueueLoginResponses();
d2.userModule().logIn("android", "Android123").call();
}

private static void downloadMetadata() throws Exception {
dhis2MockServer.enqueueMetadataResponses();
d2.syncMetaData().call();
}

private static void downloadTrackedEntityInstances() throws Exception {
dhis2MockServer.enqueueTrackedEntityInstanceResponses();
d2.trackedEntityModule().downloadTrackedEntityInstances(2, false).call();
private static void downloadTrackedEntityInstances() {
d2.trackedEntityModule().downloadTrackedEntityInstances(2, false, false).asObservable().subscribe();
}

private static void downloadEvents() throws Exception {
dhis2MockServer.enqueueEventResponses();
d2.eventModule().downloadSingleEvents(2, false).call();
d2.eventModule().downloadSingleEvents(2, false, false).call();
}

private static void downloadAggregatedData() throws Exception {
dhis2MockServer.enqueueAggregatedDataResponses();
d2.aggregatedModule().data().download().call();
private static void downloadAggregatedData() {
d2.aggregatedModule().data().download().asObservable().subscribe();
}

private static void storeSomeD2Errors() {
Expand All @@ -132,6 +132,28 @@ private static void storeSomeD2Errors() {
);
}

private static void storeSomeConflicts() {
ObjectStore<TrackerImportConflict> trackerImportConflictStore =
TrackerImportConflictStore.create(databaseAdapter);
trackerImportConflictStore.insert(TrackerImportConflictSamples.get().toBuilder()
.trackedEntityInstance(null)
.enrollment(null)
.event(null)
.build());

trackerImportConflictStore.insert(TrackerImportConflictSamples.get().toBuilder()
.conflict("conflict_2")
.value("value_2")
.trackedEntityInstance("nWrB0TfWlvh")
.enrollment("enroll2")
.event("event2")
.tableReference("table_reference_2")
.errorCode("error_code_2")
.status(ImportStatus.ERROR)
.build()
);
}

protected D2DIComponent getD2DIComponent() {
return DaggerD2DIComponent.builder()
.databaseDIModule(new DatabaseDIModule(databaseAdapter))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
public class RealServerMother {
public static String url2_29 = "https://play.dhis2.org/2.29/api/";
public static String url2_30 = "https://play.dhis2.org/2.30/api/";
public static String url2_31 = "https://play.dhis2.org/2.31.0/api/";
public static String url2_31 = "https://play.dhis2.org/2.31.3/api/";
public static String url2_32 = "https://play.dhis2.org/2.32.0/api/";
public static String url_dev = "https://play.dhis2.org/dev/api/";
public static String android_current = "https://play.dhis2.org/android-current/api/";
public static String url = android_current;
Expand Down
Loading

0 comments on commit aea368e

Please sign in to comment.