|
|
@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.common.enums.Priority; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.graph.DAG; |
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNode; |
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNode; |
|
|
|
import org.apache.dolphinscheduler.common.process.ResourceInfo; |
|
|
|
import org.apache.dolphinscheduler.common.process.ResourceInfo; |
|
|
|
import org.apache.dolphinscheduler.common.task.shell.ShellParameters; |
|
|
|
import org.apache.dolphinscheduler.common.task.shell.ShellParameters; |
|
|
@ -48,6 +49,7 @@ import org.apache.dolphinscheduler.dao.entity.Schedule; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; |
|
|
@ -238,6 +240,8 @@ public class ProcessDefinitionServiceTest { |
|
|
|
@Mock |
|
|
|
@Mock |
|
|
|
private ProcessDefinitionMapper processDefineMapper; |
|
|
|
private ProcessDefinitionMapper processDefineMapper; |
|
|
|
@Mock |
|
|
|
@Mock |
|
|
|
|
|
|
|
private ProcessTaskRelationMapper processTaskRelationMapper; |
|
|
|
|
|
|
|
@Mock |
|
|
|
private ProjectMapper projectMapper; |
|
|
|
private ProjectMapper projectMapper; |
|
|
|
@Mock |
|
|
|
@Mock |
|
|
|
private ProjectServiceImpl projectService; |
|
|
|
private ProjectServiceImpl projectService; |
|
|
@ -342,6 +346,17 @@ public class ProcessDefinitionServiceTest { |
|
|
|
putMsg(result, Status.SUCCESS, projectName); |
|
|
|
putMsg(result, Status.SUCCESS, projectName); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
|
|
|
Mockito.when(processDefineMapper.selectById(1)).thenReturn(null); |
|
|
|
Mockito.when(processDefineMapper.selectById(1)).thenReturn(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String processDefinitionJson = "{\"globalParams\":[],\"tasks\":[{\"conditionResult\":" |
|
|
|
|
|
|
|
+ "{\"failedNode\":[\"\"],\"successNode\":[\"\"]},\"delayTime\":\"0\",\"dependence\":{}" |
|
|
|
|
|
|
|
+ ",\"description\":\"\",\"id\":\"tasks-3011\",\"maxRetryTimes\":\"0\",\"name\":\"tsssss\"" |
|
|
|
|
|
|
|
+ ",\"params\":{\"localParams\":[],\"rawScript\":\"echo \\\"123123\\\"\",\"resourceList\":[]}" |
|
|
|
|
|
|
|
+ ",\"preTasks\":[],\"retryInterval\":\"1\",\"runFlag\":\"NORMAL\",\"taskInstancePriority\":\"MEDIUM\"" |
|
|
|
|
|
|
|
+ ",\"timeout\":{\"enable\":false,\"interval\":null,\"strategy\":\"\"},\"type\":\"SHELL\"" |
|
|
|
|
|
|
|
+ ",\"waitStartTimeout\":{},\"workerGroup\":\"default\"}],\"tenantId\":4,\"timeout\":0}"; |
|
|
|
|
|
|
|
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); |
|
|
|
|
|
|
|
Mockito.when(processService.genProcessData(Mockito.any())).thenReturn(processData); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> instanceNotexitRes = processDefinitionService.queryProcessDefinitionById(loginUser, |
|
|
|
Map<String, Object> instanceNotexitRes = processDefinitionService.queryProcessDefinitionById(loginUser, |
|
|
|
"project_test1", 1); |
|
|
|
"project_test1", 1); |
|
|
|
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotexitRes.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotexitRes.get(Constants.STATUS)); |
|
|
@ -376,13 +391,23 @@ public class ProcessDefinitionServiceTest { |
|
|
|
//project check auth success, instance not exist
|
|
|
|
//project check auth success, instance not exist
|
|
|
|
putMsg(result, Status.SUCCESS, projectName); |
|
|
|
putMsg(result, Status.SUCCESS, projectName); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
|
|
|
Mockito.when(processDefineMapper.queryByDefineName(project.getId(),"test_def")).thenReturn(null); |
|
|
|
Mockito.when(processDefineMapper.queryByDefineName(project.getId(), "test_def")).thenReturn(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String processDefinitionJson = "{\"globalParams\":[],\"tasks\":[{\"conditionResult\":" |
|
|
|
|
|
|
|
+ "{\"failedNode\":[\"\"],\"successNode\":[\"\"]},\"delayTime\":\"0\",\"dependence\":{}" |
|
|
|
|
|
|
|
+ ",\"description\":\"\",\"id\":\"tasks-3011\",\"maxRetryTimes\":\"0\",\"name\":\"tsssss\"" |
|
|
|
|
|
|
|
+ ",\"params\":{\"localParams\":[],\"rawScript\":\"echo \\\"123123\\\"\",\"resourceList\":[]}" |
|
|
|
|
|
|
|
+ ",\"preTasks\":[],\"retryInterval\":\"1\",\"runFlag\":\"NORMAL\",\"taskInstancePriority\":\"MEDIUM\"" |
|
|
|
|
|
|
|
+ ",\"timeout\":{\"enable\":false,\"interval\":null,\"strategy\":\"\"},\"type\":\"SHELL\"" |
|
|
|
|
|
|
|
+ ",\"waitStartTimeout\":{},\"workerGroup\":\"default\"}],\"tenantId\":4,\"timeout\":0}"; |
|
|
|
|
|
|
|
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); |
|
|
|
|
|
|
|
Mockito.when(processService.genProcessData(Mockito.any())).thenReturn(processData); |
|
|
|
Map<String, Object> instanceNotexitRes = processDefinitionService.queryProcessDefinitionByName(loginUser, |
|
|
|
Map<String, Object> instanceNotexitRes = processDefinitionService.queryProcessDefinitionByName(loginUser, |
|
|
|
"project_test1", "test_def"); |
|
|
|
"project_test1", "test_def"); |
|
|
|
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotexitRes.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotexitRes.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
//instance exit
|
|
|
|
//instance exit
|
|
|
|
Mockito.when(processDefineMapper.queryByDefineName(project.getId(),"test")).thenReturn(getProcessDefinition()); |
|
|
|
Mockito.when(processDefineMapper.queryByDefineName(project.getId(), "test")).thenReturn(getProcessDefinition()); |
|
|
|
Map<String, Object> successRes = processDefinitionService.queryProcessDefinitionByName(loginUser, |
|
|
|
Map<String, Object> successRes = processDefinitionService.queryProcessDefinitionByName(loginUser, |
|
|
|
"project_test1", "test"); |
|
|
|
"project_test1", "test"); |
|
|
|
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); |
|
|
@ -393,6 +418,11 @@ public class ProcessDefinitionServiceTest { |
|
|
|
|
|
|
|
|
|
|
|
String projectName = "project_test1"; |
|
|
|
String projectName = "project_test1"; |
|
|
|
Project project = getProject(projectName); |
|
|
|
Project project = getProject(projectName); |
|
|
|
|
|
|
|
String processDefinitionJson = "{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\"," |
|
|
|
|
|
|
|
+ "\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234" |
|
|
|
|
|
|
|
+ "\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\"," |
|
|
|
|
|
|
|
+ "\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false}," |
|
|
|
|
|
|
|
+ "\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"; |
|
|
|
|
|
|
|
|
|
|
|
User loginUser = new User(); |
|
|
|
User loginUser = new User(); |
|
|
|
loginUser.setId(-1); |
|
|
|
loginUser.setId(-1); |
|
|
@ -435,15 +465,24 @@ public class ProcessDefinitionServiceTest { |
|
|
|
// instance exit
|
|
|
|
// instance exit
|
|
|
|
ProcessDefinition definition = getProcessDefinition(); |
|
|
|
ProcessDefinition definition = getProcessDefinition(); |
|
|
|
definition.setLocations("{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"); |
|
|
|
definition.setLocations("{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"); |
|
|
|
definition.setProcessDefinitionJson("{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\"," |
|
|
|
definition.setProcessDefinitionJson(processDefinitionJson); |
|
|
|
+ "\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234" |
|
|
|
|
|
|
|
+ "\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\"," |
|
|
|
|
|
|
|
+ "\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false}," |
|
|
|
|
|
|
|
+ "\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"); |
|
|
|
|
|
|
|
definition.setConnects("[]"); |
|
|
|
definition.setConnects("[]"); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(processDefineMapper.selectById(46)).thenReturn(definition); |
|
|
|
Mockito.when(processDefineMapper.selectById(46)).thenReturn(definition); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(processService.saveProcessDefinition(Mockito.eq(loginUser) |
|
|
|
|
|
|
|
, Mockito.eq(project2) |
|
|
|
|
|
|
|
, Mockito.anyString() |
|
|
|
|
|
|
|
, Mockito.anyString() |
|
|
|
|
|
|
|
, Mockito.anyString() |
|
|
|
|
|
|
|
, Mockito.anyString() |
|
|
|
|
|
|
|
, Mockito.any(ProcessData.class) |
|
|
|
|
|
|
|
, Mockito.any(ProcessDefinition.class))) |
|
|
|
|
|
|
|
.thenReturn(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); |
|
|
|
|
|
|
|
Mockito.when(processService.genProcessData(Mockito.any())).thenReturn(processData); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map3 = processDefinitionService.batchCopyProcessDefinition( |
|
|
|
Map<String, Object> map3 = processDefinitionService.batchCopyProcessDefinition( |
|
|
|
loginUser, projectName, "46", 1); |
|
|
|
loginUser, projectName, "46", 1); |
|
|
|
Assert.assertEquals(Status.SUCCESS, map3.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.SUCCESS, map3.get(Constants.STATUS)); |
|
|
@ -568,6 +607,7 @@ public class ProcessDefinitionServiceTest { |
|
|
|
schedules.add(schedule); |
|
|
|
schedules.add(schedule); |
|
|
|
Mockito.when(scheduleMapper.queryByProcessDefinitionId(46)).thenReturn(schedules); |
|
|
|
Mockito.when(scheduleMapper.queryByProcessDefinitionId(46)).thenReturn(schedules); |
|
|
|
Mockito.when(processDefineMapper.deleteById(46)).thenReturn(0); |
|
|
|
Mockito.when(processDefineMapper.deleteById(46)).thenReturn(0); |
|
|
|
|
|
|
|
Mockito.when(processTaskRelationMapper.deleteByCode(null, null)).thenReturn(0); |
|
|
|
Map<String, Object> deleteFail = processDefinitionService.deleteProcessDefinitionById(loginUser, |
|
|
|
Map<String, Object> deleteFail = processDefinitionService.deleteProcessDefinitionById(loginUser, |
|
|
|
"project_test1", 46); |
|
|
|
"project_test1", 46); |
|
|
|
Assert.assertEquals(Status.DELETE_PROCESS_DEFINE_BY_ID_ERROR, deleteFail.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.DELETE_PROCESS_DEFINE_BY_ID_ERROR, deleteFail.get(Constants.STATUS)); |
|
|
@ -708,6 +748,7 @@ public class ProcessDefinitionServiceTest { |
|
|
|
Assert.assertEquals(Status.DATA_IS_NOT_VALID, successRes.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.DATA_IS_NOT_VALID, successRes.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
//success
|
|
|
|
//success
|
|
|
|
|
|
|
|
Mockito.when(processService.genProcessData(Mockito.any())).thenReturn(new ProcessData()); |
|
|
|
processDefinition.setProcessDefinitionJson(SHELL_JSON); |
|
|
|
processDefinition.setProcessDefinitionJson(SHELL_JSON); |
|
|
|
Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition); |
|
|
|
Map<String, Object> dataNotValidRes = processDefinitionService.getTaskNodeListByDefinitionId(46); |
|
|
|
Map<String, Object> dataNotValidRes = processDefinitionService.getTaskNodeListByDefinitionId(46); |
|
|
@ -729,6 +770,16 @@ public class ProcessDefinitionServiceTest { |
|
|
|
List<ProcessDefinition> processDefinitionList = new ArrayList<>(); |
|
|
|
List<ProcessDefinition> processDefinitionList = new ArrayList<>(); |
|
|
|
processDefinitionList.add(processDefinition); |
|
|
|
processDefinitionList.add(processDefinition); |
|
|
|
Mockito.when(processDefineMapper.queryDefinitionListByIdList(idArray)).thenReturn(processDefinitionList); |
|
|
|
Mockito.when(processDefineMapper.queryDefinitionListByIdList(idArray)).thenReturn(processDefinitionList); |
|
|
|
|
|
|
|
String processDefinitionJson = "{\"globalParams\":[],\"tasks\":[{\"conditionResult\":" |
|
|
|
|
|
|
|
+ "{\"failedNode\":[\"\"],\"successNode\":[\"\"]},\"delayTime\":\"0\",\"dependence\":{}" |
|
|
|
|
|
|
|
+ ",\"description\":\"\",\"id\":\"tasks-3011\",\"maxRetryTimes\":\"0\",\"name\":\"tsssss\"" |
|
|
|
|
|
|
|
+ ",\"params\":{\"localParams\":[],\"rawScript\":\"echo \\\"123123\\\"\",\"resourceList\":[]}" |
|
|
|
|
|
|
|
+ ",\"preTasks\":[],\"retryInterval\":\"1\",\"runFlag\":\"NORMAL\",\"taskInstancePriority\":\"MEDIUM\"" |
|
|
|
|
|
|
|
+ ",\"timeout\":{\"enable\":false,\"interval\":null,\"strategy\":\"\"},\"type\":\"SHELL\"" |
|
|
|
|
|
|
|
+ ",\"waitStartTimeout\":{},\"workerGroup\":\"default\"}],\"tenantId\":4,\"timeout\":0}"; |
|
|
|
|
|
|
|
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); |
|
|
|
|
|
|
|
Mockito.when(processService.genProcessData(processDefinition)).thenReturn(processData); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> successRes = processDefinitionService.getTaskNodeListByDefinitionIdList(defineIdList); |
|
|
|
Map<String, Object> successRes = processDefinitionService.getTaskNodeListByDefinitionIdList(defineIdList); |
|
|
|
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); |
|
|
|
} |
|
|
|
} |
|
|
@ -776,12 +827,11 @@ public class ProcessDefinitionServiceTest { |
|
|
|
//task instance not exist
|
|
|
|
//task instance not exist
|
|
|
|
Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processInstanceService.queryByProcessDefineId(46, 10)).thenReturn(processInstanceList); |
|
|
|
Mockito.when(processInstanceService.queryByProcessDefineId(46, 10)).thenReturn(processInstanceList); |
|
|
|
Mockito.when(taskInstanceMapper.queryByInstanceIdAndName(processInstance.getId(), "shell-1")).thenReturn(null); |
|
|
|
Mockito.when(processService.genDagGraph(processDefinition)).thenReturn(new DAG<>()); |
|
|
|
Map<String, Object> taskNullRes = processDefinitionService.viewTree(46, 10); |
|
|
|
Map<String, Object> taskNullRes = processDefinitionService.viewTree(46, 10); |
|
|
|
Assert.assertEquals(Status.SUCCESS, taskNullRes.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.SUCCESS, taskNullRes.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
//task instance exist
|
|
|
|
//task instance exist
|
|
|
|
Mockito.when(taskInstanceMapper.queryByInstanceIdAndName(processInstance.getId(), "shell-1")).thenReturn(taskInstance); |
|
|
|
|
|
|
|
Map<String, Object> taskNotNuLLRes = processDefinitionService.viewTree(46, 10); |
|
|
|
Map<String, Object> taskNotNuLLRes = processDefinitionService.viewTree(46, 10); |
|
|
|
Assert.assertEquals(Status.SUCCESS, taskNotNuLLRes.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.SUCCESS, taskNotNuLLRes.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
@ -843,8 +893,8 @@ public class ProcessDefinitionServiceTest { |
|
|
|
+ "}"); |
|
|
|
+ "}"); |
|
|
|
//task instance exist
|
|
|
|
//task instance exist
|
|
|
|
Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processDefineMapper.selectById(46)).thenReturn(processDefinition); |
|
|
|
|
|
|
|
Mockito.when(processService.genDagGraph(processDefinition)).thenReturn(new DAG<>()); |
|
|
|
Mockito.when(processInstanceService.queryByProcessDefineId(46, 10)).thenReturn(processInstanceList); |
|
|
|
Mockito.when(processInstanceService.queryByProcessDefineId(46, 10)).thenReturn(processInstanceList); |
|
|
|
Mockito.when(taskInstanceMapper.queryByInstanceIdAndName(processInstance.getId(), "shell-1")).thenReturn(taskInstance); |
|
|
|
|
|
|
|
Map<String, Object> taskNotNuLLRes = processDefinitionService.viewTree(46, 10); |
|
|
|
Map<String, Object> taskNotNuLLRes = processDefinitionService.viewTree(46, 10); |
|
|
|
Assert.assertEquals(Status.SUCCESS, taskNotNuLLRes.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.SUCCESS, taskNotNuLLRes.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
@ -944,7 +994,6 @@ public class ProcessDefinitionServiceTest { |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(projectMapper.queryByName(currentProjectName)).thenReturn(getProject(currentProjectName)); |
|
|
|
Mockito.when(projectMapper.queryByName(currentProjectName)).thenReturn(getProject(currentProjectName)); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, getProject(currentProjectName), currentProjectName)).thenReturn(result); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, getProject(currentProjectName), currentProjectName)).thenReturn(result); |
|
|
|
Mockito.when(processDefineMapper.queryByDefineId(46)).thenReturn(shellDefinition2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> importProcessResult = processDefinitionService.importProcessDefinition(loginUser, multipartFile, currentProjectName); |
|
|
|
Map<String, Object> importProcessResult = processDefinitionService.importProcessDefinition(loginUser, multipartFile, currentProjectName); |
|
|
|
|
|
|
|
|
|
|
@ -972,7 +1021,6 @@ public class ProcessDefinitionServiceTest { |
|
|
|
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(getProject(projectName)); |
|
|
|
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(getProject(projectName)); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
|
|
|
Mockito.when(processService.findProcessDefineById(1)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processService.findProcessDefineById(1)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processDefinitionVersionService.addProcessDefinitionVersion(processDefinition)).thenReturn(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String sqlDependentJson = "{\n" |
|
|
|
String sqlDependentJson = "{\n" |
|
|
|
+ " \"globalParams\": [\n" |
|
|
|
+ " \"globalParams\": [\n" |
|
|
@ -1074,6 +1122,13 @@ public class ProcessDefinitionServiceTest { |
|
|
|
processDefinitionService.batchExportProcessDefinitionByIds( |
|
|
|
processDefinitionService.batchExportProcessDefinitionByIds( |
|
|
|
null, null, null, null); |
|
|
|
null, null, null, null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String processDefinitionJson = "{\"globalParams\":[],\"tasks\":[{\"conditionResult\":" |
|
|
|
|
|
|
|
+ "{\"failedNode\":[\"\"],\"successNode\":[\"\"]},\"delayTime\":\"0\",\"dependence\":{}" |
|
|
|
|
|
|
|
+ ",\"description\":\"\",\"id\":\"tasks-3011\",\"maxRetryTimes\":\"0\",\"name\":\"tsssss\"" |
|
|
|
|
|
|
|
+ ",\"params\":{\"localParams\":[],\"rawScript\":\"echo \\\"123123\\\"\",\"resourceList\":[]}" |
|
|
|
|
|
|
|
+ ",\"preTasks\":[],\"retryInterval\":\"1\",\"runFlag\":\"NORMAL\",\"taskInstancePriority\":\"MEDIUM\"" |
|
|
|
|
|
|
|
+ ",\"timeout\":{\"enable\":false,\"interval\":null,\"strategy\":\"\"},\"type\":\"SHELL\"" |
|
|
|
|
|
|
|
+ ",\"waitStartTimeout\":{},\"workerGroup\":\"default\"}],\"tenantId\":4,\"timeout\":0}"; |
|
|
|
User loginUser = new User(); |
|
|
|
User loginUser = new User(); |
|
|
|
loginUser.setId(1); |
|
|
|
loginUser.setId(1); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
@ -1091,13 +1146,7 @@ public class ProcessDefinitionServiceTest { |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(); |
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(); |
|
|
|
processDefinition.setId(1); |
|
|
|
processDefinition.setId(1); |
|
|
|
processDefinition.setProcessDefinitionJson("{\"globalParams\":[],\"tasks\":[{\"conditionResult\":" |
|
|
|
processDefinition.setProcessDefinitionJson(processDefinitionJson); |
|
|
|
+ "{\"failedNode\":[\"\"],\"successNode\":[\"\"]},\"delayTime\":\"0\",\"dependence\":{}" |
|
|
|
|
|
|
|
+ ",\"description\":\"\",\"id\":\"tasks-3011\",\"maxRetryTimes\":\"0\",\"name\":\"tsssss\"" |
|
|
|
|
|
|
|
+ ",\"params\":{\"localParams\":[],\"rawScript\":\"echo \\\"123123\\\"\",\"resourceList\":[]}" |
|
|
|
|
|
|
|
+ ",\"preTasks\":[],\"retryInterval\":\"1\",\"runFlag\":\"NORMAL\",\"taskInstancePriority\":\"MEDIUM\"" |
|
|
|
|
|
|
|
+ ",\"timeout\":{\"enable\":false,\"interval\":null,\"strategy\":\"\"},\"type\":\"SHELL\"" |
|
|
|
|
|
|
|
+ ",\"waitStartTimeout\":{},\"workerGroup\":\"default\"}],\"tenantId\":4,\"timeout\":0}"); |
|
|
|
|
|
|
|
Map<String, Object> checkResult = new HashMap<>(); |
|
|
|
Map<String, Object> checkResult = new HashMap<>(); |
|
|
|
checkResult.put(Constants.STATUS, Status.SUCCESS); |
|
|
|
checkResult.put(Constants.STATUS, Status.SUCCESS); |
|
|
|
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); |
|
|
|
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); |
|
|
@ -1105,6 +1154,9 @@ public class ProcessDefinitionServiceTest { |
|
|
|
Mockito.when(processDefineMapper.queryByDefineId(1)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processDefineMapper.queryByDefineId(1)).thenReturn(processDefinition); |
|
|
|
HttpServletResponse response = mock(HttpServletResponse.class); |
|
|
|
HttpServletResponse response = mock(HttpServletResponse.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); |
|
|
|
|
|
|
|
Mockito.when(processService.genProcessData(processDefinition)).thenReturn(processData); |
|
|
|
|
|
|
|
|
|
|
|
ServletOutputStream outputStream = mock(ServletOutputStream.class); |
|
|
|
ServletOutputStream outputStream = mock(ServletOutputStream.class); |
|
|
|
when(response.getOutputStream()).thenReturn(outputStream); |
|
|
|
when(response.getOutputStream()).thenReturn(outputStream); |
|
|
|
processDefinitionService.batchExportProcessDefinitionByIds( |
|
|
|
processDefinitionService.batchExportProcessDefinitionByIds( |
|
|
|