use of com.litepaltest.model.Teacher in project LitePal by LitePalFramework.
the class UpdateUsingUpdateMethodTest method initForAssociations.
private void initForAssociations() {
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");
s2.setAge(19);
s3 = new Student();
s3.setName("Miley");
s3.setAge(16);
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.Teacher in project LitePal by LitePalFramework.
the class UpdateUsingUpdateMethodTest method testUpdateWithInstanceUpdate.
public void testUpdateWithInstanceUpdate() {
Teacher t = new Teacher();
t.setAge(66);
t.setTeacherName("Jobs");
t.setTeachYears(33);
t.setSex(false);
int rowsAffected = t.update(teacher.getId());
assertEquals(1, rowsAffected);
Teacher newTeacher = getTeacher(teacher.getId());
assertEquals("Jobs", newTeacher.getTeacherName());
assertEquals(33, newTeacher.getTeachYears());
assertEquals(66, newTeacher.getAge());
}
use of com.litepaltest.model.Teacher in project LitePal by LitePalFramework.
the class DeleteTest method initJohn.
private void initJohn() {
john = new Teacher();
john.setTeacherName("John");
john.setAge(33);
john.setTeachYears(13);
johnCard = new IdCard();
johnCard.setAddress("John Street");
johnCard.setNumber("123458");
john.setIdCard(johnCard);
}
use of com.litepaltest.model.Teacher in project LitePal by LitePalFramework.
the class DeleteTest method initMike.
private void initMike() {
mike = new Teacher();
mike.setTeacherName("Mike");
mike.setAge(36);
mike.setTeachYears(16);
mikeCard = new IdCard();
mikeCard.setAddress("Mike Street");
mikeCard.setNumber("123459");
mike.setIdCard(mikeCard);
}
use of com.litepaltest.model.Teacher in project LitePal by LitePalFramework.
the class LitePalTestCase method getTeacher.
protected Teacher getTeacher(long id) {
Teacher teacher = null;
Cursor cursor = Connector.getDatabase().query(getTableName(Teacher.class), null, "id = ?", new String[] { String.valueOf(id) }, null, null, null);
if (cursor.moveToFirst()) {
teacher = new Teacher();
String teacherName = cursor.getString(cursor.getColumnIndexOrThrow("teachername"));
int teachYears = cursor.getInt(cursor.getColumnIndexOrThrow("teachyears"));
int age = cursor.getInt(cursor.getColumnIndexOrThrow("age"));
int sex = cursor.getInt(cursor.getColumnIndexOrThrow("sex"));
teacher.setTeacherName(teacherName);
teacher.setTeachYears(teachYears);
teacher.setAge(age);
if (sex == 0) {
teacher.setSex(false);
} else if (sex == 1) {
teacher.setSex(true);
}
}
cursor.close();
return teacher;
}
Aggregations