Skip to content

Commit

Permalink
Merge pull request #255 from dhis2/develop
Browse files Browse the repository at this point in the history
Develop 0.9.2
  • Loading branch information
josemp10 authored Jun 11, 2018
2 parents 80e267d + 667ca0a commit 052b1bf
Show file tree
Hide file tree
Showing 175 changed files with 2,723 additions and 2,398 deletions.
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ buildscript {

allprojects {
repositories {
maven { url "https://maven.google.com" }
jcenter()
maven { url "https://jitpack.io" }
}
Expand All @@ -54,8 +55,8 @@ ext {
buildToolsVersion: "25.0.2",
minSdkVersion : 15,
targetSdkVersion : 25,
versionCode : 91,
versionName : "0.9.1-SNAPSHOT"
versionCode : 92,
versionName : "0.9.2-SNAPSHOT"
]

libraries = [
Expand Down Expand Up @@ -87,5 +88,8 @@ ext {

//database
sqlbritemigrations : "v1.0.1",

// google
safetynet : "15.0.1",
]
}
3 changes: 3 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ dependencies {
// Jackson
compile "com.fasterxml.jackson.core:jackson-databind:${libraries.jackson}"

// Google's play services
compile "com.google.android.gms:play-services-safetynet:${libraries.safetynet}"

// Square libraries
compile "com.squareup.okhttp3:okhttp:${libraries.okhttp}"
compile "com.squareup.retrofit2:retrofit:${libraries.retrofit}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.hisp.dhis.android.core.category.CategoryCategoryComboLinkModel;
import org.hisp.dhis.android.core.category.CategoryComboModel;
import org.hisp.dhis.android.core.category.CategoryModel;
import org.hisp.dhis.android.core.category.CategoryOptionComboCategoryLinkModel;
import org.hisp.dhis.android.core.category.CategoryOptionComboCategoryOptionLinkModel;
import org.hisp.dhis.android.core.category.CategoryOptionComboModel;
import org.hisp.dhis.android.core.category.CategoryOptionModel;
import org.hisp.dhis.android.core.common.D2Factory;
Expand All @@ -27,11 +27,8 @@
import org.junit.Test;

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

import retrofit2.Response;

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

Expand Down Expand Up @@ -115,28 +112,10 @@ public void delete_authenticate_user_table_only_when_log_out_after_sync_metadata
.isNotEmptyTable(CategoryComboModel.TABLE)
.isNotEmptyTable(CategoryCategoryComboLinkModel.TABLE)
.isNotEmptyTable(CategoryOptionComboModel.TABLE)
.isNotEmptyTable(CategoryOptionComboCategoryLinkModel.TABLE)
.isNotEmptyTable(CategoryOptionComboCategoryOptionLinkModel.TABLE)
.isNotEmptyTable(ResourceModel.TABLE);
}

@Test
public void have_organisation_units_descendants_after_login_wipe_and_login()
throws Exception {
givenALoginWithSierraLeonaOUInDatabase();

givenAMetadataWithDescendantsInDatabase();

verifyExistsAsignedOrgUnitAndDescendants();

d2.wipeDB().call();

givenALoginWithSierraLeonaOUInDatabase();

givenAMetadataWithDescendantsInDatabase();

verifyExistsAsignedOrgUnitAndDescendants();
}

@Test
public void complete_login_and_sync_metadata_successfully_after_logout()
throws Exception {
Expand Down Expand Up @@ -172,26 +151,9 @@ private void givenALoginInDatabase() throws Exception {
d2.logIn("user", "password").call();
}

private void givenALoginWithSierraLeonaOUInDatabase() throws Exception {
dhis2MockServer.enqueueMockResponse("admin/login.json", new Date());
dhis2MockServer.enqueueMockResponse("system_info.json", new Date());

d2.logIn("user", "password").call();
}

private void givenAMetadataInDatabase() throws Exception {
dhis2MockServer.enqueueMetadataResponses();
Response response = d2.syncMetaData().call();

assertThat(response.isSuccessful(), is(true));
}

private void givenAMetadataWithDescendantsInDatabase() throws Exception {
dhis2MockServer.enqueueMetadataWithDescendentsResponses();

Response response = d2.syncMetaData().call();

assertThat(response.isSuccessful(), is(true));
d2.syncMetaData().call();
}

private void givenAEventInDatabase() throws Exception {
Expand All @@ -206,18 +168,4 @@ private void givenAEventInDatabase() throws Exception {

assertThat(events.isEmpty(), is(false));
}

private void verifyExistsAsignedOrgUnitAndDescendants() {
//Sierra leona
DatabaseAssert.assertThatDatabase(databaseAdapter())
.ifValueExist(OrganisationUnitModel.TABLE,
OrganisationUnitModel.Columns.UID,
"ImspTQPwCqd");

//Sierra leona descendant
DatabaseAssert.assertThatDatabase(databaseAdapter())
.ifValueExist(OrganisationUnitModel.TABLE,
OrganisationUnitModel.Columns.CODE,
"OU_278371");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import java.io.IOException;

import retrofit2.Response;

import static com.google.common.truth.Truth.assertThat;
import static org.hisp.dhis.android.core.data.database.SqliteCheckerUtility.isDatabaseEmpty;
import static org.hisp.dhis.android.core.data.database.SqliteCheckerUtility.isTableEmpty;
Expand All @@ -37,8 +35,7 @@ public void setUp() throws IOException {
public void have_empty_database_when_wipe_db_after_sync_metadata() throws Exception {
d2.logIn("android", "Android123").call();

Response response = d2.syncMetaData().call();
assertThat(response.isSuccessful()).isTrue();
d2.syncMetaData().call();

DatabaseAssert.assertThatDatabase(databaseAdapter()).isNotEmpty();

Expand All @@ -51,8 +48,7 @@ public void have_empty_database_when_wipe_db_after_sync_metadata() throws Except
public void have_empty_database_when_wipe_db_after_sync_data() throws Exception {
d2.logIn("android", "Android123").call();

Response response = d2.syncMetaData().call();
assertThat(response.isSuccessful()).isTrue();
d2.syncMetaData().call();

EventEndpointCall eventCall = EventCallFactory.create(
d2.retrofit(), databaseAdapter(), "DiszpKrYNg8", 0);
Expand All @@ -70,8 +66,7 @@ public void have_empty_database_when_wipe_db_after_sync_data() throws Exception
public void delete_autenticate_user_table_only_when_log_out_after_sync_data() throws Exception {
d2.logIn("android", "Android123").call();

Response response = d2.syncMetaData().call();
assertThat(response.isSuccessful()).isTrue();
d2.syncMetaData().call();

EventEndpointCall eventCall = EventCallFactory.create(
d2.retrofit(), databaseAdapter(), "DiszpKrYNg8", 0);
Expand All @@ -93,8 +88,7 @@ public void delete_autenticate_user_table_only_when_log_out_after_sync_metadata(
throws Exception {
d2.logIn("android", "Android123").call();

retrofit2.Response response = d2.syncMetaData().call();
assertThat(response.isSuccessful()).isTrue();
d2.syncMetaData().call();

assertThat(isDatabaseEmpty(databaseAdapter())).isFalse();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

import java.io.IOException;

import retrofit2.Response;

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

public class MetadataCallRealIntegrationShould extends AbsStoreTestCase {
/**
* A quick integration test that is probably flaky, but will help with finding bugs related to
Expand Down Expand Up @@ -52,8 +48,7 @@ public void response_successful_on_sync_meta_data_once() throws Exception {
d2.logout().call();
d2.logIn("android", "Android123").call();

Response response = d2.syncMetaData().call();
assertThat(response.isSuccessful()).isTrue();
d2.syncMetaData().call();

//TODO: add aditional sync + break point.
//when debugger stops at the new break point manually change metadata online & resume.
Expand All @@ -68,12 +63,10 @@ public void response_successful_on_sync_meta_data_two_times() throws Exception {
d2.logIn("android", "Android123").call();

//first sync:
Response response1 = d2.syncMetaData().call();
assertThat(response1.isSuccessful()).isTrue();
d2.syncMetaData().call();

//second sync:
Response response2 = d2.syncMetaData().call();
assertThat(response2.isSuccessful()).isTrue();
d2.syncMetaData().call();
}

//@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.io.IOException;
import java.util.List;

import retrofit2.Response;

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

public class TeisCallRealIntegrationShould extends AbsStoreTestCase {
Expand All @@ -30,8 +28,7 @@ public void download_tracked_entity_instances() throws Exception {
d2.logout().call();
d2.logIn("android", "Android123").call();

Response metadataResponse = d2.syncMetaData().call();
assertThat(metadataResponse.isSuccessful()).isTrue();
d2.syncMetaData().call();

List<TrackedEntityInstance> trackedEntityInstances =
d2.downloadTrackedEntityInstances(5, false).call();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.hisp.dhis.android.core.category;

import static org.junit.Assert.assertEquals;

import android.support.test.runner.AndroidJUnit4;

import org.hisp.dhis.android.core.common.LinkModelStore;
import org.hisp.dhis.android.core.data.database.AbsStoreTestCase;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -14,10 +13,12 @@
import java.util.Date;
import java.util.List;

import static org.junit.Assert.assertEquals;

@RunWith(AndroidJUnit4.class)
public class CategoryCategoryComboLinkStoreShould extends AbsStoreTestCase {

private CategoryCategoryComboLinkStore store;
private LinkModelStore<CategoryCategoryComboLinkModel> store;
private Category newCategory;
private CategoryCombo newCategoryCombo;
private CategoryCategoryComboLinkModel newCategoryCategoryComboLinkModel;
Expand All @@ -27,7 +28,7 @@ public class CategoryCategoryComboLinkStoreShould extends AbsStoreTestCase {
@Before
public void setUp() throws IOException {
super.setUp();
store = new CategoryCategoryComboLinkStoreImpl(databaseAdapter());
store = CategoryCategoryComboLinkStore.create(databaseAdapter());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.support.test.runner.AndroidJUnit4;

import org.hisp.dhis.android.core.common.IdentifiableObjectStore;
import org.hisp.dhis.android.core.common.LinkModelStore;
import org.hisp.dhis.android.core.data.database.AbsStoreTestCase;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -17,7 +18,7 @@
@RunWith(AndroidJUnit4.class)
public class CategoryCategoryOptionLinkStoreShould extends AbsStoreTestCase {

private CategoryCategoryOptionLinkStore store;
private LinkModelStore<CategoryCategoryOptionLinkModel> store;
private Category newCategory;
private CategoryOption newCategoryOption;
private CategoryCategoryOptionLinkModel newCategoryCategoryOptionLinkModel;
Expand All @@ -27,7 +28,7 @@ public class CategoryCategoryOptionLinkStoreShould extends AbsStoreTestCase {
@Before
public void setUp() throws IOException {
super.setUp();
store = new CategoryCategoryOptionLinkStoreImpl(databaseAdapter());
store = CategoryCategoryOptionLinkStore.create(databaseAdapter());

}

Expand Down
Loading

0 comments on commit 052b1bf

Please sign in to comment.