Skip to content

Commit e679dba

Browse files
committed
OperatorAsObservable LF
1 parent 073418f commit e679dba

File tree

1 file changed

+65
-65
lines changed

1 file changed

+65
-65
lines changed
Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
1-
/**
2-
* Copyright 2014 Netflix, Inc.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
package rx.operators;
18-
19-
import static org.junit.Assert.assertFalse;
20-
import org.junit.Test;
21-
import static org.mockito.Matchers.any;
22-
import static org.mockito.Mockito.*;
23-
import rx.Observable;
24-
import rx.Observer;
25-
import rx.subjects.PublishSubject;
26-
27-
public class OperatorAsObservableTest {
28-
@Test
29-
public void testHiding() {
30-
PublishSubject<Integer> src = PublishSubject.create();
31-
32-
Observable<Integer> dst = src.asObservable();
33-
34-
assertFalse(dst instanceof PublishSubject);
35-
36-
Observer<Object> o = mock(Observer.class);
37-
38-
dst.subscribe(o);
39-
40-
src.onNext(1);
41-
src.onCompleted();
42-
43-
verify(o).onNext(1);
44-
verify(o).onCompleted();
45-
verify(o, never()).onError(any(Throwable.class));
46-
}
47-
@Test
48-
public void testHidingError() {
49-
PublishSubject<Integer> src = PublishSubject.create();
50-
51-
Observable<Integer> dst = src.asObservable();
52-
53-
assertFalse(dst instanceof PublishSubject);
54-
55-
Observer<Object> o = mock(Observer.class);
56-
57-
dst.subscribe(o);
58-
59-
src.onError(new OperationReduceTest.CustomException());
60-
61-
verify(o, never()).onNext(any());
62-
verify(o, never()).onCompleted();
63-
verify(o).onError(any(OperationReduceTest.CustomException.class));
64-
}
65-
}
1+
/**
2+
* Copyright 2014 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package rx.operators;
18+
19+
import static org.junit.Assert.assertFalse;
20+
import org.junit.Test;
21+
import static org.mockito.Matchers.any;
22+
import static org.mockito.Mockito.*;
23+
import rx.Observable;
24+
import rx.Observer;
25+
import rx.subjects.PublishSubject;
26+
27+
public class OperatorAsObservableTest {
28+
@Test
29+
public void testHiding() {
30+
PublishSubject<Integer> src = PublishSubject.create();
31+
32+
Observable<Integer> dst = src.asObservable();
33+
34+
assertFalse(dst instanceof PublishSubject);
35+
36+
Observer<Object> o = mock(Observer.class);
37+
38+
dst.subscribe(o);
39+
40+
src.onNext(1);
41+
src.onCompleted();
42+
43+
verify(o).onNext(1);
44+
verify(o).onCompleted();
45+
verify(o, never()).onError(any(Throwable.class));
46+
}
47+
@Test
48+
public void testHidingError() {
49+
PublishSubject<Integer> src = PublishSubject.create();
50+
51+
Observable<Integer> dst = src.asObservable();
52+
53+
assertFalse(dst instanceof PublishSubject);
54+
55+
Observer<Object> o = mock(Observer.class);
56+
57+
dst.subscribe(o);
58+
59+
src.onError(new OperationReduceTest.CustomException());
60+
61+
verify(o, never()).onNext(any());
62+
verify(o, never()).onCompleted();
63+
verify(o).onError(any(OperationReduceTest.CustomException.class));
64+
}
65+
}

0 commit comments

Comments
 (0)