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"));
}
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"));
}
Aggregations