Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeHideTest.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.maybe;
15
16 import static org.junit.Assert.*;
17
18 import org.junit.Test;
19
20 import io.reactivex.rxjava3.core.*;
21 import io.reactivex.rxjava3.exceptions.TestException;
22 import io.reactivex.rxjava3.functions.Function;
23 import io.reactivex.rxjava3.operators.ScalarSupplier;
24 import io.reactivex.rxjava3.processors.PublishProcessor;
25 import io.reactivex.rxjava3.testsupport.TestHelper;
26
27 public class MaybeHideTest extends RxJavaTest {
28
29 @Test
30 public void normal() {
31 Maybe.just(1)
32 .hide()
33 .test()
34 .assertResult(1);
35 }
36
37 @Test
38 public void empty() {
39 Maybe.empty()
40 .hide()
41 .test()
42 .assertResult();
43 }
44
45 @Test
46 public void error() {
47 Maybe.error(new TestException())
48 .hide()
49 .test()
50 .assertFailure(TestException.class);
51 }
52
53 @Test
54 public void hidden() {
55 assertTrue(Maybe.just(1) instanceof ScalarSupplier);
56
57 assertFalse(Maybe.just(1).hide() instanceof ScalarSupplier);
58 }
59
60 @Test
61 public void dispose() {
62 TestHelper.checkDisposedMaybe(new Function<Maybe<Object>, MaybeSource<Object>>() {
63 @Override
64 public MaybeSource<Object> apply(Maybe<Object> m) throws Exception {
65 return m.hide();
66 }
67 });
68 }
69
70 @Test
71 public void isDisposed() {
72 PublishProcessor<Integer> pp = PublishProcessor.create();
73
74 TestHelper.checkDisposed(pp.singleElement().hide());
75 }
76
77 @Test
78 public void doubleOnSubscribe() {
79 TestHelper.checkDoubleOnSubscribeMaybe(new Function<Maybe<Object>, Maybe<Object>>() {
80 @Override
81 public Maybe<Object> apply(Maybe<Object> f) throws Exception {
82 return f.hide();
83 }
84 });
85 }
86 }