Search in sources :

Example 6 with ApplicationOpenedEvent

use of ai.elimu.model.analytics.ApplicationOpenedEvent in project webapp by elimu-ai.

the class ApplicationOpenedEventDaoTest method testReadAllByStudent.

@Test
public void testReadAllByStudent() {
    Student student1 = new Student();
    student1.setUniqueId("bcaef51200ac6d92bdd81_1");
    studentDao.create(student1);
    List<ApplicationOpenedEvent> applicationOpenedEvents = applicationOpenedEventDao.readAll(student1);
    assertThat(applicationOpenedEvents.size(), is(0));
    ApplicationOpenedEvent applicationOpenedEvent1 = new ApplicationOpenedEvent();
    applicationOpenedEvent1.setStudent(student1);
    applicationOpenedEventDao.create(applicationOpenedEvent1);
    ApplicationOpenedEvent applicationOpenedEvent2 = new ApplicationOpenedEvent();
    applicationOpenedEvent2.setStudent(student1);
    applicationOpenedEventDao.create(applicationOpenedEvent2);
    applicationOpenedEvents = applicationOpenedEventDao.readAll(student1);
    assertThat(applicationOpenedEvents.size(), is(2));
    assertThat(applicationOpenedEvents.get(0).getStudent().getUniqueId(), is("bcaef51200ac6d92bdd81_1"));
    assertThat(applicationOpenedEvents.get(1).getStudent().getUniqueId(), is("bcaef51200ac6d92bdd81_1"));
    Student student2 = new Student();
    student2.setUniqueId("bcaef51200ac6d92bdd81_2");
    studentDao.create(student2);
    applicationOpenedEvents = applicationOpenedEventDao.readAll(student1);
    assertThat(applicationOpenedEvents.size(), is(2));
    assertThat(applicationOpenedEvents.get(0).getStudent().getUniqueId(), is("bcaef51200ac6d92bdd81_1"));
    assertThat(applicationOpenedEvents.get(1).getStudent().getUniqueId(), is("bcaef51200ac6d92bdd81_1"));
    applicationOpenedEvents = applicationOpenedEventDao.readAll(student2);
    assertThat(applicationOpenedEvents.size(), is(0));
    ApplicationOpenedEvent applicationOpenedEvent3 = new ApplicationOpenedEvent();
    applicationOpenedEvent3.setStudent(student2);
    applicationOpenedEventDao.create(applicationOpenedEvent3);
    applicationOpenedEvents = applicationOpenedEventDao.readAll(student2);
    assertThat(applicationOpenedEvents.size(), is(1));
    assertThat(applicationOpenedEvents.get(0).getStudent().getUniqueId(), is("bcaef51200ac6d92bdd81_2"));
    applicationOpenedEvents = applicationOpenedEventDao.readAll();
    assertThat(applicationOpenedEvents.size(), is(3));
    assertThat(applicationOpenedEvents.get(0).getStudent().getUniqueId(), is("bcaef51200ac6d92bdd81_1"));
    assertThat(applicationOpenedEvents.get(1).getStudent().getUniqueId(), is("bcaef51200ac6d92bdd81_1"));
    assertThat(applicationOpenedEvents.get(2).getStudent().getUniqueId(), is("bcaef51200ac6d92bdd81_2"));
}
Also used : ApplicationOpenedEvent(ai.elimu.model.analytics.ApplicationOpenedEvent) Student(ai.elimu.model.Student) Test(org.junit.Test)

Example 7 with ApplicationOpenedEvent

use of ai.elimu.model.analytics.ApplicationOpenedEvent in project webapp by elimu-ai.

the class ApplicationOpenedEventDaoTest method testReadAllByApplication.

@Test
public void testReadAllByApplication() {
    String packageName = "ai.elimu.handwriting";
    List<ApplicationOpenedEvent> applicationOpenedEvents = applicationOpenedEventDao.readAll(packageName);
    assertThat(applicationOpenedEvents.size(), is(0));
    ApplicationOpenedEvent applicationOpenedEvent1 = new ApplicationOpenedEvent();
    applicationOpenedEvent1.setPackageName(packageName);
    applicationOpenedEventDao.create(applicationOpenedEvent1);
    ApplicationOpenedEvent applicationOpenedEvent2 = new ApplicationOpenedEvent();
    applicationOpenedEvent2.setPackageName(packageName);
    applicationOpenedEventDao.create(applicationOpenedEvent2);
    applicationOpenedEvents = applicationOpenedEventDao.readAll(packageName);
    assertThat(applicationOpenedEvents.size(), is(2));
    assertThat(applicationOpenedEvents.get(0).getPackageName(), is("ai.elimu.handwriting"));
    assertThat(applicationOpenedEvents.get(1).getPackageName(), is("ai.elimu.handwriting"));
}
Also used : ApplicationOpenedEvent(ai.elimu.model.analytics.ApplicationOpenedEvent) Test(org.junit.Test)

Aggregations

ApplicationOpenedEvent (ai.elimu.model.analytics.ApplicationOpenedEvent)7 Device (ai.elimu.model.Device)4 Test (org.junit.Test)4 IOException (java.io.IOException)2 Reader (java.io.Reader)2 Calendar (java.util.Calendar)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Contributor (ai.elimu.model.Contributor)1 Student (ai.elimu.model.Student)1 Locale (ai.elimu.model.enums.Locale)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 CharSequenceReader (org.apache.commons.io.input.CharSequenceReader)1 JSONObject (org.json.JSONObject)1