
io.mockk.impl.stub.StubRepository.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
package io.mockk.impl.stub
import io.mockk.MockKException
import io.mockk.impl.InternalPlatform
import io.mockk.impl.log.SafeLog
class StubRepository(val safeLog: SafeLog) {
val stubs = InternalPlatform.weakMap()
fun stubFor(mock: Any): Stub = stubs[mock]
?: throw MockKException(safeLog.exec { "can't find stub $mock" })
fun add(mock: Any, stub: Stub) {
stubs.put(mock, stub)
}
fun remove(mock: Any) {
stubs.remove(mock)
}
operator fun get(mock: Any): Stub? = stubs.get(mock)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy