@@ -112,15 +112,10 @@ void testCreateMessageWithoutSamplingCapabilities(String clientType) {
112112 return Mono .just (mock (CallToolResult .class ));
113113 });
114114
115- var server = McpServer .async (
116- mcpServerTransportProvider )
117- .serverInfo ("test-server" , "1.0.0" )
118- .tools (tool )
119- .build ();
120-
121- try (var client = clientBuilder
122- .clientInfo (new McpSchema .Implementation ("Sample " + "client" , "0.0.0" ))
123- .build ();) {
115+ var server = McpServer .async (mcpServerTransportProvider ).serverInfo ("test-server" , "1.0.0" ).tools (tool ).build ();
116+
117+ try (var client = clientBuilder .clientInfo (new McpSchema .Implementation ("Sample " + "client" , "0.0.0" ))
118+ .build ();) {
124119
125120 assertThat (client .initialize ()).isNotNull ();
126121
@@ -182,12 +177,11 @@ void testCreateMessageSuccess(String clientType) throws InterruptedException {
182177 .serverInfo ("test-server" , "1.0.0" )
183178 .tools (tool )
184179 .build ();
185-
186- try (
187- var mcpClient = clientBuilder .clientInfo (new McpSchema .Implementation ("Sample client" , "0.0.0" ))
188- .capabilities (ClientCapabilities .builder ().sampling ().build ())
189- .sampling (samplingHandler )
190- .build ()) {
180+
181+ try (var mcpClient = clientBuilder .clientInfo (new McpSchema .Implementation ("Sample client" , "0.0.0" ))
182+ .capabilities (ClientCapabilities .builder ().sampling ().build ())
183+ .sampling (samplingHandler )
184+ .build ()) {
191185
192186 InitializeResult initResult = mcpClient .initialize ();
193187 assertThat (initResult ).isNotNull ();
@@ -213,12 +207,12 @@ void testRootsSuccess(String clientType) {
213207 AtomicReference <List <Root >> rootsRef = new AtomicReference <>();
214208
215209 var mcpServer = McpServer .sync (mcpServerTransportProvider )
216- .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef .set (rootsUpdate ))
217- .build ();
210+ .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef .set (rootsUpdate ))
211+ .build ();
218212
219213 try (var mcpClient = clientBuilder .capabilities (ClientCapabilities .builder ().roots (true ).build ())
220- .roots (roots )
221- .build ()) {
214+ .roots (roots )
215+ .build ()) {
222216
223217 InitializeResult initResult = mcpClient .initialize ();
224218 assertThat (initResult ).isNotNull ();
@@ -264,16 +258,12 @@ void testRootsWithoutCapability(String clientType) {
264258 return mock (CallToolResult .class );
265259 });
266260
267- var mcpServer = McpServer .sync (mcpServerTransportProvider )
268- .rootsChangeHandler ((exchange , rootsUpdate ) -> {})
269- .tools (tool )
270- .build ();
261+ var mcpServer = McpServer .sync (mcpServerTransportProvider ).rootsChangeHandler ((exchange , rootsUpdate ) -> {
262+ }).tools (tool ).build ();
271263
272264 try (
273- // Create client without roots capability
274- var mcpClient = clientBuilder
275- .capabilities (ClientCapabilities .builder ().build ())
276- .build ()) {
265+ // Create client without roots capability
266+ var mcpClient = clientBuilder .capabilities (ClientCapabilities .builder ().build ()).build ()) {
277267
278268 assertThat (mcpClient .initialize ()).isNotNull ();
279269
@@ -297,12 +287,12 @@ void testRootsNotifciationWithEmptyRootsList(String clientType) {
297287 AtomicReference <List <Root >> rootsRef = new AtomicReference <>();
298288
299289 var mcpServer = McpServer .sync (mcpServerTransportProvider )
300- .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef .set (rootsUpdate ))
301- .build ();
290+ .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef .set (rootsUpdate ))
291+ .build ();
302292
303293 try (var mcpClient = clientBuilder .capabilities (ClientCapabilities .builder ().roots (true ).build ())
304- .roots (List .of ()) // Empty roots list
305- .build ()) {
294+ .roots (List .of ()) // Empty roots list
295+ .build ()) {
306296
307297 assertThat (mcpClient .initialize ()).isNotNull ();
308298
@@ -328,13 +318,13 @@ void testRootsWithMultipleHandlers(String clientType) {
328318 AtomicReference <List <Root >> rootsRef2 = new AtomicReference <>();
329319
330320 var mcpServer = McpServer .sync (mcpServerTransportProvider )
331- .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef1 .set (rootsUpdate ))
332- .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef2 .set (rootsUpdate ))
333- .build ();
321+ .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef1 .set (rootsUpdate ))
322+ .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef2 .set (rootsUpdate ))
323+ .build ();
334324
335325 try (var mcpClient = clientBuilder .capabilities (ClientCapabilities .builder ().roots (true ).build ())
336- .roots (roots )
337- .build ()) {
326+ .roots (roots )
327+ .build ()) {
338328
339329 InitializeResult initResult = mcpClient .initialize ();
340330 assertThat (initResult ).isNotNull ();
@@ -361,12 +351,12 @@ void testRootsServerCloseWithActiveSubscription(String clientType) {
361351 AtomicReference <List <Root >> rootsRef = new AtomicReference <>();
362352
363353 var mcpServer = McpServer .sync (mcpServerTransportProvider )
364- .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef .set (rootsUpdate ))
365- .build ();
354+ .rootsChangeHandler ((exchange , rootsUpdate ) -> rootsRef .set (rootsUpdate ))
355+ .build ();
366356
367357 try (var mcpClient = clientBuilder .capabilities (ClientCapabilities .builder ().roots (true ).build ())
368- .roots (roots )
369- .build ()) {
358+ .roots (roots )
359+ .build ()) {
370360
371361 InitializeResult initResult = mcpClient .initialize ();
372362 assertThat (initResult ).isNotNull ();
@@ -413,9 +403,9 @@ void testToolCallSuccess(String clientType) {
413403 });
414404
415405 var mcpServer = McpServer .sync (mcpServerTransportProvider )
416- .capabilities (ServerCapabilities .builder ().tools (true ).build ())
417- .tools (tool1 )
418- .build ();
406+ .capabilities (ServerCapabilities .builder ().tools (true ).build ())
407+ .tools (tool1 )
408+ .build ();
419409
420410 try (var mcpClient = clientBuilder .build ()) {
421411
@@ -455,21 +445,20 @@ void testToolListChangeHandlingSuccess(String clientType) {
455445 AtomicReference <List <Tool >> rootsRef = new AtomicReference <>();
456446
457447 var mcpServer = McpServer .sync (mcpServerTransportProvider )
458- .capabilities (ServerCapabilities .builder ().tools (true ).build ())
459- .tools (tool1 )
460- .build ();
448+ .capabilities (ServerCapabilities .builder ().tools (true ).build ())
449+ .tools (tool1 )
450+ .build ();
461451
462- try (
463- var mcpClient = clientBuilder .toolsChangeConsumer (toolsUpdate -> {
464- // perform a blocking call to a remote service
465- String response = RestClient .create ()
466- .get ()
467- .uri ("https://raw.githubusercontent.com/modelcontextprotocol/java-sdk/refs/heads/main/README.md" )
468- .retrieve ()
469- .body (String .class );
470- assertThat (response ).isNotBlank ();
471- rootsRef .set (toolsUpdate );
472- }).build ()) {
452+ try (var mcpClient = clientBuilder .toolsChangeConsumer (toolsUpdate -> {
453+ // perform a blocking call to a remote service
454+ String response = RestClient .create ()
455+ .get ()
456+ .uri ("https://raw.githubusercontent.com/modelcontextprotocol/java-sdk/refs/heads/main/README.md" )
457+ .retrieve ()
458+ .body (String .class );
459+ assertThat (response ).isNotBlank ();
460+ rootsRef .set (toolsUpdate );
461+ }).build ()) {
473462
474463 InitializeResult initResult = mcpClient .initialize ();
475464 assertThat (initResult ).isNotNull ();
@@ -583,10 +572,10 @@ void testLoggingNotification(String clientType) {
583572 .build ();
584573
585574 try (
586- // Create client with logging notification handler
587- var mcpClient = clientBuilder
588- . loggingConsumer ( notification -> { receivedNotifications .add (notification ); })
589- .build ()) {
575+ // Create client with logging notification handler
576+ var mcpClient = clientBuilder . loggingConsumer ( notification -> {
577+ receivedNotifications .add (notification );
578+ }) .build ()) {
590579
591580 // Initialize client
592581 InitializeResult initResult = mcpClient .initialize ();
0 commit comments