| 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.observers; |
| 15 |
|
| 16 |
import io.reactivex.rxjava3.disposables.Disposable; |
| 17 |
import org.junit.Test; |
| 18 |
|
| 19 |
import io.reactivex.rxjava3.annotations.Nullable; |
| 20 |
import io.reactivex.rxjava3.core.RxJavaTest; |
| 21 |
import io.reactivex.rxjava3.observers.TestObserver; |
| 22 |
import io.reactivex.rxjava3.testsupport.TestObserverEx; |
| 23 |
|
| 24 |
public class BasicFuseableObserverTest extends RxJavaTest { |
| 25 |
|
| 26 |
@Test(expected = UnsupportedOperationException.class) |
| 27 |
public void offer() { |
| 28 |
TestObserverEx<Integer> to = new TestObserverEx<>(); |
| 29 |
BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(to) { |
| 30 |
@Nullable |
| 31 |
@Override |
| 32 |
public Integer poll() throws Exception { |
| 33 |
return null; |
| 34 |
} |
| 35 |
|
| 36 |
@Override |
| 37 |
public int requestFusion(int mode) { |
| 38 |
return 0; |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public void onNext(Integer value) { |
| 43 |
} |
| 44 |
|
| 45 |
@Override |
| 46 |
protected boolean beforeDownstream() { |
| 47 |
return false; |
| 48 |
} |
| 49 |
}; |
| 50 |
|
| 51 |
o.onSubscribe(Disposable.disposed()); |
| 52 |
|
| 53 |
to.assertNotSubscribed(); |
| 54 |
|
| 55 |
o.offer(1); |
| 56 |
} |
| 57 |
|
| 58 |
@Test(expected = UnsupportedOperationException.class) |
| 59 |
public void offer2() { |
| 60 |
BasicFuseableObserver<Integer, Integer> o = new BasicFuseableObserver<Integer, Integer>(new TestObserver<>()) { |
| 61 |
@Nullable |
| 62 |
@Override |
| 63 |
public Integer poll() throws Exception { |
| 64 |
return null; |
| 65 |
} |
| 66 |
|
| 67 |
@Override |
| 68 |
public int requestFusion(int mode) { |
| 69 |
return 0; |
| 70 |
} |
| 71 |
|
| 72 |
@Override |
| 73 |
public void onNext(Integer value) { |
| 74 |
} |
| 75 |
}; |
| 76 |
|
| 77 |
o.offer(1, 2); |
| 78 |
} |
| 79 |
} |