Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/operators/single/SingleStartWithTest.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.single;
15
16 import org.junit.Test;
17
18 import io.reactivex.rxjava3.core.*;
19 import io.reactivex.rxjava3.exceptions.TestException;
20
21 public class SingleStartWithTest {
22
23 @Test
24 public void justCompletableComplete() {
25 Single.just(1)
26 .startWith(Completable.complete())
27 .test()
28 .assertResult(1);
29 }
30
31 @Test
32 public void justCompletableError() {
33 Single.just(1)
34 .startWith(Completable.error(new TestException()))
35 .test()
36 .assertFailure(TestException.class);
37 }
38
39 @Test
40 public void justSingleJust() {
41 Single.just(1)
42 .startWith(Single.just(0))
43 .test()
44 .assertResult(0, 1);
45 }
46
47 @Test
48 public void justSingleError() {
49 Single.just(1)
50 .startWith(Single.error(new TestException()))
51 .test()
52 .assertFailure(TestException.class);
53 }
54
55 @Test
56 public void justMaybeJust() {
57 Single.just(1)
58 .startWith(Maybe.just(0))
59 .test()
60 .assertResult(0, 1);
61 }
62
63 @Test
64 public void justMaybeEmpty() {
65 Single.just(1)
66 .startWith(Maybe.empty())
67 .test()
68 .assertResult(1);
69 }
70
71 @Test
72 public void justMaybeError() {
73 Single.just(1)
74 .startWith(Maybe.error(new TestException()))
75 .test()
76 .assertFailure(TestException.class);
77 }
78
79 @Test
80 public void justObservableJust() {
81 Single.just(1)
82 .startWith(Observable.just(-1, 0))
83 .test()
84 .assertResult(-1, 0, 1);
85 }
86
87 @Test
88 public void justObservableEmpty() {
89 Single.just(1)
90 .startWith(Observable.empty())
91 .test()
92 .assertResult(1);
93 }
94
95 @Test
96 public void justObservableError() {
97 Single.just(1)
98 .startWith(Observable.error(new TestException()))
99 .test()
100 .assertFailure(TestException.class);
101 }
102
103 @Test
104 public void justFlowableJust() {
105 Single.just(1)
106 .startWith(Flowable.just(-1, 0))
107 .test()
108 .assertResult(-1, 0, 1);
109 }
110
111 @Test
112 public void justFlowableEmpty() {
113 Single.just(1)
114 .startWith(Observable.empty())
115 .test()
116 .assertResult(1);
117 }
118
119 @Test
120 public void justFlowableError() {
121 Single.just(1)
122 .startWith(Flowable.error(new TestException()))
123 .test()
124 .assertFailure(TestException.class);
125 }
126 }