Search in sources :

Example 61 with RunTestInLooperThread

use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.

the class RxJavaTests method asFlowable_frozenRealmList.

@Test
@RunTestInLooperThread
public void asFlowable_frozenRealmList() {
    realm.beginTransaction();
    final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
    list.add(new Dog("dog"));
    realm.commitTransaction();
    RealmList<Dog> frozenList = list.freeze();
    subscription = frozenList.asFlowable().subscribe(rxList -> {
        assertTrue(rxList.isFrozen());
        assertEquals(frozenList, rxList);
        disposeSuccessfulTest(realm);
    });
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) RunWith(org.junit.runner.RunWith) Dog(io.realm.entities.Dog) SystemClock(android.os.SystemClock) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Flowable(io.reactivex.Flowable) RunInLooperThread(io.realm.rule.RunInLooperThread) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Schedulers(io.reactivex.schedulers.Schedulers) Pair(io.realm.internal.util.Pair) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) RealmLog(io.realm.log.RealmLog) Assert.assertNotNull(org.junit.Assert.assertNotNull) AllTypes(io.realm.entities.AllTypes) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Consumer(io.reactivex.functions.Consumer) CyclicType(io.realm.entities.CyclicType) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) AtomicLong(java.util.concurrent.atomic.AtomicLong) Disposable(io.reactivex.disposables.Disposable) Rule(org.junit.Rule) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertEquals(org.junit.Assert.assertEquals) AllTypes(io.realm.entities.AllTypes) Dog(io.realm.entities.Dog) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) Test(org.junit.Test)

Example 62 with RunTestInLooperThread

use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.

the class RxJavaTests method asFlowable_frozenRealmObject.

@Test
@RunTestInLooperThread
public void asFlowable_frozenRealmObject() {
    realm.beginTransaction();
    final AllJavaTypes obj = realm.createObject(AllJavaTypes.class, 42);
    realm.commitTransaction();
    subscription = obj.<AllJavaTypes>freeze().<AllJavaTypes>asFlowable().subscribe(rxObject -> {
        assertTrue(rxObject.isFrozen());
        assertNotEquals(rxObject, obj);
        assertEquals(rxObject.getFieldId(), obj.getFieldId());
        disposeSuccessfulTest(realm);
    });
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) RunWith(org.junit.runner.RunWith) Dog(io.realm.entities.Dog) SystemClock(android.os.SystemClock) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Flowable(io.reactivex.Flowable) RunInLooperThread(io.realm.rule.RunInLooperThread) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Schedulers(io.reactivex.schedulers.Schedulers) Pair(io.realm.internal.util.Pair) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) RealmLog(io.realm.log.RealmLog) Assert.assertNotNull(org.junit.Assert.assertNotNull) AllTypes(io.realm.entities.AllTypes) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Consumer(io.reactivex.functions.Consumer) CyclicType(io.realm.entities.CyclicType) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) AtomicLong(java.util.concurrent.atomic.AtomicLong) Disposable(io.reactivex.disposables.Disposable) Rule(org.junit.Rule) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertEquals(org.junit.Assert.assertEquals) AllJavaTypes(io.realm.entities.AllJavaTypes) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) Test(org.junit.Test)

Example 63 with RunTestInLooperThread

use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.

the class RxJavaTests method asChangesetObservable_frozenRealmList.

@Test
@RunTestInLooperThread
public void asChangesetObservable_frozenRealmList() {
    realm.beginTransaction();
    final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
    list.add(new Dog("dog"));
    realm.commitTransaction();
    RealmList<Dog> frozenList = list.freeze();
    subscription = frozenList.asChangesetObservable().subscribe(change -> {
        RealmList<Dog> rxList = change.getCollection();
        assertTrue(rxList.isFrozen());
        assertEquals(frozenList, rxList);
        assertNull(change.getChangeset());
        disposeSuccessfulTest(realm);
    });
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) RunWith(org.junit.runner.RunWith) Dog(io.realm.entities.Dog) SystemClock(android.os.SystemClock) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Flowable(io.reactivex.Flowable) RunInLooperThread(io.realm.rule.RunInLooperThread) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Schedulers(io.reactivex.schedulers.Schedulers) Pair(io.realm.internal.util.Pair) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) RealmLog(io.realm.log.RealmLog) Assert.assertNotNull(org.junit.Assert.assertNotNull) AllTypes(io.realm.entities.AllTypes) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Consumer(io.reactivex.functions.Consumer) CyclicType(io.realm.entities.CyclicType) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) AtomicLong(java.util.concurrent.atomic.AtomicLong) Disposable(io.reactivex.disposables.Disposable) Rule(org.junit.Rule) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertEquals(org.junit.Assert.assertEquals) AllTypes(io.realm.entities.AllTypes) Dog(io.realm.entities.Dog) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) Test(org.junit.Test)

