-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathKotlinExamples.kt
More file actions
40 lines (29 loc) · 1.13 KB
/
KotlinExamples.kt
File metadata and controls
40 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.dataloader
import org.junit.jupiter.api.Test
import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletableFuture.*
/**
* Some Kotlin code to prove that are JSpecify annotations work here
* as expected in Kotlin land. We don't intend to ue Kotlin in our tests
* or to deliver Kotlin code in the java
*/
class KotlinExamples {
@Test
fun `basic kotlin test of non nullable value types`() {
val dataLoader: DataLoader<String, String> = DataLoaderFactory.newDataLoader { keys -> completedFuture(keys.toList()) }
val cfA = dataLoader.load("A")
val cfB = dataLoader.load("B")
dataLoader.dispatch()
assert(cfA.join().equals("A"))
assert(cfA.join().equals("A"))
}
@Test
fun `basic kotlin test of nullable value types`() {
val dataLoader: DataLoader<String, String?> = DataLoaderFactory.newDataLoader { keys -> completedFuture(keys.toList()) }
val cfA = dataLoader.load("A")
val cfB = dataLoader.load("B")
dataLoader.dispatch()
assert(cfA.join().equals("A"))
assert(cfA.join().equals("A"))
}
}