-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #230 from dhis2/develop
Develop (0.9)
- Loading branch information
Showing
208 changed files
with
6,489 additions
and
7,250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...rg/hisp/dhis/android/core/TrackedEntityInstanceQueryAndDownloadRealIntegrationShould.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.hisp.dhis.android.core; | ||
|
||
import org.hisp.dhis.android.core.common.D2Factory; | ||
import org.hisp.dhis.android.core.data.api.OuMode; | ||
import org.hisp.dhis.android.core.data.database.AbsStoreTestCase; | ||
import org.hisp.dhis.android.core.data.server.RealServerMother; | ||
import org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance; | ||
import org.hisp.dhis.android.core.trackedentity.search.TrackedEntityInstanceQuery; | ||
import org.hisp.dhis.android.core.user.User; | ||
import org.junit.Before; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import retrofit2.Response; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
public class TrackedEntityInstanceQueryAndDownloadRealIntegrationShould extends AbsStoreTestCase { | ||
private D2 d2; | ||
private TrackedEntityInstanceQuery.Builder queryBuilder; | ||
|
||
@Before | ||
@Override | ||
public void setUp() throws IOException { | ||
super.setUp(); | ||
|
||
d2 = D2Factory.create(RealServerMother.url, databaseAdapter()); | ||
|
||
|
||
List<String> orgUnits = new ArrayList<>(); | ||
orgUnits.add("O6uvpzGd5pu"); | ||
|
||
queryBuilder = TrackedEntityInstanceQuery.builder() | ||
.paging(true).page(1).pageSize(50) | ||
.orgUnits(orgUnits).orgUnitMode(OuMode.ACCESSIBLE); | ||
} | ||
|
||
//@Test | ||
public void query_and_download_tracked_entity_instances() throws Exception { | ||
login(); | ||
|
||
d2.syncMetaData().call(); | ||
|
||
TrackedEntityInstanceQuery query = queryBuilder.build(); | ||
List<TrackedEntityInstance> queriedTeis = d2.queryTrackedEntityInstances(query).call(); | ||
assertThat(queriedTeis).isNotEmpty(); | ||
|
||
Set<String> uids = new HashSet<>(queriedTeis.size()); | ||
|
||
for(TrackedEntityInstance tei: queriedTeis) { | ||
uids.add(tei.uid()); | ||
} | ||
|
||
List<TrackedEntityInstance> downloadedTeis = d2.downloadTrackedEntityInstancesByUid(uids).call(); | ||
assertThat(queriedTeis.size()).isEqualTo(downloadedTeis.size()); | ||
} | ||
|
||
private void login() throws Exception { | ||
d2.logout().call(); | ||
Response<User> loginResponse = d2.logIn("android", "Android123").call(); | ||
assertThat(loginResponse.isSuccessful()).isTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.