Java Code Examples for io.reactivex.rxjava3.observers.TestObserver#assertComplete()
The following examples show how to use
io.reactivex.rxjava3.observers.TestObserver#assertComplete() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidLifecycleActivityTest.java From RxLifecycle with Apache License 2.0 | 6 votes |
private void testBindUntilEvent(ActivityController<? extends LifecycleOwner> controller) { LifecycleProvider<Lifecycle.Event> activity = AndroidLifecycle.createLifecycleProvider(controller.get()); TestObserver<Object> testObserver = observable.compose(activity.bindUntilEvent(Lifecycle.Event.ON_STOP)).test(); controller.create(); testObserver.assertNotComplete(); controller.start(); testObserver.assertNotComplete(); controller.resume(); testObserver.assertNotComplete(); controller.pause(); testObserver.assertNotComplete(); controller.stop(); testObserver.assertComplete(); }
Example 2
Source File: RxLifecycleTest.java From RxLifecycle with Apache License 2.0 | 6 votes |
@Test public void testBindUntilActivityEvent() { BehaviorSubject<ActivityEvent> lifecycle = BehaviorSubject.create(); TestObserver<Object> testObserver = observable.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.STOP)).test(); lifecycle.onNext(ActivityEvent.CREATE); testObserver.assertNotComplete(); lifecycle.onNext(ActivityEvent.START); testObserver.assertNotComplete(); lifecycle.onNext(ActivityEvent.RESUME); testObserver.assertNotComplete(); lifecycle.onNext(ActivityEvent.PAUSE); testObserver.assertNotComplete(); lifecycle.onNext(ActivityEvent.STOP); testObserver.assertComplete(); }
Example 3
Source File: RxFragmentLifecycleTest.java From RxLifecycle with Apache License 2.0 | 6 votes |
private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) { Fragment fragment = (Fragment) provider; startFragment(fragment); TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test(); fragment.onAttach(null); testObserver.assertNotComplete(); fragment.onCreate(null); testObserver.assertNotComplete(); fragment.onViewCreated(null, null); testObserver.assertNotComplete(); fragment.onStart(); testObserver.assertNotComplete(); fragment.onResume(); testObserver.assertNotComplete(); fragment.onPause(); testObserver.assertNotComplete(); fragment.onStop(); testObserver.assertComplete(); }
Example 4
Source File: ReplayingShareObservableTest.java From RxReplayingShare with Apache License 2.0 | 6 votes |
@Test public void completeClearsCacheAndResubscribesStartingWithDefault() { List<String> start = new ArrayList<>(); start.add("initA"); PublishSubject<String> upstream = PublishSubject.create(); Observable<String> replayed = upstream.startWithIterable(start).compose(ReplayingShare.createWithDefault("default")); TestObserver<String> observer1 = new TestObserver<>(); replayed.subscribe(observer1); observer1.assertValues("default", "initA"); TestObserver<String> observer2 = new TestObserver<>(); replayed.subscribe(observer2); observer1.assertValues("default", "initA"); upstream.onComplete(); observer1.assertComplete(); observer2.assertComplete(); start.set(0, "initB"); TestObserver<String> observer3 = new TestObserver<>(); replayed.subscribe(observer3); observer3.assertValues("default", "initB"); }
Example 5
Source File: TimeLimiterTransformerCompletableTest.java From resilience4j with Apache License 2.0 | 6 votes |
@Test public void doNotTimeout() { given(helloWorldService.returnHelloWorld()) .willReturn("hello"); given(timeLimiter.getTimeLimiterConfig()) .willReturn(toConfig(Duration.ofMinutes(1))); TestObserver<?> observer = Completable.fromRunnable(helloWorldService::returnHelloWorld) .compose(TimeLimiterTransformer.of(timeLimiter)) .test(); testScheduler.advanceTimeBy(1, TimeUnit.MINUTES); observer.assertComplete(); then(timeLimiter).should() .onSuccess(); }
Example 6
Source File: AndroidLifecycleFragmentTest.java From RxLifecycle with Apache License 2.0 | 6 votes |
private void testBindUntilEvent(LifecycleOwner owner) { Fragment fragment = (Fragment) owner; ActivityController<?> controller = startFragment(fragment); TestObserver<Object> testObserver = observable.compose(AndroidLifecycle.createLifecycleProvider(owner).bindUntilEvent(Lifecycle.Event.ON_STOP)).test(); testObserver.assertNotComplete(); controller.start(); testObserver.assertNotComplete(); controller.resume(); testObserver.assertNotComplete(); controller.pause(); testObserver.assertNotComplete(); controller.stop(); testObserver.assertComplete(); }
Example 7
Source File: UntilLifecycleTransformerMaybeTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void noEvent() { TestObserver<String> testObserver = maybe .compose(RxLifecycle.<String, String>bind(lifecycle)) .test(); stream.onNext("1"); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 8
Source File: RxConnectablesTest.java From mobius with Apache License 2.0 | 5 votes |
@Test public void shouldPropagateCompletion() throws Exception { TestObserver<Integer> observer = input.compose(RxConnectables.toTransformer(connectable)).test(); input.onNext("hi"); input.onComplete(); observer.awaitDone(1, TimeUnit.SECONDS); observer.assertComplete(); }
Example 9
Source File: UntilEventTransformerObservableTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void twoEvents() { TestObserver<String> testObserver = stream .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop")) .test(); stream.onNext("1"); lifecycle.onNext("keep going"); stream.onNext("2"); lifecycle.onNext("stop"); stream.onNext("3"); testObserver.assertValues("1", "2"); testObserver.assertComplete(); }
Example 10
Source File: UntilCorrespondingEventTransformerSingleTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void twoOpenEvents() { TestObserver<String> testObserver = Single.just("1") .delay(1, TimeUnit.MILLISECONDS, testScheduler) .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS)) .test(); testObserver.assertNoValues(); lifecycle.onNext("create"); lifecycle.onNext("start"); testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 11
Source File: RxLifecycleTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void testEndsImmediatelyOutsideLifecycle() { BehaviorSubject<Lifecycle.Event> lifecycle = BehaviorSubject.create(); lifecycle.onNext(Lifecycle.Event.ON_DESTROY); TestObserver<Object> testObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test(); testObserver.assertComplete(); }
Example 12
Source File: UntilCorrespondingEventTransformerSingleTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void noEvents() { TestObserver<String> testObserver = Single.just("1") .delay(1, TimeUnit.MILLISECONDS, testScheduler) .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS)) .test(); testObserver.assertNoValues(); testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 13
Source File: UntilCorrespondingEventTransformerObservableTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void openAndCloseEvent() { TestObserver<String> testObserver = stream .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS)) .test(); lifecycle.onNext("create"); stream.onNext("1"); lifecycle.onNext("destroy"); stream.onNext("2"); testObserver.assertValues("1"); testObserver.assertComplete(); }
Example 14
Source File: UntilLifecycleTransformerCompletableTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void noEvent() { TestObserver<Void> testObserver = completable .compose(RxLifecycle.bind(lifecycle)) .test(); subject.onComplete(); testObserver.assertComplete(); }
Example 15
Source File: UntilCorrespondingEventTransformerCompletableTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void noEvents() { TestObserver<Void> testObserver = completable .compose(RxLifecycle.bind(lifecycle, CORRESPONDING_EVENTS)) .test(); subject.onComplete(); testObserver.assertComplete(); }
Example 16
Source File: TimeLimiterTransformerMaybeTest.java From resilience4j with Apache License 2.0 | 5 votes |
@Test public void doNotTimeoutEmpty() { given(timeLimiter.getTimeLimiterConfig()) .willReturn(toConfig(Duration.ofMinutes(1))); TestObserver<?> observer = Maybe.empty() .compose(TimeLimiterTransformer.of(timeLimiter)) .test(); observer.assertComplete(); then(timeLimiter).should() .onSuccess(); }
Example 17
Source File: UntilEventTransformerMaybeTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void twoEvents() { TestObserver<String> testObserver = maybe .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop")) .test(); lifecycle.onNext("keep going"); lifecycle.onNext("stop"); subject.onNext("1"); testObserver.assertNoValues(); testObserver.assertComplete(); }
Example 18
Source File: UntilEventTransformerSingleTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void oneWrongEvent() { TestObserver<String> testObserver = Single.just("1") .delay(1, TimeUnit.MILLISECONDS, testScheduler) .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop")) .test(); testObserver.assertNoValues(); lifecycle.onNext("keep going"); testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 19
Source File: UntilLifecycleTransformerObservableTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void oneEvent() { TestObserver<String> testObserver = stream .compose(RxLifecycle.<String, String>bind(lifecycle)) .test(); stream.onNext("1"); lifecycle.onNext("stop"); stream.onNext("2"); testObserver.assertValues("1"); testObserver.assertComplete(); }
Example 20
Source File: RxSupportFragmentLifecycleTest.java From RxLifecycle with Apache License 2.0 | 4 votes |
private void testBindToLifecycle(LifecycleProvider<FragmentEvent> provider) { Fragment fragment = (Fragment) provider; startFragment(fragment); fragment.onAttach(null); TestObserver<Object> attachObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onCreate(null); attachObserver.assertNotComplete(); TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onViewCreated(null, null); attachObserver.assertNotComplete(); createObserver.assertNotComplete(); TestObserver<Object> createViewObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onStart(); attachObserver.assertNotComplete(); createObserver.assertNotComplete(); createViewObserver.assertNotComplete(); TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onResume(); attachObserver.assertNotComplete(); createObserver.assertNotComplete(); createViewObserver.assertNotComplete(); startObserver.assertNotComplete(); TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onPause(); attachObserver.assertNotComplete(); createObserver.assertNotComplete(); createViewObserver.assertNotComplete(); startObserver.assertNotComplete(); resumeObserver.assertComplete(); TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onStop(); attachObserver.assertNotComplete(); createObserver.assertNotComplete(); createViewObserver.assertNotComplete(); startObserver.assertComplete(); pauseObserver.assertComplete(); TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onDestroyView(); attachObserver.assertNotComplete(); createObserver.assertNotComplete(); createViewObserver.assertComplete(); stopObserver.assertComplete(); TestObserver<Object> destroyViewObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onDestroy(); attachObserver.assertNotComplete(); createObserver.assertComplete(); destroyViewObserver.assertComplete(); TestObserver<Object> destroyObserver = observable.compose(provider.bindToLifecycle()).test(); fragment.onDetach(); attachObserver.assertComplete(); destroyObserver.assertComplete(); }