@@ -153,13 +153,10 @@ private void testGetTask(String mediaType) throws Exception {
153153 public void testGetTaskNotFound () throws Exception {
154154 assertTrue (getTaskFromTaskStore ("non-existent-task" ) == null );
155155 try {
156- GetTaskResponse response = client .getTask ("1" , new TaskQueryParams ("non-existent-task" ));
157- assertEquals ("1" , response .getId ());
158- assertInstanceOf (JSONRPCError .class , response .getError ());
159- assertEquals (new TaskNotFoundError ().getCode (), response .getError ().getCode ());
160- assertNull (response .getResult ());
156+ client .getTask ("1" , new TaskQueryParams ("non-existent-task" ));
157+ fail ("Expected A2AServerException to be thrown" );
161158 } catch (A2AServerException e ) {
162- fail ( "Unexpected exception during getTask for non-existent task: " + e . getMessage (), e );
159+ assertInstanceOf ( TaskNotFoundError . class , e . getCause () );
163160 }
164161 }
165162
@@ -184,13 +181,10 @@ public void testCancelTaskSuccess() throws Exception {
184181 public void testCancelTaskNotSupported () throws Exception {
185182 saveTaskInTaskStore (CANCEL_TASK_NOT_SUPPORTED );
186183 try {
187- CancelTaskResponse response = client .cancelTask ("1" , new TaskIdParams (CANCEL_TASK_NOT_SUPPORTED .getId ()));
188- assertNull (response .getResult ());
189- assertEquals ("1" , response .getId ());
190- assertInstanceOf (JSONRPCError .class , response .getError ());
191- assertEquals (new UnsupportedOperationError ().getCode (), response .getError ().getCode ());
184+ client .cancelTask ("1" , new TaskIdParams (CANCEL_TASK_NOT_SUPPORTED .getId ()));
185+ fail ("Expected A2AServerException to be thrown" );
192186 } catch (A2AServerException e ) {
193- fail ( "Unexpected exception during cancel task not supported test: " + e . getMessage (), e );
187+ assertInstanceOf ( UnsupportedOperationError . class , e . getCause () );
194188 } finally {
195189 deleteTaskInTaskStore (CANCEL_TASK_NOT_SUPPORTED .getId ());
196190 }
@@ -199,13 +193,10 @@ public void testCancelTaskNotSupported() throws Exception {
199193 @ Test
200194 public void testCancelTaskNotFound () {
201195 try {
202- CancelTaskResponse response = client .cancelTask ("1" , new TaskIdParams ("non-existent-task" ));
203- assertEquals ("1" , response .getId ());
204- assertNull (response .getResult ());
205- assertInstanceOf (JSONRPCError .class , response .getError ());
206- assertEquals (new TaskNotFoundError ().getCode (), response .getError ().getCode ());
196+ client .cancelTask ("1" , new TaskIdParams ("non-existent-task" ));
197+ fail ("Expected A2AServerException to be thrown" );
207198 } catch (A2AServerException e ) {
208- fail ( "Unexpected exception during cancel task not found test: " + e . getMessage (), e );
199+ assertInstanceOf ( TaskNotFoundError . class , e . getCause () );
209200 }
210201 }
211202
@@ -315,15 +306,12 @@ public void testError() {
315306 .contextId (SEND_MESSAGE_NOT_SUPPORTED .getContextId ())
316307 .build ();
317308 MessageSendParams messageSendParams = new MessageSendParams (message , null , null );
318-
309+
319310 try {
320- SendMessageResponse response = client .sendMessage ("1" , messageSendParams );
321- assertEquals ("1" , response .getId ());
322- assertNull (response .getResult ());
323- assertInstanceOf (JSONRPCError .class , response .getError ());
324- assertEquals (new UnsupportedOperationError ().getCode (), response .getError ().getCode ());
311+ client .sendMessage ("1" , messageSendParams );
312+ fail ("Expected A2AServerException to be thrown" );
325313 } catch (A2AServerException e ) {
326- fail ( "Unexpected exception during error handling test: " + e . getMessage (), e );
314+ assertInstanceOf ( UnsupportedOperationError . class , e . getCause () );
327315 }
328316 }
329317
0 commit comments