David Kubecka
02/01/2023, 11:50 AMAsyncTaskExecutor#submit
? Currently I'm doing this
val taskExecutor: AsyncTaskExecutor =
mockk {
every { submit(captureLambda()) } answers {
CompletableFuture.completedFuture(lambda<() -> Int>().invoke())
}
}
but getting
Caused by: java.lang.ClassCastException: class java.lang.Object cannot be cast to class kotlin.Function (java.lang.Object is in module java.base of loader 'bootstrap'; kotlin.Function is in unnamed module of loader 'app')
I should probably use hint
but not sure how exactly.David Kubecka
02/02/2023, 2:07 PMDavid Kubecka
02/02/2023, 3:09 PMcaptureLambda()
is intended only for Kotlin lambdas (which implement the Function
interface). For functional interfaces (Runnable
in my case) one must use the generic capture(slot)
technique.