use of io.realm.entities.Owner in project realm-java by realm.
the class RealmListTests method remove_byObject.
@Test
public void remove_byObject() {
Owner owner = realm.where(Owner.class).findFirst();
RealmList<Dog> dogs = owner.getDogs();
Dog dog = dogs.get(0);
realm.beginTransaction();
boolean result = dogs.remove(dog);
realm.commitTransaction();
assertTrue(result);
assertEquals(TEST_SIZE - 1, dogs.size());
assertEquals(TEST_SIZE, realm.where(Dog.class).count());
}
use of io.realm.entities.Owner in project realm-java by realm.
the class RealmListTests method query.
@Test
public void query() {
Owner owner = realm.where(Owner.class).findFirst();
RealmList<Dog> dogs = owner.getDogs();
Dog firstDog = dogs.where().equalTo("name", "Dog 0").findFirst();
assertNotNull(firstDog);
}
use of io.realm.entities.Owner in project realm-java by realm.
the class RealmListTests method isValid.
/**
*******************************************************
* Managed mode tests *
********************************************************
*/
@Test
public void isValid() {
Owner owner = realm.where(Owner.class).findFirst();
RealmList<Dog> dogs = owner.getDogs();
assertTrue(dogs.isValid());
realm.close();
assertFalse(dogs.isValid());
}
use of io.realm.entities.Owner in project realm-java by realm.
the class RealmListTests method size.
@Test
public void size() {
Owner owner = realm.where(Owner.class).findFirst();
assertEquals(TEST_SIZE, owner.getDogs().size());
}
use of io.realm.entities.Owner in project realm-java by realm.
the class RealmListTests method createDeletedRealmList.
private RealmList<Dog> createDeletedRealmList() {
Owner owner = realm.where(Owner.class).findFirst();
// noinspection ConstantConditions
RealmList<Dog> dogs = owner.getDogs();
realm.beginTransaction();
owner.deleteFromRealm();
realm.commitTransaction();
return dogs;
}
Aggregations