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.captureLambda()
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.