bug #I49EHH setIsEnd设计的不合理性

This commit is contained in:
bryan31
2021-09-20 23:05:10 +08:00
parent a052ad50ff
commit 6e3f8ba06a
2 changed files with 10 additions and 7 deletions

View File

@@ -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());

View File

@@ -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());
}
//条件组件的功能点测试