From eb94f1413254208aa2a96e37b2de93d10a775826 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 16:41:14 +0200 Subject: [PATCH] chore(deps): bump dev.mokksy:mokksy from 0.6.2 to 0.8.0 (#557) Bumps [dev.mokksy:mokksy](https://github.com/mokksy/ai-mocks) from 0.6.2 to 0.8.0. - Update dependency and migrate to new API --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- .../AbstractStreamableHttpClientTest.kt | 9 +++++- .../kotlin/sdk/client/MockMcp.kt | 30 ++++++++++++++----- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ccb649d..f86685d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ kotlinx-io = "0.8.2" ktor = "3.2.3" logging = "7.0.14" mockk = "1.14.9" -mokksy = "0.6.2" +mokksy = "0.8.0" serialization = "1.9.0" slf4j = "2.0.17" junit = "5.14.2" diff --git a/kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/AbstractStreamableHttpClientTest.kt b/kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/AbstractStreamableHttpClientTest.kt index 77ba553..4a04e81 100644 --- a/kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/AbstractStreamableHttpClientTest.kt +++ b/kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/AbstractStreamableHttpClientTest.kt @@ -5,6 +5,7 @@ import io.ktor.client.engine.apache5.Apache5 import io.ktor.client.plugins.logging.LogLevel import io.ktor.client.plugins.logging.Logging import io.ktor.client.plugins.sse.SSE +import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.TestInstance @@ -16,7 +17,13 @@ internal abstract class AbstractStreamableHttpClientTest { @AfterEach fun afterEach() { - mockMcp.checkForUnmatchedRequests() + mockMcp.verifyNoUnexpectedRequests() + } + + @AfterAll + fun afterAll() { + mockMcp.verifyNoUnmatchedStubs() + mockMcp.close() } protected suspend fun connect(client: Client) { diff --git a/kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/MockMcp.kt b/kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/MockMcp.kt index ff39973..fb71904 100644 --- a/kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/MockMcp.kt +++ b/kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/MockMcp.kt @@ -3,6 +3,8 @@ package io.modelcontextprotocol.kotlin.sdk.client import dev.mokksy.mokksy.BuildingStep import dev.mokksy.mokksy.Mokksy import dev.mokksy.mokksy.StubConfiguration +import dev.mokksy.mokksy.shutdown +import dev.mokksy.mokksy.start import io.ktor.http.ContentType import io.ktor.http.HttpMethod import io.ktor.http.HttpStatusCode @@ -21,16 +23,23 @@ import kotlinx.serialization.json.putJsonObject const val MCP_SESSION_ID_HEADER = "MCP-Session-Id" -internal class MockMcp(verbose: Boolean = false) { +internal class MockMcp(verbose: Boolean = false) : AutoCloseable { - private val mokksy: Mokksy = Mokksy(verbose = verbose) + private val mokksy: Mokksy = Mokksy(verbose = verbose).apply { + start() + } - fun checkForUnmatchedRequests() { - mokksy.checkForUnmatchedRequests() + fun verifyNoUnexpectedRequests() { + mokksy.verifyNoUnexpectedRequests() + } + + fun verifyNoUnmatchedStubs() { + mokksy.verifyNoUnmatchedStubs() } val url = "${mokksy.baseUrl()}/mcp" + @Suppress("LongParameterList") fun onInitialize( clientName: String? = null, sessionId: String, @@ -108,6 +117,7 @@ internal class MockMcp(verbose: Boolean = false) { } } + @Suppress("LongParameterList") fun handleWithResult( httpMethod: HttpMethod = HttpMethod.Post, jsonRpcMethod: String, @@ -124,9 +134,9 @@ internal class MockMcp(verbose: Boolean = false) { expectedSessionId = expectedSessionId, bodyPredicates = bodyPredicates, ) respondsWith { - val requestId = when (request.body.id) { - is RequestId.NumberId -> (request.body.id as RequestId.NumberId).value.toString() - is RequestId.StringId -> "\"${(request.body.id as RequestId.StringId).value}\"" + val requestId = when (val id = request.body().id) { + is RequestId.NumberId -> id.value.toString() + is RequestId.StringId -> "\"${id.value}\"" } val resultObject = result.invoke() // language=json @@ -143,6 +153,7 @@ internal class MockMcp(verbose: Boolean = false) { } } + @Suppress("LongParameterList") fun handleWithResult( httpMethod: HttpMethod = HttpMethod.Post, jsonRpcMethod: String, @@ -167,6 +178,7 @@ internal class MockMcp(verbose: Boolean = false) { ) } + @Suppress("LongParameterList") fun handleJSONRPCRequest( httpMethod: HttpMethod = HttpMethod.Post, jsonRpcMethod: String, @@ -222,4 +234,8 @@ internal class MockMcp(verbose: Boolean = false) { body = null } } + + override fun close() { + mokksy.shutdown() + } }