99import static org .mockito .Mockito .verify ;
1010import static org .mockito .Mockito .when ;
1111
12+ import java .util .Collections ;
13+ import java .util .List ;
1214import java .util .concurrent .Executor ;
1315import java .util .concurrent .Flow ;
1416
1517import jakarta .enterprise .inject .Instance ;
1618
1719import io .a2a .server .ServerCallContext ;
20+ import io .a2a .spec .AgentCapabilities ;
21+ import io .a2a .spec .AgentCard ;
22+ import io .a2a .spec .AgentInterface ;
23+ import io .a2a .spec .AuthenticationInfo ;
1824import io .a2a .spec .CancelTaskRequest ;
1925import io .a2a .spec .CancelTaskResponse ;
2026import io .a2a .spec .DeleteTaskPushNotificationConfigRequest ;
2430import io .a2a .spec .GetTaskPushNotificationConfigRequest ;
2531import io .a2a .spec .GetTaskPushNotificationConfigResponse ;
2632import io .a2a .spec .GetTaskRequest ;
33+ import io .a2a .spec .PushNotificationConfig ;
2734import io .a2a .spec .GetTaskResponse ;
35+ import io .a2a .spec .ListTaskPushNotificationConfigParams ;
2836import io .a2a .spec .ListTaskPushNotificationConfigRequest ;
2937import io .a2a .spec .ListTaskPushNotificationConfigResponse ;
3038import io .a2a .spec .SendMessageRequest ;
3442import io .a2a .spec .SetTaskPushNotificationConfigRequest ;
3543import io .a2a .spec .SetTaskPushNotificationConfigResponse ;
3644import io .a2a .spec .SubscribeToTaskRequest ;
45+ import io .a2a .spec .Task ;
46+ import io .a2a .spec .TaskPushNotificationConfig ;
47+ import io .a2a .spec .TaskState ;
48+ import io .a2a .spec .TaskStatus ;
3749import io .a2a .transport .jsonrpc .handler .JSONRPCHandler ;
3850import io .vertx .core .MultiMap ;
3951import io .vertx .core .http .HttpServerRequest ;
@@ -120,9 +132,15 @@ public void testSendMessage_MethodNameSetInContext() {
120132 }""" ;
121133 when (mockRequestBody .asString ()).thenReturn (jsonRpcRequest );
122134
123- SendMessageResponse mockResponse = mock (SendMessageResponse .class );
135+ // Create a real response with a Task
136+ Task responseTask = new Task .Builder ()
137+ .id ("task-123" )
138+ .contextId ("context-1234" )
139+ .status (new TaskStatus (TaskState .SUBMITTED ))
140+ .build ();
141+ SendMessageResponse realResponse = new SendMessageResponse ("1" , responseTask );
124142 when (mockJsonRpcHandler .onMessageSend (any (SendMessageRequest .class ), any (ServerCallContext .class )))
125- .thenReturn (mockResponse );
143+ .thenReturn (realResponse );
126144
127145 ArgumentCaptor <ServerCallContext > contextCaptor = ArgumentCaptor .forClass (ServerCallContext .class );
128146
@@ -195,9 +213,15 @@ public void testGetTask_MethodNameSetInContext() {
195213 }""" ;
196214 when (mockRequestBody .asString ()).thenReturn (jsonRpcRequest );
197215
198- GetTaskResponse mockResponse = mock (GetTaskResponse .class );
216+ // Create a real response with a Task
217+ Task responseTask = new Task .Builder ()
218+ .id ("de38c76d-d54c-436c-8b9f-4c2703648d64" )
219+ .contextId ("context-1234" )
220+ .status (new TaskStatus (TaskState .SUBMITTED ))
221+ .build ();
222+ GetTaskResponse realResponse = new GetTaskResponse ("1" , responseTask );
199223 when (mockJsonRpcHandler .onGetTask (any (GetTaskRequest .class ), any (ServerCallContext .class )))
200- .thenReturn (mockResponse );
224+ .thenReturn (realResponse );
201225
202226 ArgumentCaptor <ServerCallContext > contextCaptor = ArgumentCaptor .forClass (ServerCallContext .class );
203227
@@ -224,9 +248,15 @@ public void testCancelTask_MethodNameSetInContext() {
224248 }""" ;
225249 when (mockRequestBody .asString ()).thenReturn (jsonRpcRequest );
226250
227- CancelTaskResponse mockResponse = mock (CancelTaskResponse .class );
251+ // Create a real response with a Task
252+ Task responseTask = new Task .Builder ()
253+ .id ("de38c76d-d54c-436c-8b9f-4c2703648d64" )
254+ .contextId ("context-1234" )
255+ .status (new TaskStatus (TaskState .CANCELED ))
256+ .build ();
257+ CancelTaskResponse realResponse = new CancelTaskResponse ("1" , responseTask );
228258 when (mockJsonRpcHandler .onCancelTask (any (CancelTaskRequest .class ), any (ServerCallContext .class )))
229- .thenReturn (mockResponse );
259+ .thenReturn (realResponse );
230260
231261 ArgumentCaptor <ServerCallContext > contextCaptor = ArgumentCaptor .forClass (ServerCallContext .class );
232262
@@ -294,9 +324,18 @@ public void testSetTaskPushNotificationConfig_MethodNameSetInContext() {
294324 }""" ;
295325 when (mockRequestBody .asString ()).thenReturn (jsonRpcRequest );
296326
297- SetTaskPushNotificationConfigResponse mockResponse = mock (SetTaskPushNotificationConfigResponse .class );
327+ // Create a real response with a TaskPushNotificationConfig
328+ TaskPushNotificationConfig responseConfig = new TaskPushNotificationConfig (
329+ "de38c76d-d54c-436c-8b9f-4c2703648d64" ,
330+ new PushNotificationConfig .Builder ()
331+ .id ("config-123" )
332+ .url ("https://example.com/callback" )
333+ .authenticationInfo (new AuthenticationInfo (Collections .singletonList ("jwt" ), null ))
334+ .build ()
335+ );
336+ SetTaskPushNotificationConfigResponse realResponse = new SetTaskPushNotificationConfigResponse ("1" , responseConfig );
298337 when (mockJsonRpcHandler .setPushNotificationConfig (any (SetTaskPushNotificationConfigRequest .class ),
299- any (ServerCallContext .class ))).thenReturn (mockResponse );
338+ any (ServerCallContext .class ))).thenReturn (realResponse );
300339
301340 ArgumentCaptor <ServerCallContext > contextCaptor = ArgumentCaptor .forClass (ServerCallContext .class );
302341
@@ -324,9 +363,17 @@ public void testGetTaskPushNotificationConfig_MethodNameSetInContext() {
324363 }""" ;
325364 when (mockRequestBody .asString ()).thenReturn (jsonRpcRequest );
326365
327- GetTaskPushNotificationConfigResponse mockResponse = mock (GetTaskPushNotificationConfigResponse .class );
366+ // Create a real response with a TaskPushNotificationConfig
367+ TaskPushNotificationConfig responseConfig = new TaskPushNotificationConfig (
368+ "de38c76d-d54c-436c-8b9f-4c2703648d64" ,
369+ new PushNotificationConfig .Builder ()
370+ .id ("config-456" )
371+ .url ("https://example.com/callback" )
372+ .build ()
373+ );
374+ GetTaskPushNotificationConfigResponse realResponse = new GetTaskPushNotificationConfigResponse ("1" , responseConfig );
328375 when (mockJsonRpcHandler .getPushNotificationConfig (any (GetTaskPushNotificationConfigRequest .class ),
329- any (ServerCallContext .class ))).thenReturn (mockResponse );
376+ any (ServerCallContext .class ))).thenReturn (realResponse );
330377
331378 ArgumentCaptor <ServerCallContext > contextCaptor = ArgumentCaptor .forClass (ServerCallContext .class );
332379
@@ -354,9 +401,17 @@ public void testListTaskPushNotificationConfig_MethodNameSetInContext() {
354401 }""" ;
355402 when (mockRequestBody .asString ()).thenReturn (jsonRpcRequest );
356403
357- ListTaskPushNotificationConfigResponse mockResponse = mock (ListTaskPushNotificationConfigResponse .class );
404+ // Create a real response with a list of TaskPushNotificationConfig
405+ TaskPushNotificationConfig config = new TaskPushNotificationConfig (
406+ "de38c76d-d54c-436c-8b9f-4c2703648d64" ,
407+ new PushNotificationConfig .Builder ()
408+ .id ("config-123" )
409+ .url ("https://example.com/callback" )
410+ .build ()
411+ );
412+ ListTaskPushNotificationConfigResponse realResponse = new ListTaskPushNotificationConfigResponse ("1" , Collections .singletonList (config ));
358413 when (mockJsonRpcHandler .listPushNotificationConfig (any (ListTaskPushNotificationConfigRequest .class ),
359- any (ServerCallContext .class ))).thenReturn (mockResponse );
414+ any (ServerCallContext .class ))).thenReturn (realResponse );
360415
361416 ArgumentCaptor <ServerCallContext > contextCaptor = ArgumentCaptor .forClass (ServerCallContext .class );
362417
@@ -384,9 +439,10 @@ public void testDeleteTaskPushNotificationConfig_MethodNameSetInContext() {
384439 }""" ;
385440 when (mockRequestBody .asString ()).thenReturn (jsonRpcRequest );
386441
387- DeleteTaskPushNotificationConfigResponse mockResponse = mock (DeleteTaskPushNotificationConfigResponse .class );
442+ // Create a real response with id
443+ DeleteTaskPushNotificationConfigResponse realResponse = new DeleteTaskPushNotificationConfigResponse ("1" );
388444 when (mockJsonRpcHandler .deletePushNotificationConfig (any (DeleteTaskPushNotificationConfigRequest .class ),
389- any (ServerCallContext .class ))).thenReturn (mockResponse );
445+ any (ServerCallContext .class ))).thenReturn (realResponse );
390446
391447 ArgumentCaptor <ServerCallContext > contextCaptor = ArgumentCaptor .forClass (ServerCallContext .class );
392448
@@ -408,10 +464,22 @@ public void testGetAuthenticatedExtendedCard_MethodNameSetInContext() {
408464 + "\" ,\" id\" :1}" ;
409465 when (mockRequestBody .asString ()).thenReturn (jsonRpcRequest );
410466
411- GetAuthenticatedExtendedCardResponse mockResponse = mock (GetAuthenticatedExtendedCardResponse .class );
467+ // Create a real response with an AgentCard
468+ AgentCard agentCard = new AgentCard .Builder ()
469+ .name ("Test Agent" )
470+ .description ("Test agent description" )
471+ .version ("1.0.0" )
472+ .protocolVersion ("0.4.0" )
473+ .capabilities (new AgentCapabilities .Builder ().build ())
474+ .defaultInputModes (Collections .singletonList ("text" ))
475+ .defaultOutputModes (Collections .singletonList ("text" ))
476+ .skills (Collections .emptyList ())
477+ .supportedInterfaces (Collections .singletonList (new AgentInterface ("jsonrpc" , "http://localhost:9999" )))
478+ .build ();
479+ GetAuthenticatedExtendedCardResponse realResponse = new GetAuthenticatedExtendedCardResponse (1 , agentCard );
412480 when (mockJsonRpcHandler .onGetAuthenticatedExtendedCardRequest (
413481 any (GetAuthenticatedExtendedCardRequest .class ), any (ServerCallContext .class )))
414- .thenReturn (mockResponse );
482+ .thenReturn (realResponse );
415483
416484 ArgumentCaptor <ServerCallContext > contextCaptor = ArgumentCaptor .forClass (ServerCallContext .class );
417485
0 commit comments