bug #I5G9L0 在相同组件执行完之后,取steps的时候,存在报错现象

This commit is contained in:
everywhere.z
2022-07-08 23:32:09 +08:00
parent 291e4ff6b9
commit b16621c0b4
3 changed files with 26 additions and 1 deletions

View File

@@ -4,8 +4,10 @@ import com.yomahub.liteflow.flow.entity.CmpStep;
import com.yomahub.liteflow.slot.Slot;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -75,7 +77,13 @@ public class LiteflowResponse implements Serializable {
}
public Map<String, CmpStep> getExecuteSteps(){
return this.getSlot().getExecuteSteps().stream().collect(Collectors.toMap(CmpStep::getNodeId, cmpStep -> cmpStep));
Map<String, CmpStep> map = new HashMap<>();
this.getSlot().getExecuteSteps().forEach(cmpStep -> map.put(cmpStep.getNodeId(), cmpStep));
return map;
}
public Queue<CmpStep> getExecuteStepQueue(){
return this.getSlot().getExecuteSteps();
}
public String getExecuteStepStr(){

View File

@@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.cmpStep;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.flow.entity.CmpStep;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
@@ -13,6 +14,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Map;
import java.util.Queue;
/**
* springboot环境step的测试例子
@@ -51,4 +54,14 @@ public class CmpStepELSpringbootTest extends BaseTest {
Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testStep3() throws Exception{
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Map<String, CmpStep> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());
}
}

View File

@@ -7,4 +7,8 @@
<chain name="chain2">
THEN(WHEN(e, a).any(true), b)
</chain>
<chain name="chain3">
THEN(a, b, a, a, b)
</chain>
</flow>