|
|
@ -25,9 +25,12 @@ import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.enums.CommandType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.CommandType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNode; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.task.conditions.ConditionsParameters; |
|
|
|
import org.apache.dolphinscheduler.common.utils.DateUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.DateUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Command; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Command; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessData; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap; |
|
|
@ -335,4 +338,108 @@ public class ProcessServiceTest { |
|
|
|
processService.recurseFindSubProcessId(parentId, ids); |
|
|
|
processService.recurseFindSubProcessId(parentId, ids); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testChangeJson() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessData oldProcessData = new ProcessData(); |
|
|
|
|
|
|
|
ConditionsParameters conditionsParameters = new ConditionsParameters(); |
|
|
|
|
|
|
|
ArrayList<TaskNode> tasks = new ArrayList<>(); |
|
|
|
|
|
|
|
TaskNode taskNode = new TaskNode(); |
|
|
|
|
|
|
|
TaskNode taskNode11 = new TaskNode(); |
|
|
|
|
|
|
|
TaskNode taskNode111 = new TaskNode(); |
|
|
|
|
|
|
|
ArrayList<String> successNode = new ArrayList<>(); |
|
|
|
|
|
|
|
ArrayList<String> faildNode = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode.setName("bbb"); |
|
|
|
|
|
|
|
taskNode.setType("SHELL"); |
|
|
|
|
|
|
|
taskNode.setId("222"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode11.setName("vvv"); |
|
|
|
|
|
|
|
taskNode11.setType("CONDITIONS"); |
|
|
|
|
|
|
|
taskNode11.setId("444"); |
|
|
|
|
|
|
|
successNode.add("bbb"); |
|
|
|
|
|
|
|
faildNode.add("ccc"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode111.setName("ccc"); |
|
|
|
|
|
|
|
taskNode111.setType("SHELL"); |
|
|
|
|
|
|
|
taskNode111.setId("333"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conditionsParameters.setSuccessNode(successNode); |
|
|
|
|
|
|
|
conditionsParameters.setFailedNode(faildNode); |
|
|
|
|
|
|
|
taskNode11.setConditionResult(conditionsParameters.getConditionResult()); |
|
|
|
|
|
|
|
tasks.add(taskNode); |
|
|
|
|
|
|
|
tasks.add(taskNode11); |
|
|
|
|
|
|
|
tasks.add(taskNode111); |
|
|
|
|
|
|
|
oldProcessData.setTasks(tasks); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessData newProcessData = new ProcessData(); |
|
|
|
|
|
|
|
ConditionsParameters conditionsParameters2 = new ConditionsParameters(); |
|
|
|
|
|
|
|
TaskNode taskNode2 = new TaskNode(); |
|
|
|
|
|
|
|
TaskNode taskNode22 = new TaskNode(); |
|
|
|
|
|
|
|
TaskNode taskNode222 = new TaskNode(); |
|
|
|
|
|
|
|
ArrayList<TaskNode> tasks2 = new ArrayList<>(); |
|
|
|
|
|
|
|
ArrayList<String> successNode2 = new ArrayList<>(); |
|
|
|
|
|
|
|
ArrayList<String> faildNode2 = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode2.setName("bbbchange"); |
|
|
|
|
|
|
|
taskNode2.setType("SHELL"); |
|
|
|
|
|
|
|
taskNode2.setId("222"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode22.setName("vv"); |
|
|
|
|
|
|
|
taskNode22.setType("CONDITIONS"); |
|
|
|
|
|
|
|
taskNode22.setId("444"); |
|
|
|
|
|
|
|
successNode2.add("bbb"); |
|
|
|
|
|
|
|
faildNode2.add("ccc"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode222.setName("ccc"); |
|
|
|
|
|
|
|
taskNode222.setType("SHELL"); |
|
|
|
|
|
|
|
taskNode222.setId("333"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conditionsParameters2.setSuccessNode(successNode2); |
|
|
|
|
|
|
|
conditionsParameters2.setFailedNode(faildNode2); |
|
|
|
|
|
|
|
taskNode22.setConditionResult(conditionsParameters2.getConditionResult()); |
|
|
|
|
|
|
|
tasks2.add(taskNode2); |
|
|
|
|
|
|
|
tasks2.add(taskNode22); |
|
|
|
|
|
|
|
tasks2.add(taskNode222); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newProcessData.setTasks(tasks2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessData exceptProcessData = new ProcessData(); |
|
|
|
|
|
|
|
ConditionsParameters conditionsParameters3 = new ConditionsParameters(); |
|
|
|
|
|
|
|
TaskNode taskNode3 = new TaskNode(); |
|
|
|
|
|
|
|
TaskNode taskNode33 = new TaskNode(); |
|
|
|
|
|
|
|
TaskNode taskNode333 = new TaskNode(); |
|
|
|
|
|
|
|
ArrayList<TaskNode> tasks3 = new ArrayList<>(); |
|
|
|
|
|
|
|
ArrayList<String> successNode3 = new ArrayList<>(); |
|
|
|
|
|
|
|
ArrayList<String> faildNode3 = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode3.setName("bbbchange"); |
|
|
|
|
|
|
|
taskNode3.setType("SHELL"); |
|
|
|
|
|
|
|
taskNode3.setId("222"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode33.setName("vv"); |
|
|
|
|
|
|
|
taskNode33.setType("CONDITIONS"); |
|
|
|
|
|
|
|
taskNode33.setId("444"); |
|
|
|
|
|
|
|
successNode3.add("bbbchange"); |
|
|
|
|
|
|
|
faildNode3.add("ccc"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
taskNode333.setName("ccc"); |
|
|
|
|
|
|
|
taskNode333.setType("SHELL"); |
|
|
|
|
|
|
|
taskNode333.setId("333"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conditionsParameters3.setSuccessNode(successNode3); |
|
|
|
|
|
|
|
conditionsParameters3.setFailedNode(faildNode3); |
|
|
|
|
|
|
|
taskNode33.setConditionResult(conditionsParameters3.getConditionResult()); |
|
|
|
|
|
|
|
tasks3.add(taskNode3); |
|
|
|
|
|
|
|
tasks3.add(taskNode33); |
|
|
|
|
|
|
|
tasks3.add(taskNode333); |
|
|
|
|
|
|
|
exceptProcessData.setTasks(tasks3); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String expect = JSONUtils.toJsonString(exceptProcessData); |
|
|
|
|
|
|
|
String oldJson = JSONUtils.toJsonString(oldProcessData); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(expect, processService.changeJson(newProcessData,oldJson)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|