@@ -18,13 +18,10 @@ 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
26
import rx.Subscriber
30
27
@@ -213,15 +210,15 @@ public class ExtensionTests : KotlinTests() {
213
210
214
211
[Test ]
215
212
public fun testForEach () {
216
- asyncObservable.asObservableFunc ().toBlockingObservable()!! .forEach(received())
213
+ asyncObservable.asObservable ().toBlockingObservable()!! .forEach(received())
217
214
verify(a, times(1 ))!! .received(1 )
218
215
verify(a, times(1 ))!! .received(2 )
219
216
verify(a, times(1 ))!! .received(3 )
220
217
}
221
218
222
219
[Test (expected = javaClass<RuntimeException >())]
223
220
public fun testForEachWithError () {
224
- asyncObservable.asObservableFunc ().toBlockingObservable()!! .forEach { throw RuntimeException (" err" ) }
221
+ asyncObservable.asObservable ().toBlockingObservable()!! .forEach { throw RuntimeException (" err" ) }
225
222
fail(" we expect an exception to be thrown" )
226
223
}
227
224
@@ -256,21 +253,19 @@ public class ExtensionTests : KotlinTests() {
256
253
assertEquals(listOf (3 , 6 , 9 ), values[2 ])
257
254
}
258
255
259
- val funOnSubscribe: (Int , Observer <in String >) -> Subscription = { counter, observer ->
260
- observer.onNext(" hello_$counter " )
261
- observer.onCompleted()
262
- Subscriptions .empty()!!
256
+ val funOnSubscribe: (Int , Subscriber <in String >) -> Unit = { counter, subscriber ->
257
+ subscriber.onNext(" hello_$counter " )
258
+ subscriber.onCompleted()
263
259
}
264
260
265
- val asyncObservable: (Observer <in Int >) -> Subscription = { observer ->
261
+ val asyncObservable: (Subscriber <in Int >) -> Unit = { subscriber ->
266
262
thread {
267
263
Thread .sleep(50 )
268
- observer .onNext(1 )
269
- observer .onNext(2 )
270
- observer .onNext(3 )
271
- observer .onCompleted()
264
+ subscriber .onNext(1 )
265
+ subscriber .onNext(2 )
266
+ subscriber .onNext(3 )
267
+ subscriber .onCompleted()
272
268
}
273
- Subscriptions .empty()!!
274
269
}
275
270
276
271
/* *
@@ -288,14 +283,14 @@ public class ExtensionTests : KotlinTests() {
288
283
return listOf (1 , 3 , 2 , 5 , 4 ).asObservable()
289
284
}
290
285
291
- val onSubscribe: (Observer <in String >) -> Subscription
286
+ val onSubscribe: (Subscriber <in String >) -> Unit
292
287
get(){
293
288
return funOnSubscribe.partially1(counter++ )
294
289
}
295
290
296
291
val observable: Observable <String >
297
292
get(){
298
- return onSubscribe.asObservableFunc ()
293
+ return onSubscribe.asObservable ()
299
294
}
300
295
301
296
}
0 commit comments