github-code-scanning[bot] commented on code in PR #11682:
URL: https://github.com/apache/dolphinscheduler/pull/11682#discussion_r979406248
##########
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java:
##########
@@ -504,6 +505,76 @@
Assertions.assertDoesNotThrow(() ->
processDefinitionService.deleteProcessDefinitionByCode(user, 46L));
}
+ @Test
+ public void batchDeleteProcessDefinitionByCodeTest() {
+
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode));
+
+ Project project = getProject(projectCode);
+
+ // process check exists
+ final String twoCodes = "11,12";
+ Set<Long> definitionCodes =
Lists.newArrayList(twoCodes.split(Constants.COMMA)).stream()
+ .map(Long::parseLong).collect(Collectors.toSet());
Review Comment:
## Missing catch of NumberFormatException
Potential uncaught 'java.lang.NumberFormatException'.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/1540)
##########
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java:
##########
@@ -504,6 +505,76 @@
Assertions.assertDoesNotThrow(() ->
processDefinitionService.deleteProcessDefinitionByCode(user, 46L));
}
+ @Test
+ public void batchDeleteProcessDefinitionByCodeTest() {
+
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode));
+
+ Project project = getProject(projectCode);
+
+ // process check exists
+ final String twoCodes = "11,12";
+ Set<Long> definitionCodes =
Lists.newArrayList(twoCodes.split(Constants.COMMA)).stream()
+ .map(Long::parseLong).collect(Collectors.toSet());
+ ProcessDefinition process = getProcessDefinition();
+ List<ProcessDefinition> processDefinitionList = new ArrayList<>();
+ processDefinitionList.add(process);
+
Mockito.when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList);
+ Throwable exception = Assertions.assertThrows(ServiceException.class,
+ () ->
processDefinitionService.batchDeleteProcessDefinitionByCodes(user, projectCode,
twoCodes));
+ String formatter =
MessageFormat.format(Status.BATCH_DELETE_PROCESS_DEFINE_BY_CODES_ERROR.getMsg(),
+ "12[process definition not exist]");
+ Assertions.assertEquals(formatter, exception.getMessage());
+
+ // project check auth fail
+ Map<String, Object> result = new HashMap<>();
+ final String singleCodes = "11";
+ putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
+ definitionCodes =
Lists.newArrayList(singleCodes.split(Constants.COMMA)).stream().map(Long::parseLong)
Review Comment:
## Missing catch of NumberFormatException
Potential uncaught 'java.lang.NumberFormatException'.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/1541)
--
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]