Debian Codegraph @

src/test/java/io/reactivex/rxjava3/observable/ObservableStartWithTests.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.observable;
15
16 import static org.junit.Assert.assertEquals;
17
18 import java.util.*;
19
20 import org.junit.Test;
21
22 import io.reactivex.rxjava3.core.Observable;
23 import io.reactivex.rxjava3.core.RxJavaTest;
24
25 public class ObservableStartWithTests extends RxJavaTest {
26
27 @Test
28 public void startWith1() {
29 List<String> values = Observable.just("one", "two")
30 .startWithArray("zero").toList().blockingGet();
31
32 assertEquals("zero", values.get(0));
33 assertEquals("two", values.get(2));
34 }
35
36 @Test
37 public void startWithIterable() {
38 List<String> li = new ArrayList<>();
39 li.add("alpha");
40 li.add("beta");
41 List<String> values = Observable.just("one", "two").startWithIterable(li).toList().blockingGet();
42
43 assertEquals("alpha", values.get(0));
44 assertEquals("beta", values.get(1));
45 assertEquals("one", values.get(2));
46 assertEquals("two", values.get(3));
47 }
48
49 @Test
50 public void startWithObservable() {
51 List<String> li = new ArrayList<>();
52 li.add("alpha");
53 li.add("beta");
54 List<String> values = Observable.just("one", "two")
55 .startWith(Observable.fromIterable(li))
56 .toList()
57 .blockingGet();
58
59 assertEquals("alpha", values.get(0));
60 assertEquals("beta", values.get(1));
61 assertEquals("one", values.get(2));
62 assertEquals("two", values.get(3));
63 }
64
65 @Test
66 public void startWithEmpty() {
67 Observable.just(1).startWithArray().test().assertResult(1);
68 }
69 }