Search in sources :

Example 6 with BlankModel

use of com.orm.androrm.impl.BlankModel in project androrm by androrm.

the class DateFieldTest method testStorage.

public void testStorage() {
    Date date = Calendar.getInstance().getTime();
    BlankModel model = new BlankModel();
    model.setDate(date);
    model.save(getContext());
    assertEquals(date, model.getDate());
    model = Model.objects(getContext(), BlankModel.class).get(model.getId());
    Date newDate = model.getDate();
    assertNotNull(newDate);
    assertEquals(date.getYear(), newDate.getYear());
    assertEquals(date.getMonth(), newDate.getMonth());
    assertEquals(date.getDay(), newDate.getDay());
    assertEquals(date.getHours(), newDate.getHours());
    assertEquals(date.getMinutes(), newDate.getMinutes());
    assertEquals(date.getSeconds(), newDate.getSeconds());
}
Also used : BlankModel(com.orm.androrm.impl.BlankModel) Date(java.util.Date)

Example 7 with BlankModel

use of com.orm.androrm.impl.BlankModel in project androrm by androrm.

the class ModelTest method testEquals.

public void testEquals() {
    BlankModel m = new BlankModel();
    m.setName("test");
    m.save(getContext());
    BlankModel m2 = Model.objects(getContext(), BlankModel.class).get(m.getId());
    assertEquals(m, m2);
    BlankModelNoAutoincrement m3 = new BlankModelNoAutoincrement();
    m3.save(getContext(), 1);
    assertFalse(m.equals(m3));
}
Also used : BlankModel(com.orm.androrm.impl.BlankModel) BlankModelNoAutoincrement(com.orm.androrm.impl.BlankModelNoAutoincrement)

Example 8 with BlankModel

use of com.orm.androrm.impl.BlankModel in project androrm by androrm.

the class ModelTest method testDelete.

public void testDelete() {
    BlankModel m = new BlankModel();
    assertFalse(m.delete(getContext()));
    m.save(getContext());
    int id = m.getId();
    assertTrue(m.delete(getContext()));
    assertNull(m.getName());
    assertNull(m.getLocation());
    assertNull(m.getDate());
    assertNull(Model.objects(getContext(), BlankModel.class).get(id));
    assertEquals(0, m.getId());
}
Also used : BlankModel(com.orm.androrm.impl.BlankModel)

Aggregations

BlankModel (com.orm.androrm.impl.BlankModel)8 DatabaseAdapter (com.orm.androrm.DatabaseAdapter)2 Model (com.orm.androrm.Model)2 BlankModelNoAutoincrement (com.orm.androrm.impl.BlankModelNoAutoincrement)2 Location (android.location.Location)1 Date (java.util.Date)1