You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/10/10 13:02:13 UTC
[GitHub] [dolphinscheduler] github-code-scanning[bot] commented on a diff in pull request #12299: [Improvement][Test] Migrate all UT cases from jUnit4 to jUnit5 in task-plugin module as an example
github-code-scanning[bot] commented on code in PR #12299:
URL: https://github.com/apache/dolphinscheduler/pull/12299#discussion_r991263786
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-sagemaker/src/test/java/org/apache/dolphinscheduler/plugin/task/sagemaker/SagemakerTaskTest.java:
##########
@@ -60,35 +60,37 @@
sagemakerTask.init();
StartPipelineExecutionResult startPipelineExecutionResult = Mockito.mock(StartPipelineExecutionResult.class);
- Mockito.when(startPipelineExecutionResult.getPipelineExecutionArn()).thenReturn(pipelineExecutionArn);
+ Mockito.lenient().when(startPipelineExecutionResult.getPipelineExecutionArn()).thenReturn(pipelineExecutionArn);
StopPipelineExecutionResult stopPipelineExecutionResult = Mockito.mock(StopPipelineExecutionResult.class);
- Mockito.when(stopPipelineExecutionResult.getPipelineExecutionArn()).thenReturn(pipelineExecutionArn);
+ Mockito.lenient().when(stopPipelineExecutionResult.getPipelineExecutionArn()).thenReturn(pipelineExecutionArn);
- DescribePipelineExecutionResult describePipelineExecutionResult = Mockito.mock(DescribePipelineExecutionResult.class);
- Mockito.when(describePipelineExecutionResult.getPipelineExecutionStatus()).thenReturn("Executing", "Succeeded");
+ DescribePipelineExecutionResult describePipelineExecutionResult =
+ Mockito.mock(DescribePipelineExecutionResult.class);
+ Mockito.lenient().when(describePipelineExecutionResult.getPipelineExecutionStatus()).thenReturn("Executing",
+ "Succeeded");
- Mockito.when(client.startPipelineExecution(any())).thenReturn(startPipelineExecutionResult);
- Mockito.when(client.stopPipelineExecution(any())).thenReturn(stopPipelineExecutionResult);
- Mockito.when(client.describePipelineExecution(any())).thenReturn(describePipelineExecutionResult);
+ Mockito.lenient().when(client.startPipelineExecution(any())).thenReturn(startPipelineExecutionResult);
+ Mockito.lenient().when(client.stopPipelineExecution(any())).thenReturn(stopPipelineExecutionResult);
+ Mockito.lenient().when(client.describePipelineExecution(any())).thenReturn(describePipelineExecutionResult);
}
@Test
public void testStartPipelineRequest() throws Exception {
StartPipelineExecutionRequest request = sagemakerTask.createStartPipelineRequest();
- Assert.assertEquals("AbalonePipeline", request.getPipelineName());
- Assert.assertEquals("test Pipeline", request.getPipelineExecutionDescription());
- Assert.assertEquals("AbalonePipeline", request.getPipelineExecutionDisplayName());
- Assert.assertEquals("AbalonePipeline", request.getPipelineName());
- Assert.assertEquals(new Integer(1), request.getParallelismConfiguration().getMaxParallelExecutionSteps());
+ Assertions.assertEquals("AbalonePipeline", request.getPipelineName());
+ Assertions.assertEquals("test Pipeline", request.getPipelineExecutionDescription());
+ Assertions.assertEquals("AbalonePipeline", request.getPipelineExecutionDisplayName());
+ Assertions.assertEquals("AbalonePipeline", request.getPipelineName());
+ Assertions.assertEquals(new Integer(1), request.getParallelismConfiguration().getMaxParallelExecutionSteps());
Review Comment:
## Deprecated method or constructor invocation
Invoking [Integer.Integer](1) should be avoided because it has been deprecated.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/1689)
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-sagemaker/src/test/java/org/apache/dolphinscheduler/plugin/task/sagemaker/SagemakerTaskTest.java:
##########
@@ -60,35 +60,37 @@
sagemakerTask.init();
StartPipelineExecutionResult startPipelineExecutionResult = Mockito.mock(StartPipelineExecutionResult.class);
- Mockito.when(startPipelineExecutionResult.getPipelineExecutionArn()).thenReturn(pipelineExecutionArn);
+ Mockito.lenient().when(startPipelineExecutionResult.getPipelineExecutionArn()).thenReturn(pipelineExecutionArn);
StopPipelineExecutionResult stopPipelineExecutionResult = Mockito.mock(StopPipelineExecutionResult.class);
- Mockito.when(stopPipelineExecutionResult.getPipelineExecutionArn()).thenReturn(pipelineExecutionArn);
+ Mockito.lenient().when(stopPipelineExecutionResult.getPipelineExecutionArn()).thenReturn(pipelineExecutionArn);
- DescribePipelineExecutionResult describePipelineExecutionResult = Mockito.mock(DescribePipelineExecutionResult.class);
- Mockito.when(describePipelineExecutionResult.getPipelineExecutionStatus()).thenReturn("Executing", "Succeeded");
+ DescribePipelineExecutionResult describePipelineExecutionResult =
+ Mockito.mock(DescribePipelineExecutionResult.class);
+ Mockito.lenient().when(describePipelineExecutionResult.getPipelineExecutionStatus()).thenReturn("Executing",
+ "Succeeded");
- Mockito.when(client.startPipelineExecution(any())).thenReturn(startPipelineExecutionResult);
- Mockito.when(client.stopPipelineExecution(any())).thenReturn(stopPipelineExecutionResult);
- Mockito.when(client.describePipelineExecution(any())).thenReturn(describePipelineExecutionResult);
+ Mockito.lenient().when(client.startPipelineExecution(any())).thenReturn(startPipelineExecutionResult);
+ Mockito.lenient().when(client.stopPipelineExecution(any())).thenReturn(stopPipelineExecutionResult);
+ Mockito.lenient().when(client.describePipelineExecution(any())).thenReturn(describePipelineExecutionResult);
}
@Test
public void testStartPipelineRequest() throws Exception {
StartPipelineExecutionRequest request = sagemakerTask.createStartPipelineRequest();
- Assert.assertEquals("AbalonePipeline", request.getPipelineName());
- Assert.assertEquals("test Pipeline", request.getPipelineExecutionDescription());
- Assert.assertEquals("AbalonePipeline", request.getPipelineExecutionDisplayName());
- Assert.assertEquals("AbalonePipeline", request.getPipelineName());
- Assert.assertEquals(new Integer(1), request.getParallelismConfiguration().getMaxParallelExecutionSteps());
+ Assertions.assertEquals("AbalonePipeline", request.getPipelineName());
+ Assertions.assertEquals("test Pipeline", request.getPipelineExecutionDescription());
+ Assertions.assertEquals("AbalonePipeline", request.getPipelineExecutionDisplayName());
+ Assertions.assertEquals("AbalonePipeline", request.getPipelineName());
+ Assertions.assertEquals(new Integer(1), request.getParallelismConfiguration().getMaxParallelExecutionSteps());
Review Comment:
## Inefficient primitive constructor
Inefficient constructor for int value, use Integer.valueOf(...) instead.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/1690)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org