Explorar o código

feature #IBW9PC 上下文表达式搜索&设置,摆脱对上下文的依赖

everywhere.z hai 1 mes
pai
achega
07e90c3725

+ 3 - 0
liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultContext.java

@@ -34,4 +34,7 @@ public class DefaultContext {
 		putDataMap(key, t);
 		putDataMap(key, t);
 	}
 	}
 
 
+	public ConcurrentHashMap<String, Object> getDataMap() {
+		return dataMap;
+	}
 }
 }

+ 12 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/searchContext/SearchContextSpringbootTest.java

@@ -97,4 +97,16 @@ public class SearchContextSpringbootTest extends BaseTest {
 		Assertions.assertEquals("test info", context.getData("test"));
 		Assertions.assertEquals("test info", context.getData("test"));
 	}
 	}
 
 
+	// 测试获取DefaultContext
+	@Test
+	public void testSearchContext6() throws Exception {
+		DefaultContext context = new DefaultContext();
+		context.setData("k1", "v1");
+
+		LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg", context);
+		Assertions.assertTrue(response.isSuccess());
+		context = response.getContextBean(DefaultContext.class);
+		Assertions.assertEquals("v1", context.getData("test"));
+	}
+
 }
 }

+ 22 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/searchContext/cmp/A6Cmp.java

@@ -0,0 +1,22 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.searchContext.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("a6")
+public class A6Cmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		String str = this.getContextValue("dataMap.k1");
+		this.setContextValue("setData", "test", str);
+
+	}
+}

+ 4 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/searchContext/flow.xml

@@ -20,4 +20,8 @@
     <chain name="chain5">
     <chain name="chain5">
         THEN(a5);
         THEN(a5);
     </chain>
     </chain>
+
+    <chain name="chain6">
+        THEN(a6);
+    </chain>
 </flow>
 </flow>