Skip to content

Commit c291f7e

Browse files
author
lvcangquan.lcq
committed
fix a bug of branchGraph cache with test_case
1 parent 9c87a39 commit c291f7e

File tree

19 files changed

+365
-2
lines changed

19 files changed

+365
-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.branchGraphTest";
48+
Map<String, Object> context = new HashMap<String, Object>();
49+
int input = 16;
50+
int finalResult = -1;
51+
context.put("input", input);
52+
context.put("finalResult", finalResult);
53+
final ProcessEngine processEngine = ProcessEngineFactory.getProcessEngine();
54+
processEngine.execute(code, context);
55+
//todo
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(int input) {
8+
int 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 int process(int sqrtResult) {
8+
int addNumber = 2;
9+
int 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 int process(int onlineInput) {
8+
int addNumber = 2;
9+
int 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(int 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(int result) {
8+
System.out.println("Random process is finished");
9+
}
10+
}
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 RayPreProcessOp {
4+
public RayPreProcessOp () {
5+
}
6+
7+
public int process(int sqrtResult) {
8+
int addNumber = 100;
9+
int rayInput = sqrtResult + addNumber;
10+
return rayInput;
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 RaySolveOp {
4+
public RaySolveOp() {
5+
}
6+
7+
public int process(int rayInput) {
8+
int addNumber = 200;
9+
int rayResult = rayInput + addNumber;
10+
return rayResult;
11+
}
12+
}

0 commit comments

Comments
 (0)