Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableToXTest.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.internal.operators.observable;
15
16 import org.junit.Test;
17
18 import io.reactivex.rxjava3.core.*;
19 import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
20 import io.reactivex.rxjava3.subscribers.TestSubscriber;
21
22 public class ObservableToXTest extends RxJavaTest {
23
24 @Test
25 public void toFlowableBuffer() {
26 Observable.range(1, 5)
27 .toFlowable(BackpressureStrategy.BUFFER)
28 .test(2L)
29 .assertValues(1, 2)
30 .assertNoErrors()
31 .assertNotComplete();
32 }
33
34 @Test
35 public void toFlowableDrop() {
36 Observable.range(1, 5)
37 .toFlowable(BackpressureStrategy.DROP)
38 .test(1)
39 .assertResult(1);
40 }
41
42 @Test
43 public void toFlowableLatest() {
44 TestSubscriber<Integer> ts = Observable.range(1, 5)
45 .toFlowable(BackpressureStrategy.LATEST)
46 .test(0);
47
48 ts.request(1);
49 ts
50 .assertResult(5);
51 }
52
53 @Test
54 public void toFlowableError1() {
55 Observable.range(1, 5)
56 .toFlowable(BackpressureStrategy.ERROR)
57 .test(1)
58 .assertFailure(MissingBackpressureException.class, 1);
59 }
60
61 @Test
62 public void toFlowableError2() {
63 Observable.range(1, 5)
64 .toFlowable(BackpressureStrategy.ERROR)
65 .test(5)
66 .assertResult(1, 2, 3, 4, 5);
67 }
68
69 @Test
70 public void toFlowableMissing() {
71 TestSubscriber<Integer> ts = Observable.range(1, 5)
72 .toFlowable(BackpressureStrategy.MISSING)
73 .test(0);
74
75 ts.request(2);
76 ts
77 .assertResult(1, 2, 3, 4, 5);
78 }
79 }