| 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.completable; |
| 15 |
|
| 16 |
import static org.junit.Assert.assertFalse; |
| 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.processors.PublishProcessor; |
| 24 |
import io.reactivex.rxjava3.subjects.CompletableSubject; |
| 25 |
import io.reactivex.rxjava3.testsupport.TestHelper; |
| 26 |
|
| 27 |
public class CompletableHideTest extends RxJavaTest { |
| 28 |
|
| 29 |
@Test |
| 30 |
public void never() { |
| 31 |
Completable.never() |
| 32 |
.hide() |
| 33 |
.test() |
| 34 |
.assertNotComplete() |
| 35 |
.assertNoErrors(); |
| 36 |
} |
| 37 |
|
| 38 |
@Test |
| 39 |
public void complete() { |
| 40 |
Completable.complete() |
| 41 |
.hide() |
| 42 |
.test() |
| 43 |
.assertResult(); |
| 44 |
} |
| 45 |
|
| 46 |
@Test |
| 47 |
public void error() { |
| 48 |
Completable.error(new TestException()) |
| 49 |
.hide() |
| 50 |
.test() |
| 51 |
.assertFailure(TestException.class); |
| 52 |
} |
| 53 |
|
| 54 |
@Test |
| 55 |
public void hidden() { |
| 56 |
assertFalse(CompletableSubject.create().hide() instanceof CompletableSubject); |
| 57 |
} |
| 58 |
|
| 59 |
@Test |
| 60 |
public void dispose() { |
| 61 |
TestHelper.checkDisposedCompletable(new Function<Completable, CompletableSource>() { |
| 62 |
@Override |
| 63 |
public CompletableSource apply(Completable m) throws Exception { |
| 64 |
return m.hide(); |
| 65 |
} |
| 66 |
}); |
| 67 |
} |
| 68 |
|
| 69 |
@Test |
| 70 |
public void isDisposed() { |
| 71 |
PublishProcessor<Integer> pp = PublishProcessor.create(); |
| 72 |
|
| 73 |
TestHelper.checkDisposed(pp.ignoreElements().hide()); |
| 74 |
} |
| 75 |
|
| 76 |
@Test |
| 77 |
public void doubleOnSubscribe() { |
| 78 |
TestHelper.checkDoubleOnSubscribeCompletable(new Function<Completable, Completable>() { |
| 79 |
@Override |
| 80 |
public Completable apply(Completable f) throws Exception { |
| 81 |
return f.hide(); |
| 82 |
} |
| 83 |
}); |
| 84 |
} |
| 85 |
} |