Search in sources :

Example 1 with Teacher

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);
}
Also used : Classroom(com.litepaltest.model.Classroom) Teacher(com.litepaltest.model.Teacher) Student(com.litepaltest.model.Student)

Example 2 with Teacher

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());
}
Also used : Teacher(com.litepaltest.model.Teacher)

Example 3 with Teacher

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);
}
Also used : Teacher(com.litepaltest.model.Teacher) IdCard(com.litepaltest.model.IdCard)

Example 4 with Teacher

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);
}
Also used : Teacher(com.litepaltest.model.Teacher) IdCard(com.litepaltest.model.IdCard)

Example 5 with Teacher

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;
}
Also used : Teacher(com.litepaltest.model.Teacher) Cursor(android.database.Cursor)

Aggregations

Teacher (com.litepaltest.model.Teacher)23 Student (com.litepaltest.model.Student)11 Classroom (com.litepaltest.model.Classroom)7 IdCard (com.litepaltest.model.IdCard)7 Cursor (android.database.Cursor)3 Calendar (java.util.Calendar)3 ArrayList (java.util.ArrayList)2 DataSupportException (org.litepal.exceptions.DataSupportException)2 Cellphone (com.litepaltest.model.Cellphone)1 Date (java.util.Date)1 Random (java.util.Random)1