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

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 EventModuleMockIntegrationShould extends MockIntegrationShould {

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

    @Test
    public void allow_access_to_all_events_without_children() {
        List<Event> events = d2.eventModule().events.get();
        assertThat(events.size(), is(1));
        for (Event event: events) {
            assertThat(event.uid(), is("V1CerIi3sdL"));
            assertThat(event.organisationUnit(), is("DiszpKrYNg8"));
            assertThat(event.programStage(), is("dBwrot7S420"));
            assertThat(event.trackedEntityDataValues() == null, is(true));
        }
    }

    @Test
    public void allow_access_to_one_event_without_children() {
        Event event = d2.eventModule().events.uid("V1CerIi3sdL").get();
        assertThat(event.uid(), is("V1CerIi3sdL"));
        assertThat(event.organisationUnit(), is("DiszpKrYNg8"));
        assertThat(event.programStage(), is("dBwrot7S420"));
        assertThat(event.trackedEntityDataValues() == null, is(true));
    }
}
@@ -778,24 +778,25 @@
 is(1));%0A
+%0A
         
 for (Eve
@@ -791,13 +791,8 @@
     
-for (
 Even
@@ -802,24 +802,27 @@
 vent
-:
+ =
  events
-) %7B%0A    
+.get(0);%0A%0A
     
@@ -865,28 +865,24 @@
 rIi3sdL%22));%0A
-    
         asse
@@ -934,36 +934,32 @@
 Ng8%22));%0A        
- 
-   
 assertThat(event
@@ -999,28 +999,24 @@
 ));%0A        
-  
-  
 assertThat(e
@@ -1070,17 +1070,8 @@
 ));%0A
-        %7D
 %0A   

Update Event module tests to work with more than 1 Event