Copilot commented on code in PR #17726:
URL: 
https://github.com/apache/dolphinscheduler/pull/17726#discussion_r2562517483


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-sagemaker/src/test/java/org/apache/dolphinscheduler/plugin/task/sagemaker/SagemakerTaskTest.java:
##########
@@ -139,4 +145,33 @@ private String buildParameters() {
 
         return JSONUtils.toJsonString(parameters);
     }
+
+    @Test
+    public void testTrackApplicationStatus_InitPipelineIdThrowsException() 
throws Exception {
+        doThrow(new TaskException("sagemaker applicationID is 
null")).when(sagemakerTask).initPipelineId();
+
+        TaskException exception = assertThrows(TaskException.class, () -> {
+            sagemakerTask.trackApplicationStatus();
+        });
+
+        assertEquals("sagemaker applicationID is null", 
exception.getMessage());

Review Comment:
   The expected exception message doesn't match the actual implementation. The 
`trackApplicationStatus()` method wraps the exception with the message 
"SageMaker task track application error: " + original message. The assertion 
should expect "SageMaker task track application error: sagemaker applicationID 
is null" instead of just "sagemaker applicationID is null".
   ```suggestion
           assertEquals("SageMaker task track application error: sagemaker 
applicationID is null", exception.getMessage());
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-sagemaker/src/test/java/org/apache/dolphinscheduler/plugin/task/sagemaker/SagemakerTaskTest.java:
##########
@@ -139,4 +145,33 @@ private String buildParameters() {
 
         return JSONUtils.toJsonString(parameters);
     }
+
+    @Test
+    public void testTrackApplicationStatus_InitPipelineIdThrowsException() 
throws Exception {
+        doThrow(new TaskException("sagemaker applicationID is 
null")).when(sagemakerTask).initPipelineId();
+
+        TaskException exception = assertThrows(TaskException.class, () -> {
+            sagemakerTask.trackApplicationStatus();
+        });
+
+        assertEquals("sagemaker applicationID is null", 
exception.getMessage());
+        verify(client, times(1)).shutdown();
+    }
+
+    @Test
+    public void testCancelApplication_InitPipelineIdThrowsException() {
+        // Mock the behavior of initPipelineId to throw an exception
+        doThrow(new TaskException("sagemaker applicationID is 
null")).when(sagemakerTask).initPipelineId();
+
+        // Call the method under test and expect an exception
+        TaskException exception = assertThrows(TaskException.class, () -> {
+            sagemakerTask.cancelApplication();
+        });
+
+        // Verify the exception message
+        assertEquals("cancel application error", exception.getMessage());

Review Comment:
   The expected exception message doesn't match the actual implementation. The 
`cancelApplication()` method wraps the exception with the message "SageMaker 
task cancel application error: " + original message. The assertion should 
expect "SageMaker task cancel application error: sagemaker applicationID is 
null" instead of "cancel application error".
   ```suggestion
           assertEquals("SageMaker task cancel application error: sagemaker 
applicationID is null", exception.getMessage());
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to