Search in sources :

Example 1 with Student

use of ai.elimu.model.Student in project webapp by elimu-ai.

the class LetterLearningEventDaoTest method testReadAllByStudent.

@Test
public void testReadAllByStudent() {
    Student student = new Student();
    student.setUniqueId("ddhe72a08347cd29bd3f43d_1");
    studentDao.create(student);
    List<LetterLearningEvent> letterLearningEvents = letterLearningEventDao.readAll(student);
    assertThat(letterLearningEvents.size(), is(0));
    LetterLearningEvent letterLearningEvent = new LetterLearningEvent();
    letterLearningEvent.setStudent(student);
    letterLearningEventDao.create(letterLearningEvent);
    letterLearningEvents = letterLearningEventDao.readAll(student);
    assertThat(letterLearningEvents.size(), is(1));
    assertThat(letterLearningEvents.get(0).getStudent().getUniqueId(), is("ddhe72a08347cd29bd3f43d_1"));
}
Also used : Student(ai.elimu.model.Student) LetterLearningEvent(ai.elimu.model.analytics.LetterLearningEvent) Test(org.junit.Test)

Example 2 with Student

use of ai.elimu.model.Student in project webapp by elimu-ai.

the class NumberLearningEventDaoTest method testReadAllByStudent.

@Test
public void testReadAllByStudent() {
    Student student = new Student();
    student.setUniqueId("576de45ad9e0b07cf66_1");
    studentDao.create(student);
    List<NumberLearningEvent> numberLearningEvents = numberLearningEventDao.readAll(student);
    assertThat(numberLearningEvents.size(), is(0));
    NumberLearningEvent numberLearningEvent = new NumberLearningEvent();
    numberLearningEvent.setStudent(student);
    numberLearningEventDao.create(numberLearningEvent);
    numberLearningEvents = numberLearningEventDao.readAll(student);
    assertThat(numberLearningEvents.size(), is(1));
    assertThat(numberLearningEvents.get(0).getStudent().getUniqueId(), is("576de45ad9e0b07cf66_1"));
}
Also used : NumberLearningEvent(ai.elimu.model.analytics.NumberLearningEvent) Student(ai.elimu.model.Student) Test(org.junit.Test)

Example 3 with Student

use of ai.elimu.model.Student in project webapp by elimu-ai.

the class StudentDaoTest method testStoreStudentWithTWoDevices.

@Test
public void testStoreStudentWithTWoDevices() {
    Set<Device> devices = new HashSet<>();
    Device device1 = new Device();
    device1.setDeviceId("2223947bec18b7ad");
    deviceDao.create(device1);
    devices.add(device1);
    Device device2 = new Device();
    device2.setDeviceId("679b35bb2322c6e4");
    deviceDao.create(device2);
    devices.add(device2);
    Student student = new Student();
    student.setUniqueId("2223947bec18b7ad_1");
    student.setDevices(devices);
    studentDao.create(student);
    Student studentStoredInDatabase = studentDao.read("2223947bec18b7ad_1");
    assertThat(studentStoredInDatabase.getDevices().size(), is(2));
}
Also used : Device(ai.elimu.model.Device) Student(ai.elimu.model.Student) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with Student

use of ai.elimu.model.Student in project webapp by elimu-ai.

the class StudentDaoTest method testCreateStudentsWithNonUniqueIds.

@Test(expected = JpaSystemException.class)
public void testCreateStudentsWithNonUniqueIds() {
    Student student1 = new Student();
    student1.setUniqueId("4113947bec18b7ad_1");
    studentDao.create(student1);
    Student student2 = new Student();
    student2.setUniqueId("4113947bec18b7ad_1");
    studentDao.create(student2);
}
Also used : Student(ai.elimu.model.Student) Test(org.junit.Test)

Example 5 with Student

use of ai.elimu.model.Student in project webapp by elimu-ai.

the class StudentDaoTest method testStoreStudentWithOneDevice.

@Test
public void testStoreStudentWithOneDevice() {
    Set<Device> devices = new HashSet<>();
    Device device = new Device();
    device.setDeviceId("4113947bec18b7ad");
    deviceDao.create(device);
    devices.add(device);
    Student student = new Student();
    student.setUniqueId("4113947bec18b7ad_1");
    student.setDevices(devices);
    studentDao.create(student);
    Student studentStoredInDatabase = studentDao.read("4113947bec18b7ad_1");
    assertThat(studentStoredInDatabase.getDevices().size(), is(1));
}
Also used : Device(ai.elimu.model.Device) Student(ai.elimu.model.Student) HashSet(java.util.HashSet) 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