Java Code Examples for io.reactivex.rxjava3.observers.TestObserver#assertValue()
The following examples show how to use
io.reactivex.rxjava3.observers.TestObserver#assertValue() .
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: PublishRelayTest.java From RxRelay with Apache License 2.0 | 6 votes |
@Test public void crossCancel() { final TestObserver<Integer> ts1 = new TestObserver<Integer>(); TestObserver<Integer> ts2 = new TestObserver<Integer>() { @Override public void onNext(Integer t) { super.onNext(t); ts1.dispose(); } }; PublishRelay<Integer> pp = PublishRelay.create(); pp.subscribe(ts2); pp.subscribe(ts1); pp.accept(1); ts2.assertValue(1); ts1.assertNoValues(); }
Example 2
Source File: PublishRelayTest.java From RxRelay with Apache License 2.0 | 6 votes |
@Test public void crossCancel() { final TestObserver<Integer> ts1 = new TestObserver<Integer>(); TestObserver<Integer> ts2 = new TestObserver<Integer>() { @Override public void onNext(Integer t) { super.onNext(t); ts1.dispose(); } }; PublishRelay<Integer> pp = PublishRelay.create(); pp.subscribe(ts2); pp.subscribe(ts1); pp.accept(1); ts2.assertValue(1); ts1.assertNoValues(); }
Example 3
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 4
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 5
Source File: UntilLifecycleTransformerSingleTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void noEvent() { TestObserver<String> testObserver = Single.just("1") .delay(1, TimeUnit.MILLISECONDS, testScheduler) .compose(RxLifecycle.<String, String>bind(lifecycle)) .test(); testObserver.assertNoValues(); testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 6
Source File: UntilEventTransformerMaybeTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void oneWrongEvent() { TestObserver<String> testObserver = maybe .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop")) .test(); lifecycle.onNext("keep going"); subject.onNext("1"); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 7
Source File: UntilEventTransformerMaybeTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void noEvents() { TestObserver<String> testObserver = maybe .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop")) .test(); subject.onNext("1"); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 8
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 9
Source File: UntilEventTransformerSingleTest.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>bindUntilEvent(lifecycle, "stop")) .test(); testObserver.assertNoValues(); testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 10
Source File: UntilCorrespondingEventTransformerMaybeTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void twoOpenEvents() { TestObserver<String> testObserver = maybe .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS)) .test(); lifecycle.onNext("create"); lifecycle.onNext("start"); subject.onNext("1"); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 11
Source File: UntilCorrespondingEventTransformerMaybeTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void oneStartEvent() { TestObserver<String> testObserver = maybe .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS)) .test(); lifecycle.onNext("create"); subject.onNext("1"); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 12
Source File: UntilCorrespondingEventTransformerMaybeTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void noEvents() { TestObserver<String> testObserver = maybe .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS)) .test(); subject.onNext("1"); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 13
Source File: TransformersTest.java From mobius with Apache License 2.0 | 5 votes |
@Test public void effectPerformerInvokesFunctionWithReceivedEffectAndEmitsReturnedEvents() { PublishSubject<String> upstream = PublishSubject.create(); TestScheduler scheduler = new TestScheduler(); Function<String, Integer> function = String::length; TestObserver<Integer> observer = upstream.compose(Transformers.fromFunction(function, scheduler)).test(); upstream.onNext("Hello"); scheduler.triggerActions(); observer.assertValue(5); }
Example 14
Source File: UntilCorrespondingEventTransformerSingleTest.java From RxLifecycle with Apache License 2.0 | 5 votes |
@Test public void oneStartEvent() { 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"); testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); testObserver.assertValue("1"); testObserver.assertComplete(); }
Example 15
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 16
Source File: SerializedRelayTest.java From RxRelay with Apache License 2.0 | 5 votes |
@Test public void testBasic() { SerializedRelay<String> subject = new SerializedRelay<String>(PublishRelay.<String> create()); TestObserver<String> ts = new TestObserver<String>(); subject.subscribe(ts); subject.accept("hello"); ts.assertValue("hello"); }
Example 17
Source File: SerializedRelayTest.java From RxRelay with Apache License 2.0 | 5 votes |
@Test public void testBasic() { SerializedRelay<String> subject = new SerializedRelay<String>(PublishRelay.<String> create()); TestObserver<String> ts = new TestObserver<String>(); subject.subscribe(ts); subject.accept("hello"); ts.assertValue("hello"); }
Example 18
Source File: CountriesServiceSolvedTest.java From RxBasicsKata with MIT License | 5 votes |
@Test public void rx_CountAmountOfCountries() { Integer expected = CountriesTestProvider.countries().size(); TestObserver<Integer> testObserver = countriesService .countCountries(allCountries) .test(); testObserver.assertNoErrors(); testObserver.assertValue(expected); }
Example 19
Source File: CountriesServiceSolvedTest.java From RxBasicsKata with MIT License | 5 votes |
@Test public void rx_CountryNameInCapitals() { Country testCountry = CountriesTestProvider.countries().get(0); String expected = testCountry.name.toUpperCase(Locale.US); TestObserver<String> testObserver = countriesService .countryNameInCapitals(testCountry) .test(); testObserver.assertNoErrors(); testObserver.assertValue(expected); }