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

import android.support.test.runner.AndroidJUnit4;

import org.hisp.dhis.android.core.data.database.MockIntegrationShould;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.List;

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

@RunWith(AndroidJUnit4.class)
public class TrackedEntityModuleMockIntegrationShould extends MockIntegrationShould {

    @BeforeClass
    public static void setUpAll() throws Exception {
        downloadMetadata();
        downloadTrackedEntityInstances();
    }

    @Test
    public void allow_access_to_all_teis_without_children() {
        List<TrackedEntityInstance> trackedEntityInstances = d2.trackedEntityModule().trackedEntityInstances.get();
        assertThat(trackedEntityInstances.size(), is(1));
        for (TrackedEntityInstance tei: trackedEntityInstances) {
            assertThat(tei.uid(), is("nWrB0TfWlvh"));
            assertThat(tei.organisationUnit(), is("DiszpKrYNg8"));
            assertThat(tei.trackedEntityAttributeValues() == null, is(true));
        }
    }

    @Test
    public void allow_access_to_one_tei_without_children() {
        TrackedEntityInstance tei = d2.trackedEntityModule().trackedEntityInstances.uid("nWrB0TfWlvh").get();
        assertThat(tei.uid(), is("nWrB0TfWlvh"));
        assertThat(tei.organisationUnit(), is("DiszpKrYNg8"));
        assertThat(tei.trackedEntityAttributeValues() == null, is(true));
    }
}
@@ -879,21 +879,22 @@
  is(
-1
+2
 ));%0A
+%0A
         
 for 
@@ -893,13 +893,8 @@
     
-for (
 Trac
@@ -916,11 +916,30 @@
 ce t
-ei:
+rackedEntityInstance =
  tra
@@ -957,24 +957,25 @@
 nstances
-) %7B%0A    
+.get(0);%0A
         
@@ -978,34 +978,52 @@
     assertThat(t
+rackedEntityInstanc
 e
-i
 .uid(), is(%22nWrB
@@ -1034,36 +1034,32 @@
 lvh%22));%0A        
-    
 assertThat(tei.o
@@ -1046,34 +1046,52 @@
     assertThat(t
+rackedEntityInstanc
 e
-i
 .organisationUni
@@ -1119,28 +1119,24 @@
 ));%0A        
-   
- 
 assertThat(t
@@ -1127,34 +1127,52 @@
     assertThat(t
+rackedEntityInstanc
 e
-i
 .trackedEntityAt
@@ -1211,17 +1211,8 @@
 ));%0A
-        %7D
 %0A   

Update TrackedEntityModuleMockIntegrationShould