com.oneeyedmen.kSera.InvokeAction.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of k-sera Show documentation
Show all versions of k-sera Show documentation
A Kotlin Wrapper for JMock
The newest version!
package com.oneeyedmen.kSera
import org.jmock.api.Invocation
import org.jmock.lib.action.CustomAction
class InvokeAction(private val description: String, private val block: (Invocation) -> R)
: TypedAction by UntypedInvokeAction(description, block).asTyped()
class UntypedInvokeAction(description: String, private val lambda: (Invocation) -> R) : CustomAction(description) {
override fun invoke(invocation: Invocation): R? {
val result = lambda(invocation)
return if (result == Unit) null else result // Java reflection doesn't understand Unit
}
}