@@ -18,15 +18,11 @@ package rx.lang.kotlin
18
18
19
19
import rx.Observable
20
20
import org.junit.Test
21
- import rx.subscriptions.Subscriptions
22
21
import org.mockito.Mockito.*
23
22
import org.mockito.Matchers.*
24
- import rx.Observer
25
23
import org.junit.Assert.*
26
24
import rx.Notification
27
- import rx.Subscription
28
25
import kotlin.concurrent.thread
29
- import rx.Observable.OnSubscribeFunc
30
26
import rx.lang.kotlin.BasicKotlinTests.AsyncObservable
31
27
import rx.Observable.OnSubscribe
32
28
import rx.Subscriber
@@ -62,12 +58,12 @@ public class BasicKotlinTests : KotlinTests() {
62
58
63
59
[Test ]
64
60
public fun testLast () {
65
- assertEquals(" three" , Observable .from(listOf (" one" , " two" , " three" ))!! .toBlockingObservable ()!! .last())
61
+ assertEquals(" three" , Observable .from(listOf (" one" , " two" , " three" ))!! .toBlocking ()!! .last())
66
62
}
67
63
68
64
[Test ]
69
65
public fun testLastWithPredicate () {
70
- assertEquals(" two" , Observable .from(listOf (" one" , " two" , " three" ))!! .toBlockingObservable ()!! .last { x -> x!! .length == 3 })
66
+ assertEquals(" two" , Observable .from(listOf (" one" , " two" , " three" ))!! .toBlocking ()!! .last { x -> x!! .length == 3 })
71
67
}
72
68
73
69
[Test ]
@@ -150,21 +146,21 @@ public class BasicKotlinTests : KotlinTests() {
150
146
[Test ]
151
147
public fun testFromWithIterable () {
152
148
val list = listOf (1 , 2 , 3 , 4 , 5 )
153
- assertEquals(5 , Observable .from(list)!! .count()!! .toBlockingObservable ()!! .single())
149
+ assertEquals(5 , Observable .from(list)!! .count()!! .toBlocking ()!! .single())
154
150
}
155
151
156
152
[Test ]
157
153
public fun testFromWithObjects () {
158
154
val list = listOf (1 , 2 , 3 , 4 , 5 )
159
- assertEquals(2 , Observable .from(listOf (list, 6 ))!! .count()!! .toBlockingObservable ()!! .single())
155
+ assertEquals(2 , Observable .from(listOf (list, 6 ))!! .count()!! .toBlocking ()!! .single())
160
156
}
161
157
162
158
[Test ]
163
159
public fun testStartWith () {
164
160
val list = listOf (10 , 11 , 12 , 13 , 14 )
165
161
val startList = listOf (1 , 2 , 3 , 4 , 5 )
166
- assertEquals(6 , Observable .from(list)!! .startWith(0 )!! .count()!! .toBlockingObservable ()!! .single())
167
- assertEquals(10 , Observable .from(list)!! .startWith(startList)!! .count()!! .toBlockingObservable ()!! .single())
162
+ assertEquals(6 , Observable .from(list)!! .startWith(0 )!! .count()!! .toBlocking ()!! .single())
163
+ assertEquals(10 , Observable .from(list)!! .startWith(startList)!! .count()!! .toBlocking ()!! .single())
168
164
}
169
165
170
166
[Test ]
@@ -227,28 +223,28 @@ public class BasicKotlinTests : KotlinTests() {
227
223
228
224
[Test ]
229
225
public fun testForEach () {
230
- Observable .create(AsyncObservable ())!! .toBlockingObservable ()!! .forEach(received())
226
+ Observable .create(AsyncObservable ())!! .toBlocking ()!! .forEach(received())
231
227
verify(a, times(1 ))!! .received(1 )
232
228
verify(a, times(1 ))!! .received(2 )
233
229
verify(a, times(1 ))!! .received(3 )
234
230
}
235
231
236
232
[Test (expected = javaClass<RuntimeException >())]
237
233
public fun testForEachWithError () {
238
- Observable .create(AsyncObservable ())!! .toBlockingObservable ()!! .forEach { throw RuntimeException (" err" ) }
234
+ Observable .create(AsyncObservable ())!! .toBlocking ()!! .forEach { throw RuntimeException (" err" ) }
239
235
fail(" we expect an exception to be thrown" )
240
236
}
241
237
242
238
[Test ]
243
239
public fun testLastOrDefault () {
244
- assertEquals(" two" , Observable .from(listOf (" one" , " two" ))!! .toBlockingObservable ()!! .lastOrDefault(" default" ) { x -> x!! .length == 3 })
245
- assertEquals(" default" , Observable .from(listOf (" one" , " two" ))!! .toBlockingObservable ()!! .lastOrDefault(" default" ) { x -> x!! .length > 3 })
240
+ assertEquals(" two" , Observable .from(listOf (" one" , " two" ))!! .toBlocking ()!! .lastOrDefault(" default" ) { x -> x!! .length == 3 })
241
+ assertEquals(" default" , Observable .from(listOf (" one" , " two" ))!! .toBlocking ()!! .lastOrDefault(" default" ) { x -> x!! .length > 3 })
246
242
}
247
243
248
244
[Test (expected = javaClass<IllegalArgumentException >())]
249
245
public fun testSingle () {
250
- assertEquals(" one" , Observable .from(" one" )!! .toBlockingObservable ()!! .single { x -> x!! .length == 3 })
251
- Observable .from(listOf (" one" , " two" ))!! .toBlockingObservable ()!! .single { x -> x!! .length == 3 }
246
+ assertEquals(" one" , Observable .from(" one" )!! .toBlocking ()!! .single { x -> x!! .length == 3 })
247
+ Observable .from(listOf (" one" , " two" ))!! .toBlocking ()!! .single { x -> x!! .length == 3 }
252
248
fail()
253
249
}
254
250
@@ -271,7 +267,7 @@ public class BasicKotlinTests : KotlinTests() {
271
267
val o2 = Observable .from(listOf (4 , 5 , 6 ))!!
272
268
val o3 = Observable .from(listOf (7 , 8 , 9 ))!!
273
269
274
- val values = Observable .zip(o1, o2, o3) { a, b, c -> listOf (a, b, c) }!! .toList()!! .toBlockingObservable ()!! .single()!!
270
+ val values = Observable .zip(o1, o2, o3) { a, b, c -> listOf (a, b, c) }!! .toList()!! .toBlocking ()!! .single()!!
275
271
assertEquals(listOf (1 , 4 , 7 ), values[0 ])
276
272
assertEquals(listOf (2 , 5 , 8 ), values[1 ])
277
273
assertEquals(listOf (3 , 6 , 9 ), values[2 ])
@@ -283,7 +279,7 @@ public class BasicKotlinTests : KotlinTests() {
283
279
val o2 = Observable .from(listOf (4 , 5 , 6 ))!!
284
280
val o3 = Observable .from(listOf (7 , 8 , 9 ))!!
285
281
286
- val values = Observable .zip(listOf (o1, o2, o3)) { args -> listOf (* args) }!! .toList()!! .toBlockingObservable ()!! .single()!!
282
+ val values = Observable .zip(listOf (o1, o2, o3)) { args -> listOf (* args) }!! .toList()!! .toBlocking ()!! .single()!!
287
283
assertEquals(listOf (1 , 4 , 7 ), values[0 ])
288
284
assertEquals(listOf (2 , 5 , 8 ), values[1 ])
289
285
assertEquals(listOf (3 , 6 , 9 ), values[2 ])
@@ -296,10 +292,10 @@ public class BasicKotlinTests : KotlinTests() {
296
292
Observable .from(listOf (" one" , " two" , " three" , " four" , " five" , " six" ))!!
297
293
.groupBy { s -> s!! .length }!!
298
294
.flatMap { groupObervable ->
299
- groupObervable!! .map { s ->
300
- " Value: $s Group ${groupObervable.getKey()} "
301
- }
302
- }!! .toBlockingObservable ()!! .forEach { s ->
295
+ groupObervable!! .map { s ->
296
+ " Value: $s Group ${groupObervable.getKey()} "
297
+ }
298
+ }!! .toBlocking ()!! .forEach { s ->
303
299
println (s)
304
300
count++
305
301
}
@@ -343,7 +339,7 @@ public class BasicKotlinTests : KotlinTests() {
343
339
}
344
340
345
341
class TestOnSubscribe (val count : Int ) : OnSubscribe<String> {
346
- override fun call (op : Subscriber <in String >? ) {
342
+ override fun call (op : Subscriber <in String >? ) {
347
343
op!! .onNext(" hello_$count " )
348
344
op.onCompleted()
349
345
}
0 commit comments