Search in sources :

Example 46 with AllJavaTypes

use of io.realm.entities.AllJavaTypes in project realm-java by realm.

the class DynamicRealmObjectTests method isNull_true.

@Test
public void isNull_true() {
    realm.beginTransaction();
    AllJavaTypes obj = realm.createObject(AllJavaTypes.class, 0);
    realm.commitTransaction();
    assertTrue(new DynamicRealmObject(obj).isNull(AllJavaTypes.FIELD_OBJECT));
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) Test(org.junit.Test)

Example 47 with AllJavaTypes

use of io.realm.entities.AllJavaTypes in project realm-java by realm.

the class DynamicRealmObjectTests method hashcode.

@Test
public void hashcode() {
    AllJavaTypes standardObj = realm.where(AllJavaTypes.class).findFirst();
    DynamicRealmObject dObj1 = new DynamicRealmObject(standardObj);
    assertEquals(standardObj.hashCode(), dObj1.hashCode());
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) Test(org.junit.Test)

Example 48 with AllJavaTypes

use of io.realm.entities.AllJavaTypes in project realm-java by realm.

the class DynamicRealmObjectTests method setObject_wrongTypeThrows.

@Test
public void setObject_wrongTypeThrows() {
    realm.beginTransaction();
    AllJavaTypes obj = realm.createObject(AllJavaTypes.class, 0);
    Dog otherObj = realm.createObject(Dog.class);
    DynamicRealmObject dynamicObj = new DynamicRealmObject(obj);
    DynamicRealmObject dynamicWrongType = new DynamicRealmObject(otherObj);
    thrown.expect(IllegalArgumentException.class);
    dynamicObj.setObject(AllJavaTypes.FIELD_OBJECT, dynamicWrongType);
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) Dog(io.realm.entities.Dog) Test(org.junit.Test)

Example 49 with AllJavaTypes

use of io.realm.entities.AllJavaTypes in project realm-java by realm.

the class DynamicRealmObjectTests method untypedSetter_listMixedTypesThrows.

@Test
public void untypedSetter_listMixedTypesThrows() {
    realm.beginTransaction();
    AllJavaTypes obj1 = realm.createObject(AllJavaTypes.class, 2);
    CyclicType obj2 = realm.createObject(CyclicType.class);
    RealmList<DynamicRealmObject> list = new RealmList<DynamicRealmObject>();
    list.add(new DynamicRealmObject(obj1));
    list.add(new DynamicRealmObject(obj2));
    thrown.expect(IllegalArgumentException.class);
    dObjTyped.set(AllJavaTypes.FIELD_LIST, list);
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) CyclicType(io.realm.entities.CyclicType) Test(org.junit.Test)

Example 50 with AllJavaTypes

use of io.realm.entities.AllJavaTypes in project realm-java by realm.

the class OrderedRealmCollectionIteratorTests method iterator_oneElement.

@Test
public void iterator_oneElement() {
    collection = createCollection(realm, collectionClass, 1);
    Iterator<AllJavaTypes> it = collection.iterator();
    //noinspection WhileLoopReplaceableByForEach
    int i = 0;
    while (it.hasNext()) {
        AllJavaTypes item = it.next();
        assertEquals(0, item.getFieldLong());
        i++;
    }
    assertEquals(1, collection.size());
    assertEquals(1, i);
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest)

Aggregations

AllJavaTypes (io.realm.entities.AllJavaTypes)90 Test (org.junit.Test)78 UiThreadTest (android.support.test.annotation.UiThreadTest)24 RunTestInLooperThread (io.realm.rule.RunTestInLooperThread)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 Date (java.util.Date)5 RealmException (io.realm.exceptions.RealmException)4 Ignore (org.junit.Ignore)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutionException (java.util.concurrent.ExecutionException)2 ExecutorService (java.util.concurrent.ExecutorService)2 ExpectedException (org.junit.rules.ExpectedException)2 Pair (android.util.Pair)1 CyclicType (io.realm.entities.CyclicType)1 Dog (io.realm.entities.Dog)1 NonLatinFieldNames (io.realm.entities.NonLatinFieldNames)1 PrimaryKeyAsString (io.realm.entities.PrimaryKeyAsString)1 RealmPrimaryKeyConstraintException (io.realm.exceptions.RealmPrimaryKeyConstraintException)1 RunInLooperThread (io.realm.rule.RunInLooperThread)1 Field (java.lang.reflect.Field)1