|
15 | 15 | */ |
16 | 16 | package rx.operators; |
17 | 17 |
|
18 | | -import static org.mockito.Matchers.*; |
19 | | -import static org.mockito.Mockito.*; |
20 | | -import static rx.operators.OperationDematerialize.*; |
| 18 | +import static org.mockito.Matchers.any; |
| 19 | +import static org.mockito.Mockito.mock; |
| 20 | +import static org.mockito.Mockito.never; |
| 21 | +import static org.mockito.Mockito.times; |
| 22 | +import static org.mockito.Mockito.verify; |
| 23 | +import static rx.operators.OperationDematerialize.dematerialize; |
21 | 24 |
|
22 | 25 | import org.junit.Test; |
23 | 26 |
|
24 | 27 | import rx.Notification; |
25 | 28 | import rx.Observable; |
26 | 29 | import rx.Observer; |
| 30 | +import rx.observers.TestSubscriber; |
27 | 31 |
|
28 | 32 | public class OperationDematerializeTest { |
29 | 33 |
|
@@ -71,4 +75,35 @@ public void testDematerialize3() { |
71 | 75 | verify(observer, times(0)).onCompleted(); |
72 | 76 | verify(observer, times(0)).onNext(any(Integer.class)); |
73 | 77 | } |
| 78 | + |
| 79 | + @Test |
| 80 | + public void testErrorPassThru() { |
| 81 | + Exception exception = new Exception("test"); |
| 82 | + Observable<Integer> observable = Observable.error(exception); |
| 83 | + Observable<Integer> dematerialize = observable.dematerialize(); |
| 84 | + |
| 85 | + Observer<Integer> observer = mock(Observer.class); |
| 86 | + dematerialize.subscribe(observer); |
| 87 | + |
| 88 | + verify(observer, times(1)).onError(exception); |
| 89 | + verify(observer, times(0)).onCompleted(); |
| 90 | + verify(observer, times(0)).onNext(any(Integer.class)); |
| 91 | + } |
| 92 | + |
| 93 | + @Test |
| 94 | + public void testCompletePassThru() { |
| 95 | + Observable<Integer> observable = Observable.empty(); |
| 96 | + Observable<Integer> dematerialize = observable.dematerialize(); |
| 97 | + |
| 98 | + Observer<Integer> observer = mock(Observer.class); |
| 99 | + TestSubscriber<Integer> ts = new TestSubscriber<Integer>(observer); |
| 100 | + dematerialize.subscribe(ts); |
| 101 | + |
| 102 | + System.out.println(ts.getOnErrorEvents()); |
| 103 | + |
| 104 | + verify(observer, never()).onError(any(Throwable.class)); |
| 105 | + verify(observer, times(1)).onCompleted(); |
| 106 | + verify(observer, times(0)).onNext(any(Integer.class)); |
| 107 | + } |
| 108 | + |
74 | 109 | } |
0 commit comments