Search in sources :

Example 6 with Student

use of ai.elimu.model.Student 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)

Aggregations

Student (ai.elimu.model.Student)6 Test (org.junit.Test)6 Device (ai.elimu.model.Device)2 HashSet (java.util.HashSet)2 ApplicationOpenedEvent (ai.elimu.model.analytics.ApplicationOpenedEvent)1 LetterLearningEvent (ai.elimu.model.analytics.LetterLearningEvent)1 NumberLearningEvent (ai.elimu.model.analytics.NumberLearningEvent)1