Преглед на файлове

bug #I49EHH setIsEnd设计的不合理性

bryan31 преди 3 години
родител
ревизия
6e3f8ba06a

+ 4 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java

@@ -8,6 +8,7 @@
  */
 package com.yomahub.liteflow.core;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ReUtil;
@@ -297,13 +298,15 @@ public class FlowExecutor {
         return this.execute2Resp(chainId, param, slotClazz, null, false);
     }
 
+    private final ArrayList<Class<? extends Exception>> notFailExceptionList = ListUtil.toList(ChainEndException.class);
+
     public <T extends Slot> LiteflowResponse<T> execute2Resp(String chainId, Object param, Class<T> slotClazz, Integer slotIndex,
                                                              boolean isInnerChain) {
         LiteflowResponse<T> response = new LiteflowResponse<>();
 
         T slot = doExecute(chainId, param, slotClazz, slotIndex, isInnerChain);
 
-        if (ObjectUtil.isNotNull(slot.getException())) {
+        if (ObjectUtil.isNotNull(slot.getException()) && !notFailExceptionList.contains(slot.getException().getClass())) {
             response.setSuccess(false);
             response.setMessage(slot.getException().getMessage());
             response.setCause(slot.getException());

+ 6 - 6
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java

@@ -63,19 +63,19 @@ public class FlowExecutorTest extends BaseTest {
     }
 
     //isEnd方法的功能点测试
-    @Test(expected = ChainEndException.class)
+    @Test
     public void testIsEnd() throws Exception {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain4", 10);
-        Assert.assertFalse(response.isSuccess());
-        ReflectionUtils.rethrowException(response.getCause());
+        Assert.assertTrue(response.isSuccess());
+        Assert.assertEquals("d",response.getSlot().printStep());
     }
 
     //setIsEnd方法的功能点测试
-    @Test(expected = ChainEndException.class)
+    @Test
     public void testSetIsEnd() throws Exception {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain5", 10);
-        Assert.assertFalse(response.isSuccess());
-        ReflectionUtils.rethrowException(response.getCause());
+        Assert.assertTrue(response.isSuccess());
+        Assert.assertEquals("e",response.getSlot().printStep());
     }
 
     //条件组件的功能点测试