Debian Codegraph @

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