5353import org .junit .jupiter .params .provider .MethodSource ;
5454import org .junit .jupiter .params .provider .ValueSource ;
5555import reactor .core .publisher .Mono ;
56- import reactor .test .StepVerifier ;
5756
5857import static io .modelcontextprotocol .util .ToolsUtils .EMPTY_JSON_SCHEMA ;
5958import static net .javacrumbs .jsonunit .assertj .JsonAssertions .assertThatJson ;
@@ -404,6 +403,8 @@ void testCreateElicitationSuccess(String clientType) {
404403 .addContent (new McpSchema .TextContent ("CALL RESPONSE" ))
405404 .build ();
406405
406+ AtomicReference <McpSchema .ElicitResult > elicitResultRef = new AtomicReference <>();
407+
407408 McpServerFeatures .AsyncToolSpecification tool = McpServerFeatures .AsyncToolSpecification .builder ()
408409 .tool (Tool .builder ().name ("tool1" ).description ("tool1 description" ).inputSchema (EMPTY_JSON_SCHEMA ).build ())
409410 .callHandler ((exchange , request ) -> {
@@ -414,13 +415,9 @@ void testCreateElicitationSuccess(String clientType) {
414415 Map .of ("type" , "object" , "properties" , Map .of ("message" , Map .of ("type" , "string" ))))
415416 .build ();
416417
417- StepVerifier .create (exchange .createElicitation (elicitationRequest )).consumeNextWith (result -> {
418- assertThat (result ).isNotNull ();
419- assertThat (result .action ()).isEqualTo (McpSchema .ElicitResult .Action .ACCEPT );
420- assertThat (result .content ().get ("message" )).isEqualTo ("Test message" );
421- }).verifyComplete ();
422-
423- return Mono .just (callResponse );
418+ return exchange .createElicitation (elicitationRequest )
419+ .doOnNext (elicitResultRef ::set )
420+ .thenReturn (callResponse );
424421 })
425422 .build ();
426423
@@ -438,6 +435,11 @@ void testCreateElicitationSuccess(String clientType) {
438435
439436 assertThat (response ).isNotNull ();
440437 assertThat (response ).isEqualTo (callResponse );
438+ assertWith (elicitResultRef .get (), result -> {
439+ assertThat (result ).isNotNull ();
440+ assertThat (result .action ()).isEqualTo (McpSchema .ElicitResult .Action .ACCEPT );
441+ assertThat (result .content ().get ("message" )).isEqualTo ("Test message" );
442+ });
441443 }
442444 finally {
443445 mcpServer .closeGracefully ().block ();
0 commit comments