Skip to content

Commit 8fe3cba

Browse files
committed
Add JSON deserialization test
1 parent dafca2e commit 8fe3cba

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mcp/src/test/java/io/modelcontextprotocol/spec/McpSchemaTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,24 @@ void testJSONRPCRequest() throws Exception {
185185
{"jsonrpc":"2.0","method":"method_name","id":1,"params":{"key":"value"}}"""));
186186
}
187187

188+
@Test
189+
void testJSONRPCRequestWithMeta() throws Exception {
190+
Map<String, Object> params = new HashMap<>();
191+
params.put("key", "value");
192+
params.put("_meta", Map.of("progressToken", "abc123"));
193+
194+
McpSchema.JSONRPCRequest request = new McpSchema.JSONRPCRequest(McpSchema.JSONRPC_VERSION, "method_name", 1,
195+
params);
196+
197+
String value = mapper.writeValueAsString(request);
198+
assertThatJson(value).when(Option.IGNORING_ARRAY_ORDER)
199+
.when(Option.IGNORING_EXTRA_ARRAY_ITEMS)
200+
.isObject()
201+
.isEqualTo(
202+
json("""
203+
{"jsonrpc":"2.0","method":"method_name","id":1,"params":{"key":"value"},"_meta":{"progressToken":"abc123"}}"""));
204+
}
205+
188206
@Test
189207
void testJSONRPCNotification() throws Exception {
190208
Map<String, Object> params = new HashMap<>();

0 commit comments

Comments
 (0)