bug #I7HTR4 同一组件不同tag,取step时候存在问题

This commit is contained in:
everywhere.z 2023-07-11 23:35:49 +08:00
parent 628009622c
commit 269e1ec145
7 changed files with 66 additions and 78 deletions

View File

@ -1,13 +1,13 @@
package com.yomahub.liteflow.flow;
import cn.hutool.core.collection.ListUtil;
import com.yomahub.liteflow.exception.LiteFlowException;
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.*;
import java.util.function.Consumer;
/**
* 执行结果封装类
@ -101,9 +101,15 @@ public class LiteflowResponse {
return this.getSlot().getContextBean(contextBeanClazz);
}
public Map<String, CmpStep> getExecuteSteps() {
Map<String, CmpStep> map = new HashMap<>();
this.getSlot().getExecuteSteps().forEach(cmpStep -> map.put(cmpStep.getNodeId(), cmpStep));
public Map<String, List<CmpStep>> getExecuteSteps() {
Map<String, List<CmpStep>> map = new LinkedHashMap<>();
this.getSlot().getExecuteSteps().forEach(cmpStep -> {
if (map.containsKey(cmpStep.getNodeId())){
map.get(cmpStep.getNodeId()).add(cmpStep);
}else{
map.put(cmpStep.getNodeId(), ListUtil.toList(cmpStep));
}
});
return map;
}

View File

@ -14,10 +14,7 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.*;
/**
* springboot环境最普通的例子测试
@ -39,13 +36,13 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
public void testStep() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass());
Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
}
@Test
@ -59,7 +56,7 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
public void testStep3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Map<String, CmpStep> stepMap = response.getExecuteSteps();
Map<String, List<CmpStep>> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());

View File

@ -14,10 +14,7 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.*;
/**
* springboot环境最普通的例子测试
@ -39,13 +36,13 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
public void testStep() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass());
Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
}
@Test
@ -59,7 +56,7 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
public void testStep3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Map<String, CmpStep> stepMap = response.getExecuteSteps();
Map<String, List<CmpStep>> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());

View File

@ -10,10 +10,7 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.*;
public class CmpStepTest extends BaseTest {
@ -30,13 +27,13 @@ public class CmpStepTest extends BaseTest {
public void testStep1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass());
Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
}
@Test
@ -50,7 +47,7 @@ public class CmpStepTest extends BaseTest {
public void testStep3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Map<String, CmpStep> stepMap = response.getExecuteSteps();
Map<String, List<CmpStep>> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());

View File

@ -11,10 +11,7 @@ import org.noear.solon.annotation.Inject;
import org.noear.solon.test.SolonJUnit4ClassRunner;
import org.noear.solon.test.annotation.TestPropertySource;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.*;
/**
* springboot环境step的测试例子
@ -35,13 +32,13 @@ public class CmpStepELSpringbootTest extends BaseTest {
public void testStep1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass());
Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
}
@Test
@ -55,7 +52,7 @@ public class CmpStepELSpringbootTest extends BaseTest {
public void testStep3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Map<String, CmpStep> stepMap = response.getExecuteSteps();
Map<String, List<CmpStep>> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());

View File

@ -14,10 +14,7 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Predicate;
@ -43,13 +40,13 @@ public class CmpStepELSpringbootTest extends BaseTest {
public void testStep1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass());
Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
}
@Test
@ -63,7 +60,7 @@ public class CmpStepELSpringbootTest extends BaseTest {
public void testStep3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Map<String, CmpStep> stepMap = response.getExecuteSteps();
Map<String, List<CmpStep>> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());

View File

@ -11,10 +11,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.*;
@RunWith(SpringRunner.class)
@ContextConfiguration("classpath:/cmpStep/application.xml")
@ -27,13 +24,13 @@ public class CmpStepELSpringTest extends BaseTest {
public void testStep1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass());
Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
}
@Test
@ -47,7 +44,7 @@ public class CmpStepELSpringTest extends BaseTest {
public void testStep3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Map<String, CmpStep> stepMap = response.getExecuteSteps();
Map<String, List<CmpStep>> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());