-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathKotlinExamples.kt
More file actions
39 lines (28 loc) · 1.08 KB
/
KotlinExamples.kt
File metadata and controls
39 lines (28 loc) · 1.08 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
package org.dataloader
import org.junit.jupiter.api.Test
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 -> CompletableFuture.completedFuture(keys.toList()) }
val cfA = dataLoader.load("A")
val cfB = dataLoader.load("B")
dataLoader.dispatch()
cfA.join().equals("A")
cfB.join().equals("B")
}
@Test
fun `basic kotlin test of nullable value types`() {
val dataLoader: DataLoader<String, String?> = DataLoaderFactory.newDataLoader { keys -> CompletableFuture.completedFuture(keys.toList()) }
val cfA = dataLoader.load("A")
val cfB = dataLoader.load("B")
dataLoader.dispatch()
cfA.join().equals("A")
cfB.join().equals("B")
}
}