Skip to content

Commit

Permalink
TE-584: Handle task from sub process
Browse files Browse the repository at this point in the history
  • Loading branch information
trungmaihova committed May 24, 2024
1 parent a4ccbea commit 641c1d5
Show file tree
Hide file tree
Showing 10 changed files with 509 additions and 10 deletions.
107 changes: 106 additions & 1 deletion process-analyzer-test/processes/FlowSubprocess.p.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"findTasksOnPath( start.ivp ) => TaskA, TaskB"
],
"visual" : {
"at" : { "x" : 376, "y" : 343 },
"at" : { "x" : 824, "y" : 167 },
"size" : { "width" : 476, "height" : 97 }
}
}, {
Expand Down Expand Up @@ -198,5 +198,110 @@
"visual" : {
"at" : { "x" : 488, "y" : 192 }
}
}, {
"id" : "f10",
"type" : "RequestStart",
"name" : "start3",
"config" : {
"signature" : "start3"
},
"visual" : {
"at" : { "x" : 96, "y" : 312 }
},
"connect" : [
{ "id" : "f11", "to" : "S30" }
]
}, {
"id" : "S30",
"type" : "EmbeddedProcess",
"name" : "Sub Process A",
"elements" : [ {
"id" : "S30-g0",
"type" : "EmbeddedStart",
"visual" : {
"at" : { "x" : 64, "y" : 256 }
},
"parentConnector" : "f11",
"connect" : [
{ "id" : "S30-f0", "to" : "S30-f1" }
]
}, {
"id" : "S30-g1",
"type" : "EmbeddedEnd",
"visual" : {
"at" : { "x" : 496, "y" : 256 }
},
"parentConnector" : "f13"
}, {
"id" : "S30-f1",
"type" : "SubProcessCall",
"name" : "CallSubProcess A",
"config" : {
"processCall" : "FlowSubProcessCall:call()",
"call" : {
"map" : { },
"code" : [
"import com.axonivy.utils.process.analyzer.test.UseCase;",
"import java.util.concurrent.TimeUnit;",
"import com.axonivy.utils.process.analyzer.APAConfig;",
"",
"APAConfig.handleAsTask();",
"APAConfig.setTaskName(\"CallSubProcess A\");",
"APAConfig.setEstimate(10,TimeUnit.DAYS,UseCase.BIGPROJECT);",
"APAConfig.setEstimate(5,TimeUnit.DAYS,UseCase.SMALLPROJECT);"
]
}
},
"visual" : {
"at" : { "x" : 208, "y" : 256 }
},
"connect" : [
{ "id" : "S30-f2", "to" : "S30-f3" }
]
}, {
"id" : "S30-f3",
"type" : "UserTask",
"name" : "TaskC",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskC"
}
},
"visual" : {
"at" : { "x" : 368, "y" : 256 }
},
"connect" : [
{ "id" : "S30-f4", "to" : "S30-g1" }
]
} ],
"visual" : {
"at" : { "x" : 288, "y" : 312 }
},
"connect" : [
{ "id" : "f13", "to" : "f12" }
]
}, {
"id" : "f12",
"type" : "UserTask",
"name" : "TaskB",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskB"
}
},
"visual" : {
"at" : { "x" : 480, "y" : 312 }
},
"connect" : [
{ "id" : "f15", "to" : "f14" }
]
}, {
"id" : "f14",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 672, "y" : 312 }
}
} ]
}
206 changes: 206 additions & 0 deletions process-analyzer-test/processes/ParallelTasksExample.p.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,212 @@
"connect" : [
{ "id" : "f24", "to" : "f4", "var" : "in2" }
]
}, {
"id" : "f34",
"type" : "RequestStart",
"name" : "start5",
"config" : {
"signature" : "start5"
},
"visual" : {
"at" : { "x" : 56, "y" : 744 }
},
"connect" : [
{ "id" : "f93", "to" : "f91" }
]
}, {
"id" : "f91",
"type" : "UserTask",
"name" : "TaskA5",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskA5"
}
},
"visual" : {
"at" : { "x" : 216, "y" : 744 }
},
"connect" : [
{ "id" : "f98", "to" : "f94", "var" : "in1" }
]
}, {
"id" : "f94",
"type" : "TaskSwitchGateway",
"config" : {
"tasks" : [ {
"id" : "TaskA",
"responsible" : {
"activator" : "SYSTEM"
}
}, {
"id" : "TaskB",
"responsible" : {
"activator" : "SYSTEM"
}
}, {
"id" : "TaskC",
"responsible" : {
"activator" : "SYSTEM"
}
} ]
},
"visual" : {
"at" : { "x" : 352, "y" : 744 }
},
"connect" : [
{ "id" : "f25", "to" : "f102", "via" : [ { "x" : 352, "y" : 624 } ], "condition" : "ivp==\"TaskA.ivp\"" },
{ "id" : "f26", "to" : "f103", "via" : [ { "x" : 352, "y" : 864 } ], "condition" : "ivp==\"TaskB.ivp\"" },
{ "id" : "f27", "to" : "f100", "condition" : "ivp==\"TaskC.ivp\"" }
]
}, {
"id" : "f100",
"type" : "UserTask",
"name" : "TaskC5",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskC5"
}
},
"visual" : {
"at" : { "x" : 448, "y" : 744 }
},
"connect" : [
{ "id" : "f107", "to" : "f106", "var" : "in1" }
]
}, {
"id" : "f102",
"type" : "UserTask",
"name" : "TaskB5",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskB5"
}
},
"visual" : {
"at" : { "x" : 560, "y" : 624 }
},
"connect" : [
{ "id" : "f111", "to" : "f110" }
]
}, {
"id" : "f103",
"type" : "UserTask",
"name" : "TaskD5",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskD5"
}
},
"visual" : {
"at" : { "x" : 560, "y" : 864 }
},
"connect" : [
{ "id" : "f116", "to" : "f114", "via" : [ { "x" : 840, "y" : 864 } ], "var" : "in2" }
]
}, {
"id" : "f110",
"type" : "UserTask",
"name" : "TaskE5",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskE5"
}
},
"visual" : {
"at" : { "x" : 712, "y" : 624 }
},
"connect" : [
{ "id" : "f117", "to" : "f114", "via" : [ { "x" : 840, "y" : 624 } ], "var" : "in3" }
]
}, {
"id" : "f112",
"type" : "UserTask",
"name" : "TaskF5",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskF5"
}
},
"visual" : {
"at" : { "x" : 712, "y" : 744 }
},
"connect" : [
{ "id" : "f115", "to" : "f114", "var" : "in1" }
]
}, {
"id" : "f114",
"type" : "TaskSwitchGateway",
"config" : {
"tasks" : [ {
"id" : "TaskA",
"responsible" : {
"activator" : "SYSTEM"
}
} ]
},
"visual" : {
"at" : { "x" : 840, "y" : 744 }
},
"connect" : [
{ "id" : "f119", "to" : "f118", "condition" : "ivp==\"TaskA.ivp\"" }
]
}, {
"id" : "f118",
"type" : "UserTask",
"name" : "TaskG5",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskG5"
}
},
"visual" : {
"at" : { "x" : 968, "y" : 744 }
},
"connect" : [
{ "id" : "f121", "to" : "f120" }
]
}, {
"id" : "f120",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 1128, "y" : 744 }
}
}, {
"id" : "f106",
"type" : "TaskSwitchGateway",
"config" : {
"tasks" : [ {
"id" : "TaskA",
"responsible" : {
"activator" : "SYSTEM"
}
}, {
"id" : "TaskB",
"responsible" : {
"activator" : "SYSTEM"
}
}, {
"id" : "TaskC",
"responsible" : {
"activator" : "SYSTEM"
}
} ]
},
"visual" : {
"at" : { "x" : 560, "y" : 744 }
},
"connect" : [
{ "id" : "f108", "to" : "f102", "condition" : "ivp==\"TaskA.ivp\"" },
{ "id" : "f109", "to" : "f103", "condition" : "ivp==\"TaskB.ivp\"" },
{ "id" : "f113", "to" : "f112", "condition" : "ivp==\"TaskC.ivp\"" }
]
} ],
"layout" : {
"colors" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.axonivy.utils.process.analyzer.test;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import java.util.List;

import org.assertj.core.util.Arrays;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.axonivy.utils.process.analyzer.internal.ProcessAnalyzer;

import ch.ivyteam.ivy.bpm.engine.client.BpmClient;
import ch.ivyteam.ivy.bpm.engine.client.ExecutionResult;
import ch.ivyteam.ivy.bpm.engine.client.element.BpmProcess;
import ch.ivyteam.ivy.bpm.exec.client.IvyProcessTest;
import ch.ivyteam.ivy.workflow.ICase;
import ch.ivyteam.ivy.workflow.ITask;

@IvyProcessTest
public class FlowSubProcessCaseTest extends FlowExampleTest {
private static final BpmProcess FLOW_SUB_PROCESS = BpmProcess.name("FlowSubprocess");

@BeforeEach
public void setupForEach() {
processAnalyzer = new ProcessAnalyzer();
}

@Test
void shouldshouldFindAllTasksAtStart3(BpmClient bpmClient) throws Exception {
ExecutionResult result = bpmClient.start().process(FLOW_SUB_PROCESS.elementName("start3")).execute();
ICase icase = result.workflow().activeCase();

List<ITask> parallelTasks = result.workflow().activeTasks();

var detectedTasks = processAnalyzer.findAllTasks(icase, null);

var expected = Arrays.array("CallSubProcess A", "TaskC", "TaskB");
var taskNames = getTaskNames(detectedTasks);
assertArrayEquals(expected, taskNames);
}

@Test
void shouldshouldFindAllTasksAtStart(BpmClient bpmClient) throws Exception {
ExecutionResult result = bpmClient.start().process(FLOW_SUB_PROCESS.elementName("start")).execute();
ICase icase = result.workflow().activeCase();

List<ITask> parallelTasks = result.workflow().activeTasks();

var detectedTasks = processAnalyzer.findAllTasks(icase, null);

var expected = Arrays.array("Task A", "Task B");
var taskNames = getTaskNames(detectedTasks);
assertArrayEquals(expected, taskNames);
}
}
Loading

0 comments on commit 641c1d5

Please sign in to comment.