use of io.realm.entities.AllJavaTypes in project realm-java by realm.
the class RealmCollectionTests method contains.
@Test
public void contains() {
AllJavaTypes obj = collection.iterator().next();
assertTrue(collection.contains(obj));
}
use of io.realm.entities.AllJavaTypes in project realm-java by realm.
the class RealmCollectionTests method contains_realmObjectFromOtherRealm.
@Test
public void contains_realmObjectFromOtherRealm() {
Realm realm2 = Realm.getInstance(configFactory.createConfiguration("other_realm.realm"));
populateRealm(realm2, TEST_SIZE);
AllJavaTypes otherRealmObj = realm2.where(AllJavaTypes.class).equalTo(AllJavaTypes.FIELD_LONG, 0).findFirst();
try {
assertFalse(collection.contains(otherRealmObj));
} finally {
realm2.close();
}
}
use of io.realm.entities.AllJavaTypes in project realm-java by realm.
the class OrderedRealmCollectionIteratorTests method listIterator_remove_nonRealmList_throwUnsupported.
@Test
public void listIterator_remove_nonRealmList_throwUnsupported() {
if (skipTest(CollectionClass.MANAGED_REALMLIST, CollectionClass.UNMANAGED_REALMLIST)) {
return;
}
ListIterator<AllJavaTypes> it = collection.listIterator();
AllJavaTypes obj = it.next();
assertEquals("test data 0", obj.getFieldString());
realm.beginTransaction();
thrown.expect(UnsupportedOperationException.class);
it.remove();
}
use of io.realm.entities.AllJavaTypes in project realm-java by realm.
the class OrderedRealmCollectionIteratorTests method iterator.
@Test
public void iterator() {
Iterator<AllJavaTypes> it = collection.iterator();
int i = 0;
while (it.hasNext()) {
AllJavaTypes item = it.next();
assertEquals("Failed at index: " + i, i, item.getFieldLong());
i++;
}
assertEquals(TEST_SIZE, collection.size());
assertEquals(TEST_SIZE, i);
}
use of io.realm.entities.AllJavaTypes in project realm-java by realm.
the class OrderedRealmCollectionIteratorTests method useCase_forEachIterator_modifyQueryResult_outerTransaction.
@Test
public void useCase_forEachIterator_modifyQueryResult_outerTransaction() {
if (skipTest(CollectionClass.MANAGED_REALMLIST, CollectionClass.UNMANAGED_REALMLIST)) {
return;
}
assertEquals(TEST_SIZE, collection.size());
realm.beginTransaction();
for (AllJavaTypes obj : collection) {
obj.setFieldLong(obj.getFieldLong() + TEST_SIZE);
}
realm.commitTransaction();
// Verifies that all elements were modified.
assertEquals(0, realm.where(AllJavaTypes.class).lessThan(AllJavaTypes.FIELD_LONG, TEST_SIZE).count());
}
Aggregations