Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/operators/single/SingleInternalHelperTest.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 static org.junit.Assert.*;
17
18 import java.util.*;
19
20 import org.junit.Test;
21
22 import io.reactivex.rxjava3.core.*;
23 import io.reactivex.rxjava3.testsupport.TestHelper;
24
25 public class SingleInternalHelperTest extends RxJavaTest {
26
27 @Test
28 public void utilityClass() {
29 TestHelper.checkUtilityClass(SingleInternalHelper.class);
30 }
31
32 @Test
33 public void noSuchElementCallableEnum() {
34 assertEquals(1, SingleInternalHelper.NoSuchElementSupplier.values().length);
35 assertNotNull(SingleInternalHelper.NoSuchElementSupplier.valueOf("INSTANCE"));
36 }
37
38 @Test
39 public void toFlowableEnum() {
40 assertEquals(1, SingleInternalHelper.ToFlowable.values().length);
41 assertNotNull(SingleInternalHelper.ToFlowable.valueOf("INSTANCE"));
42 }
43
44 @Test
45 public void singleIterableToFlowableIterable() {
46 Iterable<? extends Flowable<Integer>> it = SingleInternalHelper.iterableToFlowable(
47 Collections.singletonList(Single.just(1)));
48
49 Iterator<? extends Flowable<Integer>> iter = it.iterator();
50
51 if (iter.hasNext()) {
52 iter.next().test().assertResult(1);
53 if (iter.hasNext()) {
54 fail("Iterator reports an additional element");
55 }
56 } else {
57 fail("Iterator was empty");
58 }
59 }
60 }