use of com.litepaltest.model.Classroom in project LitePal by LitePalFramework.
the class UpdateUsingSaveMethodTest method init.
private void init() {
Calendar calendar = Calendar.getInstance();
c1 = new Classroom();
c1.setName("Working room");
c2 = new Classroom();
c2.setName("Resting room");
s1 = new Student();
s1.setName("Parker");
s1.setAge(18);
s2 = new Student();
s2.setName("Peter");
calendar.clear();
calendar.set(1990, 9, 16, 0, 0, 0);
s2.setBirthday(calendar.getTime());
s2.setAge(19);
s3 = new Student();
s3.setName("Miley");
s3.setAge(16);
id1 = new IdCard();
id1.setNumber("999777123");
id1.setAddress("Zhushan road");
t1 = new Teacher();
t1.setTeacherName("Jackson");
t1.setTeachYears(3);
t1.setAge(28);
t2 = new Teacher();
t2.setTeacherName("Rose");
t2.setTeachYears(12);
t2.setAge(34);
}
use of com.litepaltest.model.Classroom in project LitePal by LitePalFramework.
the class UpdateUsingUpdateMethodTest method init.
private void init() {
classroom = new Classroom();
classroom.setName("English room");
classroom.getNews().add("hello");
classroom.getNews().add("world");
classroom.getNumbers().add(123);
classroom.getNumbers().add(456);
teacher = new Teacher();
teacher.setTeacherName("Tony");
teacher.setTeachYears(3);
teacher.setAge(23);
teacher.setSex(false);
student = new Student();
student.setName("Jonny");
student.setAge(13);
student.setClassroom(classroom);
student.setBirthday(new Date());
student.getTeachers().add(teacher);
teacher.getStudents().add(student);
student.save();
teacher.save();
classroom.save();
}
use of com.litepaltest.model.Classroom in project LitePal by LitePalFramework.
the class SaveAllTest method testSaveAllGenericData.
public void testSaveAllGenericData() {
List<Classroom> classroomList = new ArrayList<Classroom>();
for (int i = 0; i < 50; i++) {
Classroom classroom = new Classroom();
classroom.setName("classroom " + i);
for (int j = 0; j < 20; j++) {
classroom.getNews().add("news " + i);
}
for (int k = 0; k < 13; k++) {
classroom.getNumbers().add(k);
}
classroomList.add(classroom);
}
DataSupport.saveAll(classroomList);
assertEquals(50, classroomList.size());
for (Classroom classroom : classroomList) {
assertTrue(classroom.isSaved());
Classroom c = DataSupport.find(Classroom.class, classroom.get_id());
assertTrue(c.getName().startsWith("classroom"));
assertEquals(20, c.getNews().size());
assertEquals(13, c.getNumbers().size());
}
}
use of com.litepaltest.model.Classroom in project LitePal by LitePalFramework.
the class SaveAllTest method testSaveAllWithM2OOnOneSide.
public void testSaveAllWithM2OOnOneSide() {
Classroom classroom = new Classroom();
classroom.setName("Music room");
for (int i = 0; i < 50; i++) {
Student student = new Student();
student.setName("Tom");
student.setAge(new Random().nextInt(20));
classroom.getStudentCollection().add(student);
}
DataSupport.saveAll(classroom.getStudentCollection());
classroom.save();
List<Student> list = DataSupport.where(classroomTable + "_id = ?", String.valueOf(classroom.get_id())).find(Student.class);
assertEquals(50, list.size());
}
use of com.litepaltest.model.Classroom in project LitePal by LitePalFramework.
the class SaveAllTest method testSaveAllWithM2OOnManySide.
public void testSaveAllWithM2OOnManySide() {
Classroom classroom = new Classroom();
classroom.setName("English room");
List<Student> studentList = new ArrayList<Student>();
for (int i = 0; i < 50; i++) {
Student student = new Student();
student.setName("Tom");
student.setAge(new Random().nextInt(20));
student.setClassroom(classroom);
studentList.add(student);
}
DataSupport.saveAll(studentList);
classroom.save();
List<Student> list = DataSupport.where(classroomTable + "_id = ?", String.valueOf(classroom.get_id())).find(Student.class);
assertEquals(50, list.size());
}
Aggregations