Skip to content

Commit

Permalink
TE-612: Fix loop with SubProcessCall
Browse files Browse the repository at this point in the history
  • Loading branch information
trungmaihova committed Jun 17, 2024
1 parent 629d544 commit 9800658
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FlowTriggerCallData #class
com.axonivy.utils.estimator.test #namespace
63 changes: 60 additions & 3 deletions process-analyzer-test/processes/FlowSubprocess.p.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"findTasksOnPath( start.ivp ) => TaskA, TaskB"
],
"visual" : {
"at" : { "x" : 824, "y" : 167 },
"at" : { "x" : 968, "y" : 63 },
"size" : { "width" : 476, "height" : 97 }
}
}, {
Expand Down Expand Up @@ -191,7 +191,7 @@
"size" : { "width" : 128, "height" : 60 }
},
"connect" : [
{ "id" : "f9", "to" : "f8" }
{ "id" : "f9", "to" : "S80" }
]
}, {
"id" : "f6",
Expand All @@ -210,7 +210,7 @@
"id" : "f8",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 488, "y" : 192 }
"at" : { "x" : 728, "y" : 192 }
}
}, {
"id" : "f10",
Expand Down Expand Up @@ -969,6 +969,63 @@
"connect" : [
{ "id" : "f29", "to" : "f17", "var" : "in1" }
]
}, {
"id" : "S80",
"type" : "EmbeddedProcess",
"name" : "Sub2",
"elements" : [ {
"id" : "S80-g0",
"type" : "EmbeddedStart",
"visual" : {
"at" : { "x" : 64, "y" : 256 }
},
"parentConnector" : "f9",
"connect" : [
{ "id" : "S80-f0", "to" : "S80-f3" }
]
}, {
"id" : "S80-g1",
"type" : "EmbeddedEnd",
"visual" : {
"at" : { "x" : 520, "y" : 256 }
},
"parentConnector" : "f32"
}, {
"id" : "S80-f1",
"type" : "UserTask",
"name" : "Sub2-TaskA",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "Sub2-TaskA"
}
},
"visual" : {
"at" : { "x" : 368, "y" : 256 }
},
"connect" : [
{ "id" : "S80-f2", "to" : "S80-g1" }
]
}, {
"id" : "S80-f3",
"type" : "TriggerCall",
"name" : "Sub2-TriggerA",
"config" : {
"processCall" : "FlowTriggerCall:start()"
},
"visual" : {
"at" : { "x" : 192, "y" : 256 }
},
"connect" : [
{ "id" : "S80-f4", "to" : "S80-f1" }
]
} ],
"visual" : {
"at" : { "x" : 512, "y" : 192 }
},
"connect" : [
{ "id" : "f32", "to" : "f8" }
]
} ],
"layout" : {
"colors" : {
Expand Down
44 changes: 44 additions & 0 deletions process-analyzer-test/processes/FlowTriggerCall.p.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema" : "https://json-schema.axonivy.com/process/11.2.2/process.json",
"id" : "19024F53FFE1E44F",
"config" : {
"data" : "com.axonivy.utils.estimator.test.FlowTriggerCallData"
},
"elements" : [ {
"id" : "f0",
"type" : "RequestStart",
"name" : "start",
"config" : {
"signature" : "start",
"triggerable" : true
},
"visual" : {
"at" : { "x" : 96, "y" : 64 }
},
"connect" : [
{ "id" : "f2", "to" : "f3" }
]
}, {
"id" : "f1",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 352, "y" : 64 }
}
}, {
"id" : "f3",
"type" : "UserTask",
"name" : "Trigger-TaskA",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "Trigger-TaskA"
}
},
"visual" : {
"at" : { "x" : 224, "y" : 64 }
},
"connect" : [
{ "id" : "f4", "to" : "f1" }
]
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void shouldFindTasksOnPathAtStart() throws Exception {
var start = ProcessGraphHelper.findByElementName(process, "start");
var detectedTasks = processAnalyzer.findTasksOnPath(start, UseCase.BIGPROJECT, "internal");

var expected = Arrays.array("Task A", "Task B", "Task2B", "Task G", "Task2A", "Task H");
var expected = Arrays.array("Task A", "Task B", "Task2A", "Task H", "Task2B", "Task G");
var taskNames = (getTaskNames(detectedTasks));
assertArrayEquals(expected, taskNames);
}
Expand All @@ -120,7 +120,7 @@ void shouldCalculateEstimateDuratioUseCaseBIGPROJECTAtTaskBAndTaskC() throws Exc
var taskC = ProcessGraphHelper.findByElementName(process, "Task C");
Duration duration = processAnalyzer.calculateWorstCaseDuration(List.of(taskB, taskC), UseCase.BIGPROJECT);

