Commit 057f924bd165d3253e06bea213321b77e2b983c8
1 parent
e639dbfe
refactor: 【IoT 物联网】统一场景联动 ‘IoT’ 前缀
Showing
18 changed files
with
175 additions
and
63 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/CurrentTimeConditionMatcher.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/IotCurrentTimeConditionMatcher.java
| ... | ... | @@ -16,7 +16,6 @@ import java.time.LocalTime; |
| 16 | 16 | import java.time.format.DateTimeFormatter; |
| 17 | 17 | import java.util.List; |
| 18 | 18 | |
| 19 | -// TODO @puhui999:是不是 IoT 的前缀,都加下哈; | |
| 20 | 19 | /** |
| 21 | 20 | * 当前时间条件匹配器:处理时间相关的子条件匹配逻辑 |
| 22 | 21 | * |
| ... | ... | @@ -24,7 +23,7 @@ import java.util.List; |
| 24 | 23 | */ |
| 25 | 24 | @Component |
| 26 | 25 | @Slf4j |
| 27 | -public class CurrentTimeConditionMatcher implements IotSceneRuleConditionMatcher { | |
| 26 | +public class IotCurrentTimeConditionMatcher implements IotSceneRuleConditionMatcher { | |
| 28 | 27 | |
| 29 | 28 | /** |
| 30 | 29 | * 时间格式化器 - HH:mm:ss | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/DevicePropertyConditionMatcher.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/IotDevicePropertyConditionMatcher.java
| ... | ... | @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; |
| 15 | 15 | * @author HUIHUI |
| 16 | 16 | */ |
| 17 | 17 | @Component |
| 18 | -public class DevicePropertyConditionMatcher implements IotSceneRuleConditionMatcher { | |
| 18 | +public class IotDevicePropertyConditionMatcher implements IotSceneRuleConditionMatcher { | |
| 19 | 19 | |
| 20 | 20 | @Override |
| 21 | 21 | public IotSceneRuleConditionTypeEnum getSupportedConditionType() { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/DeviceStateConditionMatcher.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/IotDeviceStateConditionMatcher.java
| ... | ... | @@ -13,7 +13,7 @@ import org.springframework.stereotype.Component; |
| 13 | 13 | * @author HUIHUI |
| 14 | 14 | */ |
| 15 | 15 | @Component |
| 16 | -public class DeviceStateConditionMatcher implements IotSceneRuleConditionMatcher { | |
| 16 | +public class IotDeviceStateConditionMatcher implements IotSceneRuleConditionMatcher { | |
| 17 | 17 | |
| 18 | 18 | @Override |
| 19 | 19 | public IotSceneRuleConditionTypeEnum getSupportedConditionType() { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/DeviceEventPostTriggerMatcher.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotDeviceEventPostTriggerMatcher.java
| ... | ... | @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; |
| 15 | 15 | * @author HUIHUI |
| 16 | 16 | */ |
| 17 | 17 | @Component |
| 18 | -public class DeviceEventPostTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 18 | +public class IotDeviceEventPostTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 19 | 19 | |
| 20 | 20 | @Override |
| 21 | 21 | public IotSceneRuleTriggerTypeEnum getSupportedTriggerType() { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/DevicePropertyPostTriggerMatcher.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotDevicePropertyPostTriggerMatcher.java
| ... | ... | @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; |
| 14 | 14 | * @author HUIHUI |
| 15 | 15 | */ |
| 16 | 16 | @Component |
| 17 | -public class DevicePropertyPostTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 17 | +public class IotDevicePropertyPostTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 18 | 18 | |
| 19 | 19 | @Override |
| 20 | 20 | public IotSceneRuleTriggerTypeEnum getSupportedTriggerType() { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/DeviceServiceInvokeTriggerMatcher.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotDeviceServiceInvokeTriggerMatcher.java
| ... | ... | @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; |
| 14 | 14 | * @author HUIHUI |
| 15 | 15 | */ |
| 16 | 16 | @Component |
| 17 | -public class DeviceServiceInvokeTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 17 | +public class IotDeviceServiceInvokeTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 18 | 18 | |
| 19 | 19 | @Override |
| 20 | 20 | public IotSceneRuleTriggerTypeEnum getSupportedTriggerType() { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/DeviceStateUpdateTriggerMatcher.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotDeviceStateUpdateTriggerMatcher.java
| ... | ... | @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; |
| 14 | 14 | * @author HUIHUI |
| 15 | 15 | */ |
| 16 | 16 | @Component |
| 17 | -public class DeviceStateUpdateTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 17 | +public class IotDeviceStateUpdateTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 18 | 18 | |
| 19 | 19 | @Override |
| 20 | 20 | public IotSceneRuleTriggerTypeEnum getSupportedTriggerType() { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/TimerTriggerMatcher.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotTimerTriggerMatcher.java
| ... | ... | @@ -16,7 +16,7 @@ import org.springframework.stereotype.Component; |
| 16 | 16 | * @author HUIHUI |
| 17 | 17 | */ |
| 18 | 18 | @Component |
| 19 | -public class TimerTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 19 | +public class IotTimerTriggerMatcher implements IotSceneRuleTriggerMatcher { | |
| 20 | 20 | |
| 21 | 21 | @Override |
| 22 | 22 | public IotSceneRuleTriggerTypeEnum getSupportedTriggerType() { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/BaseMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/IotBaseConditionMatcherTest.java
| ... | ... | @@ -6,7 +6,6 @@ import org.springframework.context.annotation.Bean; |
| 6 | 6 | import org.springframework.context.annotation.Configuration; |
| 7 | 7 | import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; |
| 8 | 8 | |
| 9 | -// TODO @puhui999:建议改成 IotBaseConditionMatcherTest | |
| 10 | 9 | /** |
| 11 | 10 | * Matcher 测试基类 |
| 12 | 11 | * 提供通用的 Spring 测试配置 |
| ... | ... | @@ -14,7 +13,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; |
| 14 | 13 | * @author HUIHUI |
| 15 | 14 | */ |
| 16 | 15 | @SpringJUnitConfig |
| 17 | -public abstract class BaseMatcherTest { | |
| 16 | +public abstract class IotBaseConditionMatcherTest { | |
| 18 | 17 | |
| 19 | 18 | /** |
| 20 | 19 | * 注入一下 SpringUtil,解析 EL 表达式时需要 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/CurrentTimeConditionMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/IotCurrentTimeConditionMatcherTest.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionOperatorEnum; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionTypeEnum; |
| 7 | -import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.BaseMatcherTest; | |
| 7 | +import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.IotBaseConditionMatcherTest; | |
| 8 | 8 | import org.junit.jupiter.api.BeforeEach; |
| 9 | 9 | import org.junit.jupiter.api.Test; |
| 10 | 10 | |
| ... | ... | @@ -16,17 +16,17 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString |
| 16 | 16 | import static org.junit.jupiter.api.Assertions.*; |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * {@link CurrentTimeConditionMatcher} 的单元测试 | |
| 19 | + * {@link IotCurrentTimeConditionMatcher} 的单元测试 | |
| 20 | 20 | * |
| 21 | 21 | * @author HUIHUI |
| 22 | 22 | */ |
| 23 | -public class CurrentTimeConditionMatcherTest extends BaseMatcherTest { | |
| 23 | +public class IotCurrentTimeConditionMatcherTest extends IotBaseConditionMatcherTest { | |
| 24 | 24 | |
| 25 | - private CurrentTimeConditionMatcher matcher; | |
| 25 | + private IotCurrentTimeConditionMatcher matcher; | |
| 26 | 26 | |
| 27 | 27 | @BeforeEach |
| 28 | 28 | public void setUp() { |
| 29 | - matcher = new CurrentTimeConditionMatcher(); | |
| 29 | + matcher = new IotCurrentTimeConditionMatcher(); | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | @Test | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/DevicePropertyConditionMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/IotDevicePropertyConditionMatcherTest.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionOperatorEnum; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionTypeEnum; |
| 7 | -import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.BaseMatcherTest; | |
| 7 | +import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.IotBaseConditionMatcherTest; | |
| 8 | 8 | import org.junit.jupiter.api.BeforeEach; |
| 9 | 9 | import org.junit.jupiter.api.Test; |
| 10 | 10 | |
| ... | ... | @@ -15,17 +15,17 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId |
| 15 | 15 | import static org.junit.jupiter.api.Assertions.*; |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * {@link DevicePropertyConditionMatcher} 的单元测试 | |
| 18 | + * {@link IotDevicePropertyConditionMatcher} 的单元测试 | |
| 19 | 19 | * |
| 20 | 20 | * @author HUIHUI |
| 21 | 21 | */ |
| 22 | -public class DevicePropertyConditionMatcherTest extends BaseMatcherTest { | |
| 22 | +public class IotDevicePropertyConditionMatcherTest extends IotBaseConditionMatcherTest { | |
| 23 | 23 | |
| 24 | - private DevicePropertyConditionMatcher matcher; | |
| 24 | + private IotDevicePropertyConditionMatcher matcher; | |
| 25 | 25 | |
| 26 | 26 | @BeforeEach |
| 27 | 27 | public void setUp() { |
| 28 | - matcher = new DevicePropertyConditionMatcher(); | |
| 28 | + matcher = new IotDevicePropertyConditionMatcher(); | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | @Test | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/DeviceStateConditionMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/IotDeviceStateConditionMatcherTest.java
| ... | ... | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionOperatorEnum; |
| 7 | 7 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionTypeEnum; |
| 8 | -import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.BaseMatcherTest; | |
| 8 | +import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.IotBaseConditionMatcherTest; | |
| 9 | 9 | import org.junit.jupiter.api.BeforeEach; |
| 10 | 10 | import org.junit.jupiter.api.Test; |
| 11 | 11 | |
| ... | ... | @@ -14,17 +14,17 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString |
| 14 | 14 | import static org.junit.jupiter.api.Assertions.*; |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * {@link DeviceStateConditionMatcher} 的单元测试 | |
| 17 | + * {@link IotDeviceStateConditionMatcher} 的单元测试 | |
| 18 | 18 | * |
| 19 | 19 | * @author HUIHUI |
| 20 | 20 | */ |
| 21 | -public class DeviceStateConditionMatcherTest extends BaseMatcherTest { | |
| 21 | +public class IotDeviceStateConditionMatcherTest extends IotBaseConditionMatcherTest { | |
| 22 | 22 | |
| 23 | - private DeviceStateConditionMatcher matcher; | |
| 23 | + private IotDeviceStateConditionMatcher matcher; | |
| 24 | 24 | |
| 25 | 25 | @BeforeEach |
| 26 | 26 | public void setUp() { |
| 27 | - matcher = new DeviceStateConditionMatcher(); | |
| 27 | + matcher = new IotDeviceStateConditionMatcher(); | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | @Test | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/DeviceEventPostTriggerMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotDeviceEventPostTriggerMatcherTest.java
| ... | ... | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| 7 | 7 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum; |
| 8 | -import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.BaseMatcherTest; | |
| 8 | +import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.IotBaseConditionMatcherTest; | |
| 9 | 9 | import org.junit.jupiter.api.BeforeEach; |
| 10 | 10 | import org.junit.jupiter.api.Test; |
| 11 | 11 | |
| ... | ... | @@ -18,17 +18,17 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString |
| 18 | 18 | import static org.junit.jupiter.api.Assertions.*; |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * {@link DeviceEventPostTriggerMatcher} 的单元测试 | |
| 21 | + * {@link IotDeviceEventPostTriggerMatcher} 的单元测试 | |
| 22 | 22 | * |
| 23 | 23 | * @author HUIHUI |
| 24 | 24 | */ |
| 25 | -public class DeviceEventPostTriggerMatcherTest extends BaseMatcherTest { | |
| 25 | +public class IotDeviceEventPostTriggerMatcherTest extends IotBaseConditionMatcherTest { | |
| 26 | 26 | |
| 27 | - private DeviceEventPostTriggerMatcher matcher; | |
| 27 | + private IotDeviceEventPostTriggerMatcher matcher; | |
| 28 | 28 | |
| 29 | 29 | @BeforeEach |
| 30 | 30 | public void setUp() { |
| 31 | - matcher = new DeviceEventPostTriggerMatcher(); | |
| 31 | + matcher = new IotDeviceEventPostTriggerMatcher(); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | @Test | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/DevicePropertyPostTriggerMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotDevicePropertyPostTriggerMatcherTest.java
| ... | ... | @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| 7 | 7 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionOperatorEnum; |
| 8 | 8 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum; |
| 9 | -import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.BaseMatcherTest; | |
| 9 | +import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.IotBaseConditionMatcherTest; | |
| 10 | 10 | import org.junit.jupiter.api.BeforeEach; |
| 11 | 11 | import org.junit.jupiter.api.Test; |
| 12 | 12 | |
| ... | ... | @@ -20,17 +20,17 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString |
| 20 | 20 | import static org.junit.jupiter.api.Assertions.*; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * {@link DevicePropertyPostTriggerMatcher} 的单元测试 | |
| 23 | + * {@link IotDevicePropertyPostTriggerMatcher} 的单元测试 | |
| 24 | 24 | * |
| 25 | 25 | * @author HUIHUI |
| 26 | 26 | */ |
| 27 | -public class DevicePropertyPostTriggerMatcherTest extends BaseMatcherTest { | |
| 27 | +public class IotDevicePropertyPostTriggerMatcherTest extends IotBaseConditionMatcherTest { | |
| 28 | 28 | |
| 29 | - private DevicePropertyPostTriggerMatcher matcher; | |
| 29 | + private IotDevicePropertyPostTriggerMatcher matcher; | |
| 30 | 30 | |
| 31 | 31 | @BeforeEach |
| 32 | 32 | public void setUp() { |
| 33 | - matcher = new DevicePropertyPostTriggerMatcher(); | |
| 33 | + matcher = new IotDevicePropertyPostTriggerMatcher(); | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | @Test | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/DeviceServiceInvokeTriggerMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotDeviceServiceInvokeTriggerMatcherTest.java
| ... | ... | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| 7 | 7 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum; |
| 8 | -import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.BaseMatcherTest; | |
| 8 | +import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.IotBaseConditionMatcherTest; | |
| 9 | 9 | import org.junit.jupiter.api.BeforeEach; |
| 10 | 10 | import org.junit.jupiter.api.Test; |
| 11 | 11 | |
| ... | ... | @@ -18,17 +18,17 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString |
| 18 | 18 | import static org.junit.jupiter.api.Assertions.*; |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * {@link DeviceServiceInvokeTriggerMatcher} 的单元测试 | |
| 21 | + * {@link IotDeviceServiceInvokeTriggerMatcher} 的单元测试 | |
| 22 | 22 | * |
| 23 | 23 | * @author HUIHUI |
| 24 | 24 | */ |
| 25 | -public class DeviceServiceInvokeTriggerMatcherTest extends BaseMatcherTest { | |
| 25 | +public class IotDeviceServiceInvokeTriggerMatcherTest extends IotBaseConditionMatcherTest { | |
| 26 | 26 | |
| 27 | - private DeviceServiceInvokeTriggerMatcher matcher; | |
| 27 | + private IotDeviceServiceInvokeTriggerMatcher matcher; | |
| 28 | 28 | |
| 29 | 29 | @BeforeEach |
| 30 | 30 | public void setUp() { |
| 31 | - matcher = new DeviceServiceInvokeTriggerMatcher(); | |
| 31 | + matcher = new IotDeviceServiceInvokeTriggerMatcher(); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | @Test | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/DeviceStateUpdateTriggerMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotDeviceStateUpdateTriggerMatcherTest.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.rule.scene.matcher.trigger; |
| 2 | 2 | |
| 3 | -import cn.hutool.extra.spring.SpringUtil; | |
| 4 | 3 | import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; |
| 5 | 4 | import cn.iocoder.yudao.module.iot.core.enums.IotDeviceStateEnum; |
| 6 | 5 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 7 | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| 8 | 7 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionOperatorEnum; |
| 9 | 8 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum; |
| 9 | +import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.IotBaseConditionMatcherTest; | |
| 10 | 10 | import org.junit.jupiter.api.BeforeEach; |
| 11 | 11 | import org.junit.jupiter.api.Test; |
| 12 | -import org.springframework.context.annotation.Bean; | |
| 13 | -import org.springframework.context.annotation.Configuration; | |
| 14 | -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; | |
| 15 | 12 | |
| 16 | 13 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; |
| 17 | 14 | import static org.junit.jupiter.api.Assertions.*; |
| 18 | 15 | |
| 19 | 16 | /** |
| 20 | - * {@link DeviceStateUpdateTriggerMatcher} 的单元测试 | |
| 17 | + * {@link IotDeviceStateUpdateTriggerMatcher} 的单元测试 | |
| 21 | 18 | * |
| 22 | 19 | * @author HUIHUI |
| 23 | 20 | */ |
| 24 | -@SpringJUnitConfig(DeviceStateUpdateTriggerMatcherTest.TestConfig.class) | |
| 25 | -public class DeviceStateUpdateTriggerMatcherTest { | |
| 26 | - | |
| 27 | - @Configuration | |
| 28 | - static class TestConfig { | |
| 29 | - @Bean | |
| 30 | - public SpringUtil springUtil() { | |
| 31 | - return new SpringUtil(); | |
| 32 | - } | |
| 33 | - } | |
| 21 | +public class IotDeviceStateUpdateTriggerMatcherTest extends IotBaseConditionMatcherTest { | |
| 34 | 22 | |
| 35 | - private DeviceStateUpdateTriggerMatcher matcher; | |
| 23 | + private IotDeviceStateUpdateTriggerMatcher matcher; | |
| 36 | 24 | |
| 37 | 25 | @BeforeEach |
| 38 | 26 | public void setUp() { |
| 39 | - matcher = new DeviceStateUpdateTriggerMatcher(); | |
| 27 | + matcher = new IotDeviceStateUpdateTriggerMatcher(); | |
| 40 | 28 | } |
| 41 | 29 | |
| 42 | 30 | @Test | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/TimerTriggerMatcherTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/trigger/IotTimerTriggerMatcherTest.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.service.rule.scene.matcher.trigger; |
| 3 | 3 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum; |
| 6 | -import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.BaseMatcherTest; | |
| 6 | +import cn.iocoder.yudao.module.iot.service.rule.scene.matcher.IotBaseConditionMatcherTest; | |
| 7 | 7 | import org.junit.jupiter.api.BeforeEach; |
| 8 | 8 | import org.junit.jupiter.api.Test; |
| 9 | 9 | |
| ... | ... | @@ -12,17 +12,17 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString |
| 12 | 12 | import static org.junit.jupiter.api.Assertions.*; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * {@link TimerTriggerMatcher} 的单元测试 | |
| 15 | + * {@link IotTimerTriggerMatcher} 的单元测试 | |
| 16 | 16 | * |
| 17 | 17 | * @author HUIHUI |
| 18 | 18 | */ |
| 19 | -public class TimerTriggerMatcherTest extends BaseMatcherTest { | |
| 19 | +public class IotTimerTriggerMatcherTest extends IotBaseConditionMatcherTest { | |
| 20 | 20 | |
| 21 | - private TimerTriggerMatcher matcher; | |
| 21 | + private IotTimerTriggerMatcher matcher; | |
| 22 | 22 | |
| 23 | 23 | @BeforeEach |
| 24 | 24 | public void setUp() { |
| 25 | - matcher = new TimerTriggerMatcher(); | |
| 25 | + matcher = new IotTimerTriggerMatcher(); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | @Test | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/timer/IotSceneRuleTimerHandlerTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.service.rule.scene.timer; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.ListUtil; | |
| 4 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; | |
| 5 | +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum; | |
| 6 | +import cn.iocoder.yudao.module.iot.framework.job.core.IotSchedulerManager; | |
| 7 | +import cn.iocoder.yudao.module.iot.job.rule.IotSceneRuleJob; | |
| 8 | +import org.junit.jupiter.api.BeforeEach; | |
| 9 | +import org.junit.jupiter.api.Test; | |
| 10 | +import org.junit.jupiter.api.extension.ExtendWith; | |
| 11 | +import org.mockito.InjectMocks; | |
| 12 | +import org.mockito.Mock; | |
| 13 | +import org.mockito.junit.jupiter.MockitoExtension; | |
| 14 | +import org.quartz.SchedulerException; | |
| 15 | + | |
| 16 | +import static org.mockito.ArgumentMatchers.any; | |
| 17 | +import static org.mockito.ArgumentMatchers.eq; | |
| 18 | +import static org.mockito.Mockito.*; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * {@link IotSceneRuleTimerHandler} 的单元测试类 | |
| 22 | + * | |
| 23 | + * @author HUIHUI | |
| 24 | + */ | |
| 25 | +@ExtendWith(MockitoExtension.class) | |
| 26 | +public class IotSceneRuleTimerHandlerTest { | |
| 27 | + | |
| 28 | + @Mock | |
| 29 | + private IotSchedulerManager schedulerManager; | |
| 30 | + | |
| 31 | + @InjectMocks | |
| 32 | + private IotSceneRuleTimerHandler timerHandler; | |
| 33 | + | |
| 34 | + @BeforeEach | |
| 35 | + void setUp() { | |
| 36 | + // 重置 Mock 对象 | |
| 37 | + reset(schedulerManager); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Test | |
| 41 | + public void testRegisterTimerTriggers_success() throws SchedulerException { | |
| 42 | + // 准备参数 | |
| 43 | + Long sceneRuleId = 1L; | |
| 44 | + IotSceneRuleDO sceneRule = new IotSceneRuleDO(); | |
| 45 | + sceneRule.setId(sceneRuleId); | |
| 46 | + sceneRule.setStatus(0); // 0 表示启用 | |
| 47 | + // 创建定时触发器 | |
| 48 | + IotSceneRuleDO.Trigger timerTrigger = new IotSceneRuleDO.Trigger(); | |
| 49 | + timerTrigger.setType(IotSceneRuleTriggerTypeEnum.TIMER.getType()); | |
| 50 | + timerTrigger.setCronExpression("0 0 12 * * ?"); // 每天中午12点 | |
| 51 | + sceneRule.setTriggers(ListUtil.toList(timerTrigger)); | |
| 52 | + | |
| 53 | + // 调用 | |
| 54 | + timerHandler.registerTimerTriggers(sceneRule); | |
| 55 | + | |
| 56 | + // 验证 | |
| 57 | + verify(schedulerManager, times(1)).addOrUpdateJob( | |
| 58 | + eq(IotSceneRuleJob.class), | |
| 59 | + eq("iot_scene_rule_timer_" + sceneRuleId), | |
| 60 | + eq("0 0 12 * * ?"), | |
| 61 | + eq(IotSceneRuleJob.buildJobDataMap(sceneRuleId)) | |
| 62 | + ); | |
| 63 | + } | |
| 64 | + | |
| 65 | + @Test | |
| 66 | + public void testRegisterTimerTriggers_noTimerTrigger() throws SchedulerException { | |
| 67 | + // 准备参数 - 没有定时触发器 | |
| 68 | + IotSceneRuleDO sceneRule = new IotSceneRuleDO(); | |
| 69 | + sceneRule.setStatus(0); // 0 表示启用 | |
| 70 | + // 创建非定时触发器 | |
| 71 | + IotSceneRuleDO.Trigger deviceTrigger = new IotSceneRuleDO.Trigger(); | |
| 72 | + deviceTrigger.setType(IotSceneRuleTriggerTypeEnum.DEVICE_PROPERTY_POST.getType()); | |
| 73 | + sceneRule.setTriggers(ListUtil.toList(deviceTrigger)); | |
| 74 | + | |
| 75 | + // 调用 | |
| 76 | + timerHandler.registerTimerTriggers(sceneRule); | |
| 77 | + | |
| 78 | + // 验证 - 不应该调用调度器 | |
| 79 | + verify(schedulerManager, never()).addOrUpdateJob(any(), any(), any(), any()); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @Test | |
| 83 | + public void testRegisterTimerTriggers_emptyCronExpression() throws SchedulerException { | |
| 84 | + // 准备参数 - CRON 表达式为空 | |
| 85 | + Long sceneRuleId = 2L; | |
| 86 | + IotSceneRuleDO sceneRule = new IotSceneRuleDO(); | |
| 87 | + sceneRule.setId(sceneRuleId); | |
| 88 | + sceneRule.setStatus(0); // 0 表示启用 | |
| 89 | + // 创建定时触发器但没有 CRON 表达式 | |
| 90 | + IotSceneRuleDO.Trigger timerTrigger = new IotSceneRuleDO.Trigger(); | |
| 91 | + timerTrigger.setType(IotSceneRuleTriggerTypeEnum.TIMER.getType()); | |
| 92 | + timerTrigger.setCronExpression(""); // 空的 CRON 表达式 | |
| 93 | + sceneRule.setTriggers(ListUtil.toList(timerTrigger)); | |
| 94 | + | |
| 95 | + // 调用 | |
| 96 | + timerHandler.registerTimerTriggers(sceneRule); | |
| 97 | + | |
| 98 | + // 验证 - 不应该调用调度器 | |
| 99 | + verify(schedulerManager, never()).addOrUpdateJob(any(), any(), any(), any()); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @Test | |
| 103 | + public void testUnregisterTimerTriggers_success() throws SchedulerException { | |
| 104 | + // 准备参数 | |
| 105 | + Long sceneRuleId = 3L; | |
| 106 | + | |
| 107 | + // 调用 | |
| 108 | + timerHandler.unregisterTimerTriggers(sceneRuleId); | |
| 109 | + | |
| 110 | + // 验证 | |
| 111 | + verify(schedulerManager, times(1)).deleteJob("iot_scene_rule_timer_" + sceneRuleId); | |
| 112 | + } | |
| 113 | + | |
| 114 | + @Test | |
| 115 | + public void testPauseTimerTriggers_success() throws SchedulerException { | |
| 116 | + // 准备参数 | |
| 117 | + Long sceneRuleId = 4L; | |
| 118 | + | |
| 119 | + // 调用 | |
| 120 | + timerHandler.pauseTimerTriggers(sceneRuleId); | |
| 121 | + | |
| 122 | + // 验证 | |
| 123 | + verify(schedulerManager, times(1)).pauseJob("iot_scene_rule_timer_" + sceneRuleId); | |
| 124 | + } | |
| 125 | + | |
| 126 | +} | ... | ... |