Example 64 with RunTestInLooperThread

use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.

the class RxJavaTests method realmList_emittedOnSubscribe.

@Test
@RunTestInLooperThread
public void realmList_emittedOnSubscribe() {
    realm.beginTransaction();
    final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
    list.add(new Dog("dog"));
    realm.commitTransaction();
    subscription = list.asFlowable().subscribe(rxList -> {
        assertTrue(rxList.isFrozen());
        assertEquals(1, rxList.size());
        assertEquals("dog", rxList.first().getName());
        disposeSuccessfulTest(realm);
    });
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) RunWith(org.junit.runner.RunWith) Dog(io.realm.entities.Dog) SystemClock(android.os.SystemClock) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Flowable(io.reactivex.Flowable) RunInLooperThread(io.realm.rule.RunInLooperThread) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Schedulers(io.reactivex.schedulers.Schedulers) Pair(io.realm.internal.util.Pair) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) RealmLog(io.realm.log.RealmLog) Assert.assertNotNull(org.junit.Assert.assertNotNull) AllTypes(io.realm.entities.AllTypes) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Consumer(io.reactivex.functions.Consumer) CyclicType(io.realm.entities.CyclicType) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) AtomicLong(java.util.concurrent.atomic.AtomicLong) Disposable(io.reactivex.disposables.Disposable) Rule(org.junit.Rule) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertEquals(org.junit.Assert.assertEquals) AllTypes(io.realm.entities.AllTypes) Dog(io.realm.entities.Dog) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) Test(org.junit.Test)

Example 65 with RunTestInLooperThread

use of io.realm.rule.RunTestInLooperThread in project realm-java by realm.

the class RxJavaTests method asFlowable_frozenDynamicRealmList.

@Test
@RunTestInLooperThread
public void asFlowable_frozenDynamicRealmList() {
    realm.beginTransaction();
    final RealmList<Dog> list = realm.createObject(AllTypes.class).getColumnRealmList();
    list.add(new Dog("dog"));
    realm.commitTransaction();
    DynamicRealm dynamicRealm = DynamicRealm.getInstance(looperThread.getConfiguration());
    RealmList<DynamicRealmObject> frozenList = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst().getList(AllTypes.FIELD_REALMLIST).freeze();
    subscription = frozenList.asFlowable().subscribe(rxList -> {
        assertTrue(rxList.isFrozen());
        assertEquals(frozenList, rxList);
        disposeSuccessfulTest(dynamicRealm);
    });
}
Also used : AllJavaTypes(io.realm.entities.AllJavaTypes) RunWith(org.junit.runner.RunWith) Dog(io.realm.entities.Dog) SystemClock(android.os.SystemClock) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Flowable(io.reactivex.Flowable) RunInLooperThread(io.realm.rule.RunInLooperThread) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Schedulers(io.reactivex.schedulers.Schedulers) Pair(io.realm.internal.util.Pair) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) RealmLog(io.realm.log.RealmLog) Assert.assertNotNull(org.junit.Assert.assertNotNull) AllTypes(io.realm.entities.AllTypes) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Consumer(io.reactivex.functions.Consumer) CyclicType(io.realm.entities.CyclicType) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) AtomicLong(java.util.concurrent.atomic.AtomicLong) Disposable(io.reactivex.disposables.Disposable) Rule(org.junit.Rule) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertEquals(org.junit.Assert.assertEquals) AllTypes(io.realm.entities.AllTypes) Dog(io.realm.entities.Dog) RunTestInLooperThread(io.realm.rule.RunTestInLooperThread) Test(org.junit.Test)

Aggregations

RunTestInLooperThread (io.realm.rule.RunTestInLooperThread)180 Test (org.junit.Test)180 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)80 AllTypes (io.realm.entities.AllTypes)76 Dog (io.realm.entities.Dog)59 RunInLooperThread (io.realm.rule.RunInLooperThread)30 AllJavaTypes (io.realm.entities.AllJavaTypes)29 AtomicLong (java.util.concurrent.atomic.AtomicLong)23 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)21 RealmLog (io.realm.log.RealmLog)21 Assert.assertEquals (org.junit.Assert.assertEquals)21 Assert.assertFalse (org.junit.Assert.assertFalse)21 Assert.assertNotNull (org.junit.Assert.assertNotNull)21 Assert.assertTrue (org.junit.Assert.assertTrue)21 Before (org.junit.Before)21 Rule (org.junit.Rule)21 RunWith (org.junit.runner.RunWith)21 Consumer (io.reactivex.functions.Consumer)20 Assert.fail (org.junit.Assert.fail)20 SystemClock (android.os.SystemClock)19