use of com.litepaltest.model.Student in project LitePal by LitePalFramework.
the class DeleteTest method testMarkAsDeleted.
public void testMarkAsDeleted() {
List<Student> students = new ArrayList<>();
for (int i = 0; i < 5; i++) {
Student s = new Student();
s.setName("Dusting");
s.setAge(i + 10);
students.add(s);
}
DataSupport.saveAll(students);
List<Student> list = DataSupport.where("name=?", "Dusting").find(Student.class);
assertTrue(list.size() >= 5);
DataSupport.deleteAll(Student.class, "name=?", "Dusting");
list = DataSupport.where("name=?", "Dusting").find(Student.class);
assertEquals(0, list.size());
DataSupport.saveAll(students);
list = DataSupport.where("name=?", "Dusting").find(Student.class);
assertEquals(0, list.size());
DataSupport.markAsDeleted(students);
DataSupport.saveAll(students);
list = DataSupport.where("name=?", "Dusting").find(Student.class);
assertEquals(5, list.size());
}
use of com.litepaltest.model.Student in project LitePal by LitePalFramework.
the class DeleteTest method testDeleteWithNoParameter.
public void testDeleteWithNoParameter() {
initJude();
jude.save();
int rowsAffected = jude.delete();
assertEquals(1, rowsAffected);
Student s = getStudent(jude.getId());
assertNull(s);
}
use of com.litepaltest.model.Student in project LitePal by LitePalFramework.
the class DeleteTest method initRose.
private void initRose() {
rose = new Student();
rose.setName("Rose");
rose.setAge(15);
roseCard = new IdCard();
roseCard.setAddress("Rose Street");
roseCard.setNumber("123457");
roseCard.setStudent(rose);
}
use of com.litepaltest.model.Student in project LitePal by LitePalFramework.
the class DeleteTest method testDeleteAll.
public void testDeleteAll() {
Student s;
int[] ids = new int[5];
for (int i = 0; i < 5; i++) {
s = new Student();
s.setName("Dusting");
s.setAge(i + 10086);
s.save();
ids[i] = s.getId();
}
int affectedRows = DataSupport.deleteAll(Student.class, "name = ? and age = ?", "Dusting", "10088");
assertEquals(1, affectedRows);
assertNull(getStudent(ids[2]));
affectedRows = DataSupport.deleteAll(Student.class, "name = ? and age > ? and age < ?", "Dusting", "10085", "10092");
assertEquals(4, affectedRows);
}
Aggregations