Skip to content

Commit 6ed499b

Browse files
committed
Merge pull request #23 from cbruegg/0.x
Migrate to Kotlin M13
2 parents ea85355 + 42352b5 commit 6ed499b

File tree

9 files changed

+61
-60
lines changed

9 files changed

+61
-60
lines changed

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
buildscript {
2+
ext.kotlin_version = '0.13.1513'
23
repositories { jcenter() }
34
dependencies { classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:2.+',
4-
'org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.+' }
5+
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
56
}
67

78
apply plugin: 'rxjava-project'
89
apply plugin: 'kotlin'
910

1011
dependencies {
1112
compile 'io.reactivex:rxjava:1.0.+'
12-
compile 'org.jetbrains.kotlin:kotlin-stdlib:0.12.+'
13-
compile 'org.funktionale:funktionale:0.5.1_M12'
13+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
14+
compile 'org.funktionale:funktionale:0.6_M13'
1415
testCompile 'junit:junit:4.12'
1516
testCompile 'org.mockito:mockito-core:1.8.5'
1617
examplesCompile 'com.squareup.retrofit:retrofit:1.9.+'

src/examples/kotlin/rx/lang/kotlin/examples/retrofit.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ data class SearchResults(val docs : List<SearchResultEntry>)
1111
data class MavenSearchResponse(val response : SearchResults)
1212

1313
interface MavenSearchService {
14-
GET("/solrsearch/select?wt=json")
15-
fun search(Query("q") s : String, Query("rows") rows : Int = 20) : Observable<MavenSearchResponse>
14+
@GET("/solrsearch/select?wt=json")
15+
fun search(@Query("q") s : String, @Query("rows") rows : Int = 20) : Observable<MavenSearchResponse>
1616
}
1717

1818
fun main(args: Array<String>) {
1919
val service = RestAdapter.Builder().
2020
setEndpoint("http://search.maven.org").
2121
build().
22-
create(javaClass<MavenSearchService>())
22+
create(MavenSearchService::class.java)
2323

2424
service.search("rxkotlin").
2525
flatMapIterable { it.response.docs }.

src/main/kotlin/rx/lang/kotlin/namespace.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,62 +19,62 @@ package rx.lang.kotlin
1919
import rx.Observable
2020
import rx.Subscriber
2121

22-
deprecated("use observable {} instead")
22+
@Deprecated("use observable {} instead")
2323
public fun<T> Function1<Subscriber<in T>, Unit>.asObservable(): Observable<T> {
2424
return Observable.create(this)
2525
}
2626

27-
deprecated("use deferredObservable {} instead")
27+
@Deprecated("use deferredObservable {} instead")
2828
public fun<T> Function0<Observable<T>>.defer(): Observable<T> {
2929
return Observable.defer(this)
3030
}
3131

32-
deprecated("use toObservable() instead")
32+
@Deprecated("use toObservable() instead")
3333
fun IntRange.asObservable(): Observable<Int> {
3434
return Observable.range(start, end)
3535
}
3636

37-
deprecated("use toObservable() instead")
37+
@Deprecated("use toObservable() instead")
3838
public fun<T> Iterable<T>.asObservable(): Observable<T> {
3939
return Observable.from(this)
4040
}
4141

42-
deprecated("use toSingletonObservable() instead")
42+
@Deprecated("use toSingletonObservable() instead")
4343
public fun<T> T.asObservable(): Observable<T> {
4444
return Observable.just(this)
4545
}
4646

47-
deprecated("use toObservable() instead")
47+
@Deprecated("use toObservable() instead")
4848
public fun<T> Throwable.asObservable(): Observable<T> {
4949
return Observable.error(this)
5050
}
5151

52-
deprecated("use listOf().toObservable() instead")
52+
@Deprecated("use listOf().toObservable() instead")
5353
public fun<T> Pair<T, T>.asObservable(): Observable<T> {
5454
return Observable.from(listOf(first, second))
5555
}
5656

57-
deprecated("use listOf().toObservable() instead")
57+
@Deprecated("use listOf().toObservable() instead")
5858
public fun<T> Triple<T, T, T>.asObservable(): Observable<T> {
5959
return Observable.from(listOf(first, second, third))
6060
}
6161

62-
deprecated("use first.mergeWith(second) or listOf(first, second).merge() instead")
62+
@Deprecated("use first.mergeWith(second) or listOf(first, second).merge() instead")
6363
public fun<T> Pair<Observable<T>, Observable<T>>.merge(): Observable<T> {
6464
return Observable.merge(first, second)
6565
}
6666

67-
deprecated("use listOf(first, second, third).merge() instead")
67+
@Deprecated("use listOf(first, second, third).merge() instead")
6868
public fun<T> Triple<Observable<T>, Observable<T>, Observable<T>>.merge(): Observable<T> {
6969
return Observable.merge(first, second, third)
7070
}
7171

72-
deprecated("use listOf(first, second).mergeDelayError() instead")
72+
@Deprecated("use listOf(first, second).mergeDelayError() instead")
7373
public fun<T> Pair<Observable<T>, Observable<T>>.mergeDelayError(): Observable<T> {
7474
return Observable.mergeDelayError(first, second)
7575
}
7676

77-
deprecated("use listOf(first, second, third).mergeDelayError() instead")
77+
@Deprecated("use listOf(first, second, third).mergeDelayError() instead")
7878
public fun<T> Triple<Observable<T>, Observable<T>, Observable<T>>.mergeDelayError(): Observable<T> {
7979
return Observable.mergeDelayError(first, second, third)
8080
}

src/main/kotlin/rx/lang/kotlin/observables.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public fun <T> Iterable<Observable<out T>>.mergeDelayError() : Observable<T> = O
4444

4545
public fun <T, R> Observable<T>.fold(initial : R, body : (R, T) -> R) : Observable<R> = reduce(initial, {a, e -> body(a, e)})
4646
public fun <T> Observable<T>.onError(block : (Throwable) -> Unit) : Observable<T> = doOnError(block)
47-
@suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
47+
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
4848
public fun <T> Observable<T>.firstOrNull() : Observable<T?> = firstOrDefault(null)
4949
public fun <T> BlockingObservable<T>.firstOrNull() : T = firstOrDefault(null)
5050

51-
@suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
52-
public fun <T> Observable<T>.onErrorReturnNull() : Observable<T?> = onErrorReturn {null}
51+
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
52+
public fun <T> Observable<T>.onErrorReturnNull() : Observable<T?> = onErrorReturn<T> {null}
5353

5454
public fun <T, R> Observable<T>.lift(operator : (Subscriber<in R>) -> Subscriber<T>) : Observable<R> = lift(object : Observable.Operator<R, T> {
5555
override fun call(t1: Subscriber<in R>?): Subscriber<in T> = operator(t1!!)

src/test/kotlin/rx/lang/kotlin/BasicKotlinTests.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public class BasicKotlinTests : KotlinTests() {
8383
@Test
8484
public fun testMaterialize() {
8585
Observable.from(listOf(1, 2, 3)).materialize().subscribe(received)
86-
verify(a, times(4)).received(any(javaClass<Notification<Int>>()))
87-
verify(a, times(0)).error(any(javaClass<Exception>()))
86+
verify(a, times(4)).received(any(Notification::class.java))
87+
verify(a, times(0)).error(any(Exception::class.java))
8888
}
8989

9090
@Test
@@ -105,13 +105,13 @@ public class BasicKotlinTests : KotlinTests() {
105105
verify(a, times(0)).received(5)
106106
verify(a, times(1)).received(6)
107107
verify(a, times(0)).received(7)
108-
verify(a, times(1)).error(any(javaClass<NullPointerException>()))
108+
verify(a, times(1)).error(any(NullPointerException::class.java))
109109
}
110110

111111
@Test
112112
public fun testScriptWithMaterialize() {
113113
TestFactory().observable.materialize().subscribe(received)
114-
verify(a, times(2)).received(any(javaClass<Notification<Int>>()))
114+
verify(a, times(2)).received(any(Notification::class.java))
115115
}
116116

117117
@Test
@@ -272,7 +272,7 @@ public class BasicKotlinTests : KotlinTests() {
272272
.groupBy { s -> s.length() }
273273
.flatMap { groupObervable ->
274274
groupObervable.map { s ->
275-
"Value: $s Group ${groupObervable.getKey()}"
275+
"Value: $s Group ${groupObervable.key}"
276276
}
277277
}.toBlocking().forEach { s ->
278278
println(s)

src/test/kotlin/rx/lang/kotlin/ExtensionTests.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public class ExtensionTests : KotlinTests() {
8181
@Test
8282
public fun testMaterialize() {
8383
listOf(1, 2, 3).toObservable().materialize().subscribe((received))
84-
verify(a, times(4)).received(any(javaClass<Notification<Int>>()))
85-
verify(a, times(0)).error(any(javaClass<Exception>()))
84+
verify(a, times(4)).received(any(Notification::class.java))
85+
verify(a, times(0)).error(any(Exception::class.java))
8686
}
8787

8888

@@ -102,13 +102,13 @@ public class ExtensionTests : KotlinTests() {
102102
verify(a, times(0)).received(5)
103103
verify(a, times(1)).received(6)
104104
verify(a, times(0)).received(7)
105-
verify(a, times(1)).error(any(javaClass<NullPointerException>()))
105+
verify(a, times(1)).error(any(NullPointerException::class.java))
106106
}
107107

108108
@Test
109109
public fun testScriptWithMaterialize() {
110110
TestFactory().observable.materialize().subscribe((received))
111-
verify(a, times(2)).received(any(javaClass<Notification<Int>>()))
111+
verify(a, times(2)).received(any(Notification::class.java))
112112
}
113113

114114
@Test

src/test/kotlin/rx/lang/kotlin/KotlinTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class KotlinTests {
3030
MockitoAnnotations.initMocks(this)
3131
}
3232

33-
suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
33+
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
3434
val <T> received = {result: T? -> a.received(result) }
3535

3636
public interface ScriptAssertion {

src/test/kotlin/rx/lang/kotlin/ObservablesTest.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import org.junit.Ignore
1010

1111

1212
public class ObservablesTest {
13-
test fun testCreation() {
13+
@test fun testCreation() {
1414
val o0 : Observable<Int> = emptyObservable()
1515
observable<Int> { s -> s.onNext(1); s.onNext(777); s.onCompleted() }.toList().forEach {
1616
assertEquals(listOf(1, 777), it)
@@ -30,7 +30,7 @@ public class ObservablesTest {
3030
assertNotNull(o5)
3131
}
3232

33-
test fun testExampleFromReadme() {
33+
@test fun testExampleFromReadme() {
3434
val result = observable<String> { subscriber ->
3535
subscriber.onNext("H")
3636
subscriber.onNext("e")
@@ -47,39 +47,39 @@ public class ObservablesTest {
4747
assertEquals("Hello", result)
4848
}
4949

50-
test fun iteratorObservable() {
50+
@test fun iteratorObservable() {
5151
assertEquals(listOf(1,2,3), listOf(1,2,3).iterator().toObservable().toList().toBlocking().single())
5252
}
5353

54-
test fun intProgressionStep1Empty() {
54+
@test fun intProgressionStep1Empty() {
5555
assertEquals(listOf(1), (1..1).toObservable().toList().toBlocking().first())
5656
}
57-
test fun intProgressionStep1() {
57+
@test fun intProgressionStep1() {
5858
assertEquals((1..10).toList(), (1..10).toObservable().toList().toBlocking().first())
5959
}
6060

61-
test fun intProgressionDownto() {
61+
@test fun intProgressionDownto() {
6262
assertEquals((1 downTo 10).toList(), (1 downTo 10).toObservable().toList().toBlocking().first())
6363
}
6464

65-
Ignore
66-
test fun intProgressionOverflow() {
65+
@Ignore
66+
@test fun intProgressionOverflow() {
6767
// too slow
68-
assertEquals((0..10).toList().reverse(), (-10 .. Integer.MAX_VALUE).toObservable().skip(Integer.MAX_VALUE).map{Integer.MAX_VALUE - it}.toList().toBlocking().first())
68+
assertEquals((0..10).toList().reversed(), (-10 .. Integer.MAX_VALUE).toObservable().skip(Integer.MAX_VALUE).map{Integer.MAX_VALUE - it}.toList().toBlocking().first())
6969
}
7070

71-
test fun filterNotNull() {
71+
@test fun filterNotNull() {
7272
val o : Observable<Int> = listOf(1, null).toObservable().filterNotNull()
7373
o.toList().forEach {
7474
assertEquals(listOf(1), it)
7575
}
7676
}
7777

78-
test fun requireNoNullsWithoutNulls() {
78+
@test fun requireNoNullsWithoutNulls() {
7979
(listOf(1,2) as List<Int?>).toObservable().requireNoNulls().subscribe()
8080
}
8181

82-
test fun requireNoNulls() {
82+
@test fun requireNoNulls() {
8383
try {
8484
val o : Observable<Int> = listOf(1, null).toObservable().requireNoNulls()
8585

@@ -89,7 +89,7 @@ public class ObservablesTest {
8989
}
9090
}
9191

92-
test fun testWithIndex() {
92+
@test fun testWithIndex() {
9393
listOf("a", "b", "c").toObservable().
9494
withIndex().
9595
toList().
@@ -98,29 +98,29 @@ public class ObservablesTest {
9898
}
9999
}
100100

101-
test fun testFold() {
101+
@test fun testFold() {
102102
listOf(1, 2, 3).toObservable().fold(0) {acc, e -> acc + e}.single().forEach {
103103
assertEquals(6, it)
104104
}
105105
}
106106

107-
test fun `kotlin sequence should produce expected items and observable be able to handle em`() {
107+
@test fun `kotlin sequence should produce expected items and observable be able to handle em`() {
108108
kotlin.sequence(0) {it + 1}.toObservable().take(3).toList().forEach {
109109
assertEquals(listOf(0, 1, 2), it)
110110
}
111111
}
112112

113-
test fun `infinite iterable should not hang or produce too many elements`() {
113+
@test fun `infinite iterable should not hang or produce too many elements`() {
114114
val generated = AtomicInteger()
115115
kotlin.sequence { generated.incrementAndGet() }.toObservable().
116116
take(100).
117117
toList().
118118
subscribe()
119119

120-
assertEquals(101, generated.get())
120+
assertEquals(100, generated.get())
121121
}
122122

123-
test fun testFlatMapSequence() {
123+
@test fun testFlatMapSequence() {
124124
assertEquals(
125125
listOf(1, 2, 3, 2, 3, 4, 3, 4, 5),
126126
listOf(1,2,3).toObservable().flatMapSequence { listOf(it, it + 1, it + 2).asSequence() }.toList().toBlocking().single()

0 commit comments

Comments
 (0)