assertEquals(Duration.ofHours(18), duration);
assertEquals(Duration.ofHours(15), duration);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ void shouldFindTaskParentNames() throws Exception {
}

@Test
void shouldFindSubProcessTest() throws Exception {
void shouldFindSubProcessTestAtStart2() throws Exception {
var start2 = ProcessGraphHelper.findByElementName(process, "start2");
var detectedTasks = processAnalyzer.findAllTasks(start2, UseCase.BIGPROJECT);

var expected = Arrays.array("Task sub", "Sub2-TaskA");
var taskNames = getTaskNames(detectedTasks);
assertArrayEquals(expected, taskNames);

var detectedTask = (DetectedTask) detectedTasks.get(0);

assertEquals(1, detectedTasks.size());
assertEquals("18DE58E0441486DF-f5", detectedTask.getPid());
assertEquals("Custom info", detectedTask.getCustomInfo());
assertEquals("FlowSubProcessCall", detectedTask.getElementName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private List<AnalysisPath> getParentPathOf(ProcessElement startElement,String fl

List<AnalysisPath> result = paths;
if(parentElement != null) {
SubProcessGroup subProcess = new SubProcessGroup(parentElement.getElement(), paths);
SubProcessGroup subProcess = new SubProcessGroup((EmbeddedProcessElement) parentElement.getElement(), paths);

Map<ProcessElement, List<AnalysisPath>> parentPaths = findPath(List.of(parentElement), flowName, findType);
List<AnalysisPath> subPaths = parentPaths.getOrDefault(parentElement, emptyList());
Expand Down Expand Up @@ -458,8 +458,8 @@ private Map<SequenceFlow, List<AnalysisPath>> findAnalysisPathForNextNode(Proces

private boolean isContains(List<AnalysisPath> currentPaths, final ProcessElement from) {
boolean isContains = false;
if (from.getElement() instanceof SingleTaskCreator && from.getElement() instanceof RequestStart == false) {
SingleTaskCreator node = (SingleTaskCreator) from.getElement();
if (from.getElement() instanceof NodeElement && from.getElement() instanceof RequestStart == false) {
NodeElement node = (NodeElement) from.getElement();
if (node.getIncoming().size() > 0) {
SequenceFlow sequenceFlow = node.getIncoming().get(0);
List<AnalysisPath> pathWithConnectToFrom = currentPaths.stream().filter(path -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
import java.util.Objects;

import ch.ivyteam.ivy.process.model.BaseElement;
import ch.ivyteam.ivy.process.model.element.EmbeddedProcessElement;
import ch.ivyteam.ivy.process.model.value.PID;

public class SubProcessGroup implements ProcessElement {
private BaseElement element;
private EmbeddedProcessElement element;
List<AnalysisPath> internalPaths;

public SubProcessGroup(BaseElement element) {
public SubProcessGroup(EmbeddedProcessElement element) {
this.element = element;
}

public SubProcessGroup(BaseElement element, List<AnalysisPath> internalPaths) {
public SubProcessGroup(EmbeddedProcessElement element, List<AnalysisPath> internalPaths) {
this(element);
this.internalPaths = internalPaths;
}
Expand Down

0 comments on commit 9800658

Please sign in to comment.