1
1
package rx .operators ;
2
2
3
+ import static org .mockito .Matchers .*;
4
+ import static org .mockito .Mockito .*;
5
+ import static org .mockito .MockitoAnnotations .*;
6
+ import static rx .operators .OperationDistinct .*;
7
+
8
+ import java .util .Comparator ;
9
+
3
10
import org .junit .Before ;
4
11
import org .junit .Test ;
5
12
import org .mockito .InOrder ;
6
13
import org .mockito .Mock ;
14
+
7
15
import rx .Observable ;
8
16
import rx .Observer ;
9
17
import rx .util .functions .Func1 ;
10
18
11
- import java .util .Comparator ;
12
-
13
- import static org .mockito .Matchers .any ;
14
- import static org .mockito .Matchers .anyString ;
15
- import static org .mockito .Mockito .*;
16
- import static org .mockito .Mockito .never ;
17
- import static org .mockito .MockitoAnnotations .initMocks ;
18
- import static rx .Observable .*;
19
- import static rx .operators .OperationDistinct .distinct ;
20
-
21
19
public class OperationDistinctTest {
22
20
23
21
@ Mock
@@ -50,8 +48,8 @@ public void before() {
50
48
51
49
@ Test
52
50
public void testDistinctOfNone () {
53
- Observable <String > src = empty ();
54
- create (distinct (src )).subscribe (w );
51
+ Observable <String > src = Observable . empty ();
52
+ Observable . create (distinct (src )).subscribe (w );
55
53
56
54
verify (w , never ()).onNext (anyString ());
57
55
verify (w , never ()).onError (any (Throwable .class ));
@@ -60,8 +58,8 @@ public void testDistinctOfNone() {
60
58
61
59
@ Test
62
60
public void testDistinctOfNoneWithKeySelector () {
63
- Observable <String > src = empty ();
64
- create (distinct (src , TO_UPPER_WITH_EXCEPTION )).subscribe (w );
61
+ Observable <String > src = Observable . empty ();
62
+ Observable . create (distinct (src , TO_UPPER_WITH_EXCEPTION )).subscribe (w );
65
63
66
64
verify (w , never ()).onNext (anyString ());
67
65
verify (w , never ()).onError (any (Throwable .class ));
@@ -70,8 +68,8 @@ public void testDistinctOfNoneWithKeySelector() {
70
68
71
69
@ Test
72
70
public void testDistinctOfNormalSource () {
73
- Observable <String > src = from ("a" , "b" , "c" , "c" , "c" , "b" , "b" , "a" , "e" );
74
- create (distinct (src )).subscribe (w );
71
+ Observable <String > src = Observable . from ("a" , "b" , "c" , "c" , "c" , "b" , "b" , "a" , "e" );
72
+ Observable . create (distinct (src )).subscribe (w );
75
73
76
74
InOrder inOrder = inOrder (w );
77
75
inOrder .verify (w , times (1 )).onNext ("a" );
@@ -85,8 +83,8 @@ public void testDistinctOfNormalSource() {
85
83
86
84
@ Test
87
85
public void testDistinctOfNormalSourceWithKeySelector () {
88
- Observable <String > src = from ("a" , "B" , "c" , "C" , "c" , "B" , "b" , "a" , "E" );
89
- create (distinct (src , TO_UPPER_WITH_EXCEPTION )).subscribe (w );
86
+ Observable <String > src = Observable . from ("a" , "B" , "c" , "C" , "c" , "B" , "b" , "a" , "E" );
87
+ Observable . create (distinct (src , TO_UPPER_WITH_EXCEPTION )).subscribe (w );
90
88
91
89
InOrder inOrder = inOrder (w );
92
90
inOrder .verify (w , times (1 )).onNext ("a" );
@@ -100,8 +98,8 @@ public void testDistinctOfNormalSourceWithKeySelector() {
100
98
101
99
@ Test
102
100
public void testDistinctOfNormalSourceWithComparator () {
103
- Observable <String > src = from ("1" , "12" , "123" , "aaa" , "321" , "12" , "21" , "1" , "12345" );
104
- create (distinct (src , COMPARE_LENGTH )).subscribe (w );
101
+ Observable <String > src = Observable . from ("1" , "12" , "123" , "aaa" , "321" , "12" , "21" , "1" , "12345" );
102
+ Observable . create (distinct (src , COMPARE_LENGTH )).subscribe (w );
105
103
106
104
InOrder inOrder = inOrder (w );
107
105
inOrder .verify (w , times (1 )).onNext ("1" );
@@ -115,8 +113,8 @@ public void testDistinctOfNormalSourceWithComparator() {
115
113
116
114
@ Test
117
115
public void testDistinctOfNormalSourceWithKeySelectorAndComparator () {
118
- Observable <String > src = from ("a" , "x" , "ab" , "abc" , "cba" , "de" , "x" , "a" , "abcd" );
119
- create (distinct (src , TO_UPPER_WITH_EXCEPTION , COMPARE_LENGTH )).subscribe (w );
116
+ Observable <String > src = Observable . from ("a" , "x" , "ab" , "abc" , "cba" , "de" , "x" , "a" , "abcd" );
117
+ Observable . create (distinct (src , TO_UPPER_WITH_EXCEPTION , COMPARE_LENGTH )).subscribe (w );
120
118
121
119
InOrder inOrder = inOrder (w );
122
120
inOrder .verify (w , times (1 )).onNext ("a" );
@@ -130,13 +128,13 @@ public void testDistinctOfNormalSourceWithKeySelectorAndComparator() {
130
128
131
129
@ Test
132
130
public void testDistinctOfNormalSourceWithKeySelectorAndComparatorAndTwoSubscriptions () {
133
- Observable <String > src = from ("a" , "x" , "ab" , "abc" , "cba" , "de" , "x" , "a" , "abcd" );
134
- create (distinct (src , TO_UPPER_WITH_EXCEPTION , COMPARE_LENGTH )).subscribe (w );
131
+ Observable <String > src = Observable . from ("a" , "x" , "ab" , "abc" , "cba" , "de" , "x" , "a" , "abcd" );
132
+ Observable . create (distinct (src , TO_UPPER_WITH_EXCEPTION , COMPARE_LENGTH )).subscribe (w );
135
133
136
134
InOrder inOrder = inOrder (w );
137
135
inOrder .verify (w , times (1 )).onNext ("a" );
138
136
inOrder .verify (w , times (1 )).onNext ("x" );
139
- create (distinct (src , TO_UPPER_WITH_EXCEPTION , COMPARE_LENGTH )).subscribe (w2 );
137
+ Observable . create (distinct (src , TO_UPPER_WITH_EXCEPTION , COMPARE_LENGTH )).subscribe (w2 );
140
138
inOrder .verify (w , times (1 )).onNext ("abc" );
141
139
inOrder .verify (w , times (1 )).onNext ("abcd" );
142
140
inOrder .verify (w , times (1 )).onCompleted ();
@@ -155,8 +153,8 @@ public void testDistinctOfNormalSourceWithKeySelectorAndComparatorAndTwoSubscrip
155
153
156
154
@ Test
157
155
public void testDistinctOfSourceWithNulls () {
158
- Observable <String > src = from (null , "a" , "a" , null , null , "b" , null );
159
- create (distinct (src )).subscribe (w );
156
+ Observable <String > src = Observable . from (null , "a" , "a" , null , null , "b" , null );
157
+ Observable . create (distinct (src )).subscribe (w );
160
158
161
159
InOrder inOrder = inOrder (w );
162
160
inOrder .verify (w , times (1 )).onNext (null );
@@ -169,8 +167,8 @@ public void testDistinctOfSourceWithNulls() {
169
167
170
168
@ Test
171
169
public void testDistinctOfSourceWithExceptionsFromKeySelector () {
172
- Observable <String > src = from ("a" , "b" , null , "c" );
173
- create (distinct (src , TO_UPPER_WITH_EXCEPTION )).subscribe (w );
170
+ Observable <String > src = Observable . from ("a" , "b" , null , "c" );
171
+ Observable . create (distinct (src , TO_UPPER_WITH_EXCEPTION )).subscribe (w );
174
172
175
173
InOrder inOrder = inOrder (w );
176
174
inOrder .verify (w , times (1 )).onNext ("a" );
0 commit comments