mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
撤销:提交测试用例:模拟真实场景1:简单营销
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
package com.yomahub.liteflow.test.scenes;
|
||||
|
||||
/**
|
||||
* <p>公共方法类</p>
|
||||
* <p>node Component util</p>
|
||||
*/
|
||||
public class CmpUtil {
|
||||
|
||||
private static final String SPLIT_STRING = "_";
|
||||
|
||||
public CmpUtil() {}
|
||||
|
||||
|
||||
/**
|
||||
* 得到:唯一nodeId
|
||||
* @param mode 模式(枚举)
|
||||
* @param type 类型(枚举)
|
||||
* @return String 唯一 node id
|
||||
* */
|
||||
public static String processSwitch(String mode,String type) {
|
||||
return mode + SPLIT_STRING + type;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.yomahub.liteflow.test.scenes;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import com.yomahub.liteflow.test.scenes.bean.RequestDataDO;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* springboot环境EL复杂例子测试1
|
||||
* @author nmnl
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/scens/application1.properties")
|
||||
@SpringBootTest(classes = ScensELSpringbootTest1.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.scenes.cmp1"})
|
||||
public class ScensELSpringbootTest1 extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
|
||||
// 验证正常finally
|
||||
/*@Test
|
||||
public void testScens1_1() throws Exception{
|
||||
LocalDateTime x = LocalDateTime.of(LocalDate.now(), LocalTime.of(15,0,0));
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chaintask", RequestDataDO.of(x,"a"));
|
||||
//Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("ASwitchCmp==>FinallyCmp",response.getExecuteStepStr());
|
||||
}*/
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
package com.yomahub.liteflow.test.scenes.bean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class MarketingDO {
|
||||
|
||||
/** id */
|
||||
private String id;
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 类型(枚举)
|
||||
* @see com.yomahub.liteflow.test.scenes.enums.MarketingTypeEnum
|
||||
* */
|
||||
private String type;
|
||||
|
||||
/** 模式(枚举)
|
||||
* @see com.yomahub.liteflow.test.scenes.enums.MarketingModeEnum
|
||||
* */
|
||||
private String mode;
|
||||
|
||||
/** 开始时间 */
|
||||
private LocalDateTime startDatetime;
|
||||
|
||||
/** 结束时间 */
|
||||
private LocalDateTime endDatetime;
|
||||
|
||||
/** 限制总次数 */
|
||||
private Integer limitTotalNum;
|
||||
|
||||
/** 限制每天次数 */
|
||||
private Integer limitDayNum;
|
||||
|
||||
/** 参与区域(运营商)
|
||||
* */
|
||||
private String joinInst;
|
||||
|
||||
/** 用户模型json
|
||||
* */
|
||||
private String userModel;
|
||||
|
||||
/** 消息模版json
|
||||
*/
|
||||
private String msgTemplate;
|
||||
|
||||
/** 奖励规则json
|
||||
* */
|
||||
private String rewardRule;
|
||||
|
||||
/** 描述 */
|
||||
private String remark;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartDatetime() {
|
||||
return startDatetime;
|
||||
}
|
||||
|
||||
public void setStartDatetime(LocalDateTime startDatetime) {
|
||||
this.startDatetime = startDatetime;
|
||||
}
|
||||
|
||||
public LocalDateTime getEndDatetime() {
|
||||
return endDatetime;
|
||||
}
|
||||
|
||||
public void setEndDatetime(LocalDateTime endDatetime) {
|
||||
this.endDatetime = endDatetime;
|
||||
}
|
||||
|
||||
public Integer getLimitTotalNum() {
|
||||
return limitTotalNum;
|
||||
}
|
||||
|
||||
public void setLimitTotalNum(Integer limitTotalNum) {
|
||||
this.limitTotalNum = limitTotalNum;
|
||||
}
|
||||
|
||||
public Integer getLimitDayNum() {
|
||||
return limitDayNum;
|
||||
}
|
||||
|
||||
public void setLimitDayNum(Integer limitDayNum) {
|
||||
this.limitDayNum = limitDayNum;
|
||||
}
|
||||
|
||||
public String getJoinInst() {
|
||||
return joinInst;
|
||||
}
|
||||
|
||||
public void setJoinInst(String joinInst) {
|
||||
this.joinInst = joinInst;
|
||||
}
|
||||
|
||||
public String getUserModel() {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
public void setUserModel(String userModel) {
|
||||
this.userModel = userModel;
|
||||
}
|
||||
|
||||
public String getMsgTemplate() {
|
||||
return msgTemplate;
|
||||
}
|
||||
|
||||
public void setMsgTemplate(String msgTemplate) {
|
||||
this.msgTemplate = msgTemplate;
|
||||
}
|
||||
|
||||
public String getRewardRule() {
|
||||
return rewardRule;
|
||||
}
|
||||
|
||||
public void setRewardRule(String rewardRule) {
|
||||
this.rewardRule = rewardRule;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.yomahub.liteflow.test.scenes.bean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* springboot环境EL复杂例子测试1
|
||||
* 可以参与的营销 : 1条件:开始时间+区域.
|
||||
* @author nmnl
|
||||
*/
|
||||
public class RequestDataDO {
|
||||
// LocalDateTime.of(LocalDate.now(), LocalTime.of(15,0,0));
|
||||
private LocalDateTime localDateTime;
|
||||
|
||||
private String instId;
|
||||
|
||||
private RequestDataDO(LocalDateTime localDateTime, String instId) {
|
||||
this.localDateTime = localDateTime;
|
||||
this.instId = instId;
|
||||
}
|
||||
|
||||
private static RequestDataDO create(LocalDateTime localDateTime, String instId) {
|
||||
return new RequestDataDO(localDateTime, instId);
|
||||
}
|
||||
|
||||
public static RequestDataDO of(LocalDateTime localDateTime, String instId) {
|
||||
Objects.requireNonNull(localDateTime, "localDateTime");
|
||||
Objects.requireNonNull(instId, "instId");
|
||||
return create(localDateTime, instId);
|
||||
}
|
||||
|
||||
public LocalDateTime getLocalDateTime() {
|
||||
return localDateTime;
|
||||
}
|
||||
|
||||
public void setLocalDateTime(LocalDateTime localDateTime) {
|
||||
this.localDateTime = localDateTime;
|
||||
}
|
||||
|
||||
public String getInstId() {
|
||||
return instId;
|
||||
}
|
||||
|
||||
public void setInstId(String instId) {
|
||||
this.instId = instId;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.scenes.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeSwitchComponent;
|
||||
import com.yomahub.liteflow.test.scenes.CmpUtil;
|
||||
import com.yomahub.liteflow.test.scenes.bean.MarketingDO;
|
||||
import com.yomahub.liteflow.test.scenes.bean.RequestDataDO;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* springboot环境EL复杂例子测试1
|
||||
* 场景描述:可以参与的营销 ASwitchCmp
|
||||
* 1条件:开始时间+区域.
|
||||
* 2流程:根据营销信息(类型+模式)->筛选可参与营销(类型+模式)
|
||||
* 3触发:THEN
|
||||
* @author nmnl
|
||||
*/
|
||||
// @LiteflowComponent("ASwitchCmp")
|
||||
// @Component("ASwitchCmp")
|
||||
@LiteflowComponent("a")
|
||||
public class ASwitchChooseOneCmp extends NodeSwitchComponent {
|
||||
|
||||
// 简单数据结构
|
||||
// 虚拟:营销数据
|
||||
private final static Map<String, MarketingDO> CHOOSE_ONE = new HashMap<>(3);
|
||||
|
||||
static {
|
||||
MarketingDO a = new MarketingDO();
|
||||
CHOOSE_ONE.put("a",a);
|
||||
|
||||
MarketingDO b = new MarketingDO();
|
||||
CHOOSE_ONE.put("b",b);
|
||||
|
||||
MarketingDO c = new MarketingDO();
|
||||
CHOOSE_ONE.put("c",c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String processSwitch() throws Exception {
|
||||
RequestDataDO requestDataDO = this.getRequestData();
|
||||
if (null == requestDataDO){
|
||||
// requestDataDO 为空,无法做进一步的判断
|
||||
throw new Exception("requestDataDO 为空");
|
||||
}
|
||||
// 1条件:营销开始时间+区域..
|
||||
MarketingDO chooseOne = CHOOSE_ONE.get(requestDataDO.getInstId());
|
||||
if (null == chooseOne){
|
||||
// 未命中活动
|
||||
throw new Exception("未命中营销");
|
||||
}
|
||||
//this.getSlot().setResponseData(chooseOne);
|
||||
return CmpUtil.processSwitch(chooseOne.getMode(),chooseOne.getType());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.scenes.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("BEventCmp")
|
||||
public class BEventCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
|
||||
System.out.println(" --- " + this.getRequestData().toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.scenes.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("BManualCmp")
|
||||
public class BManualCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("BManualCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.scenes.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("BTimingCmp")
|
||||
public class BTimingCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("BTimingCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.scenes.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("FinallyCmp")
|
||||
public class FinallyCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("FinallyCmp executed!");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.yomahub.liteflow.test.scenes.enums;
|
||||
|
||||
/**
|
||||
* 枚举类总接口
|
||||
* @author nmnl
|
||||
*/
|
||||
public interface DescEnum {
|
||||
|
||||
/** 获取枚举desc属性 */
|
||||
String getDesc();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.yomahub.liteflow.test.scenes.enums;
|
||||
|
||||
/**
|
||||
* 模式
|
||||
* @author mll
|
||||
*/
|
||||
public enum MarketingModeEnum implements DescEnum {
|
||||
|
||||
EVENT("事件模式"),
|
||||
|
||||
MANUAL("手动模式"),
|
||||
|
||||
TIMING("定时模式");
|
||||
|
||||
private final String desc;
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
MarketingModeEnum(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.yomahub.liteflow.test.scenes.enums;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
* @author nmnl
|
||||
*/
|
||||
public enum MarketingTypeEnum implements DescEnum {
|
||||
|
||||
PAY_DISCOUNT("支付折扣活动"),
|
||||
|
||||
ISSUING_COUPONS("发卷活动"),
|
||||
|
||||
MESSAGE_NOTIFICATION("消息通知活动");
|
||||
|
||||
private final String desc;
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
MarketingTypeEnum(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
liteflow.rule-source=scens/flow1.el.xml
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chaintask">
|
||||
SWITCH(a).to(BEventCmp,BManualCmp,BTimingCmp)
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user