io.mockk.impl.recording.CallRoundBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockk-common Show documentation
Show all versions of mockk-common Show documentation
Common(JS and Java) MockK module
The newest version!
package io.mockk.impl.recording
import io.mockk.Invocation
import io.mockk.Matcher
import io.mockk.impl.log.SafeToString
import kotlin.reflect.KClass
class CallRoundBuilder(val safeToString: SafeToString) {
val signedMatchers = mutableListOf()
val signedCalls = mutableListOf()
fun addMatcher(matcher: Matcher<*>, sigValue: Any) {
signedMatchers.add(SignedMatcher(matcher, sigValue))
}
fun addSignedCall(
retValue: Any?,
tempMock: Boolean,
retType: KClass<*>,
invocation: Invocation
) {
val signedCall = SignedCall(
retValue,
tempMock,
retType,
invocation.self,
invocation.method,
invocation.args,
safeToString.exec { invocation.toString() }
)
signedCalls.add(signedCall)
}
fun addWasNotCalled(list: List) {
for (self in list) {
signedCalls.add(
SignedCall(
Unit,
false,
Unit::class,
self,
WasNotCalled.method,
listOf(),
safeToString.exec { "${self} wasNot Called" }
)
)
}
}
fun build() = CallRound(signedCalls.toList(), signedMatchers.toList())
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy