瀏覽代碼

多层异步循环测试用例补充

everywhere.z 1 周之前
父節點
當前提交
a8cdbfbb48

+ 7 - 3
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringbootTest.java

@@ -1,5 +1,6 @@
 package com.yomahub.liteflow.test.iterator;
 package com.yomahub.liteflow.test.iterator;
 
 
+import cn.hutool.core.collection.ConcurrentHashSet;
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.collection.ListUtil;
 import com.yomahub.liteflow.core.FlowExecutor;
 import com.yomahub.liteflow.core.FlowExecutor;
 import com.yomahub.liteflow.flow.LiteflowResponse;
 import com.yomahub.liteflow.flow.LiteflowResponse;
@@ -83,12 +84,15 @@ public class IteratorELSpringbootTest extends BaseTest {
 	@Test
 	@Test
 	public void testIt5() throws Exception {
 	public void testIt5() throws Exception {
 		DefaultContext context = new DefaultContext();
 		DefaultContext context = new DefaultContext();
-		context.setData("set", new HashSet<>());
+		context.setData("set", new ConcurrentHashSet<>());
 		context.setData("list1", ListUtil.toList("a", "b", "c", "d", "e", "f"));
 		context.setData("list1", ListUtil.toList("a", "b", "c", "d", "e", "f"));
-		context.setData("list2", ListUtil.toList("1", "2", "3", "4", "5", "6", "7", "8", "9"));
+		context.setData("list2", ListUtil.toList("L2_1", "L2_2", "L2_3"));
+		context.setData("list3", ListUtil.toList("L3_1", "L3_2", "L3_3", "L3_4"));
+		context.setData("list4", ListUtil.toList("L4_1", "L4_2"));
+		context.setData("list5", ListUtil.toList("L5_1", "L5_2", "L5_3"));
 		LiteflowResponse response = flowExecutor.execute2Resp("chain5",null, context);
 		LiteflowResponse response = flowExecutor.execute2Resp("chain5",null, context);
 		Assertions.assertTrue(response.isSuccess());
 		Assertions.assertTrue(response.isSuccess());
 		Set<String> set = context.getData("set");
 		Set<String> set = context.getData("set");
-		Assertions.assertEquals(54, set.size());
+		Assertions.assertEquals(6*3*4*2*3, set.size());
 	}
 	}
 }
 }

+ 6 - 3
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/cmp/FCmp.java

@@ -13,12 +13,15 @@ public class FCmp extends NodeComponent {
 
 
 	@Override
 	@Override
 	public void process() throws Exception {
 	public void process() throws Exception {
-		Object obj1 = this.getPreLoopObj();
-		Object obj2 = this.getCurrLoopObj();
+		Object obj1 = this.getCurrLoopObj();
+		Object obj2 = this.getPreNLoopObj(1);
+		Object obj3 = this.getPreNLoopObj(2);
+		Object obj4 = this.getPreNLoopObj(3);
+		Object obj5 = this.getPreNLoopObj(4);
 		if (obj1 == null || obj2 == null) {
 		if (obj1 == null || obj2 == null) {
 			throw new RuntimeException("");
 			throw new RuntimeException("");
 		}
 		}
-		String str = StrUtil.format("{}{}", obj1, obj2);
+		String str = StrUtil.format("{}-{}-{}-{}-{}", obj5, obj4, obj3, obj2, obj1);
 		DefaultContext context = this.getFirstContextBean();
 		DefaultContext context = this.getFirstContextBean();
 		Set<String> set = context.getData("set");
 		Set<String> set = context.getData("set");
 		set.add(str);
 		set.add(str);

+ 18 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/cmp/X3Cmp.java

@@ -0,0 +1,18 @@
+package com.yomahub.liteflow.test.iterator.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeIteratorComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+import java.util.Iterator;
+import java.util.List;
+
+@LiteflowComponent("x3")
+public class X3Cmp extends NodeIteratorComponent {
+    @Override
+    public Iterator<?> processIterator() throws Exception {
+        DefaultContext context = this.getFirstContextBean();
+        List<String> list = context.getData("list3");
+        return list.iterator();
+    }
+}

+ 18 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/cmp/X4Cmp.java

@@ -0,0 +1,18 @@
+package com.yomahub.liteflow.test.iterator.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeIteratorComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+import java.util.Iterator;
+import java.util.List;
+
+@LiteflowComponent("x4")
+public class X4Cmp extends NodeIteratorComponent {
+    @Override
+    public Iterator<?> processIterator() throws Exception {
+        DefaultContext context = this.getFirstContextBean();
+        List<String> list = context.getData("list4");
+        return list.iterator();
+    }
+}

+ 18 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/cmp/X5Cmp.java

@@ -0,0 +1,18 @@
+package com.yomahub.liteflow.test.iterator.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeIteratorComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+import java.util.Iterator;
+import java.util.List;
+
+@LiteflowComponent("x5")
+public class X5Cmp extends NodeIteratorComponent {
+    @Override
+    public Iterator<?> processIterator() throws Exception {
+        DefaultContext context = this.getFirstContextBean();
+        List<String> list = context.getData("list5");
+        return list.iterator();
+    }
+}

+ 2 - 1
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/iterator/application.properties

@@ -1 +1,2 @@
-liteflow.rule-source=iterator/flow.xml
+liteflow.rule-source=iterator/flow.xml
+liteflow.global-thread-pool-size=500

+ 7 - 1
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/iterator/flow.xml

@@ -27,7 +27,13 @@
 
 
     <chain name="chain5">
     <chain name="chain5">
         ITERATOR(x1).parallel(true).DO(
         ITERATOR(x1).parallel(true).DO(
-            ITERATOR(x2).parallel(true).DO(f)
+            ITERATOR(x2).parallel(true).DO(
+                ITERATOR(x3).parallel(true).DO(
+                    ITERATOR(x4).parallel(true).DO(
+                        ITERATOR(x5).parallel(true).DO(f)
+                    )
+                )
+            )
         );
         );
     </chain>
     </chain>
 </flow>
 </flow>