Skip to content

Commit aea86c5

Browse files
lvcangquan.lcqzjulcq
authored andcommitted
fix a bug of branchGraph cache with test_case
1 parent 9c87a39 commit aea86c5

File tree

21 files changed

+409
-2
lines changed

21 files changed

+409
-2
lines changed

src/main/java/com/alibaba/compileflow/engine/runtime/impl/AbstractProcessRuntime.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ private List<TransitionNode> buildGatewayFollowingNodes(TransitionNode flowNode)
539539
}
540540

541541
private List<TransitionNode> buildBranchNodes(TransitionNode branchNode) {
542-
if (branchGraph.containsKey(branchNode.getId())) {
542+
if (branchGraph.containsKey(branchNode.getId()) &&
543+
!branchNode.getIncomingNodes().stream().anyMatch(incomingNode -> incomingNode instanceof GatewayElement)) {
543544
return branchGraph.get(branchNode.getId());
544545
}
545546

src/test/java/com/allibaba/compileflow/test/ProcessEngineTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ public void testProcessEngine() {
4242
System.out.println(processEngine.execute(code, context));
4343
}
4444

45+
@Test
46+
public void testBranchGraph() {
47+
final String code = "bpm.om.branchGraph";
48+
Map<String, Object> context = new HashMap<String, Object>();
49+
Integer input = 16;
50+
Integer compareNumber = 18;
51+
context.put("input", input);
52+
final ProcessEngine processEngine = ProcessEngineFactory.getProcessEngine();
53+
Map<String, Object> result = processEngine.execute(code, context);
54+
Integer finalResult = (Integer) result.get("finalResult");
55+
assert (finalResult == compareNumber);
56+
}
57+
4558
@Test
4659
public void testProcessEngineBpmn20() {
4760
final String code = "bpmn20.ktv.ktvExample";
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.allibaba.compileflow.test.om.branch_graph.calculate;
2+
3+
public class InputCheckOp {
4+
public InputCheckOp() {
5+
}
6+
7+
public Boolean process(Integer input) {
8+
Integer compareNumber = 20;
9+
if (input > compareNumber) {
10+
return false;
11+
} else {
12+
return true;
13+
}
14+
}
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.allibaba.compileflow.test.om.branch_graph.calculate;
2+
3+
public class OnlinePreProcessOp {
4+
public OnlinePreProcessOp() {
5+
}
6+
7+
public Integer process(Integer sqrtResult) {
8+
Integer addNumber = 2;
9+
Integer onlineInput = sqrtResult + addNumber;
10+
return onlineInput;
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.allibaba.compileflow.test.om.branch_graph.calculate;
2+
3+
public class OnlineSolveOp {
4+
public OnlineSolveOp() {
5+
}
6+
7+
public Integer process(Integer onlineInput) {
8+
Integer addNumber = 2;
9+
Integer onlineResult = onlineInput + addNumber;
10+
return onlineResult;
11+
}
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.allibaba.compileflow.test.om.branch_graph.calculate;
2+
3+
import java.math.BigInteger;
4+
5+
public class PreProcessOp {
6+
public PreProcessOp() {
7+
}
8+
9+
public void process(Integer input) {
10+
int compareNumber = 10;
11+
if (input < compareNumber) {
12+
System.out.println("input is smaller than 10");
13+
}
14+
}
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.allibaba.compileflow.test.om.branch_graph.calculate;
2+
3+
public class RandomOp {
4+
public RandomOp() {
5+
}
6+
7+
public void process(Integer result) {
8+
System.out.println("Random process is finished " + result);
9+
}
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.allibaba.compileflow.test.om.branch_graph.calculate;
2+
3+
public class ResultCheckOp {
4+
public ResultCheckOp() {
5+
}
6+
7+
public Boolean process(Integer result) {
8+
Integer compareNumber = 10;
9+
if (result < compareNumber) {
10+
return true;
11+
}
12+
return false;
13+
}
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.allibaba.compileflow.test.om.branch_graph.calculate;
2+
3+
public class ResultPostProcessOp {
4+
public ResultPostProcessOp() {
5+
}
6+
7+
public Integer process(Integer result) {
8+
Integer addNumber = 10;
9+
Integer finalResult = result + addNumber;
10+
return finalResult;
11+
}
12+
}

0 commit comments

Comments
 (0)