【代码评审】IoT:数据桥梁的接入
This commit is contained in:
parent
3191d1bd1a
commit
3b85adc754
|
@ -112,6 +112,21 @@
|
|||
<version>24.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TODO @芋艿:合理注释 -->
|
||||
<!-- IoT 数据桥梁的执行器所需消息队列。如果您只需要使用 rocketmq 那么则注释掉其它消息队列即可 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.rocketmq</groupId>-->
|
||||
<!-- <artifactId>rocketmq-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.kafka</groupId>-->
|
||||
<!-- <artifactId>spring-kafka</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-amqp</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeTypeEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import lombok.Data;
|
||||
|
@ -7,7 +8,7 @@ import lombok.Data;
|
|||
/**
|
||||
* 抽象类 IotDataBridgeConfig
|
||||
*
|
||||
* 用于表示数据桥梁配置数据的通用类型,根据具体的 "type" 字段动态映射到对应的子类。
|
||||
* 用于表示数据桥梁配置数据的通用类型,根据具体的 "type" 字段动态映射到对应的子类
|
||||
* 提供多态支持,适用于不同类型的数据结构序列化和反序列化场景。
|
||||
*
|
||||
* @author HUIHUI
|
||||
|
@ -26,6 +27,8 @@ public abstract class IotDataBridgeAbstractConfig {
|
|||
|
||||
/**
|
||||
* 配置类型
|
||||
*
|
||||
* 枚举 {@link IotDataBridgeTypeEnum#getType()}
|
||||
*/
|
||||
private String type;
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.junit.jupiter.api.Disabled;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -20,6 +19,7 @@ import java.time.LocalDateTime;
|
|||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* {@link IotDataBridgeExecute} 实现类的测试
|
||||
|
@ -41,20 +41,14 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest {
|
|||
@BeforeEach
|
||||
public void setUp() {
|
||||
// 创建共享的测试消息
|
||||
message = IotDeviceMessage.builder()
|
||||
.requestId("TEST-001")
|
||||
.productKey("testProduct")
|
||||
.deviceName("testDevice")
|
||||
.deviceKey("testDeviceKey")
|
||||
.type("property")
|
||||
.identifier("temperature")
|
||||
.data("{\"value\": 60}")
|
||||
.reportTime(LocalDateTime.now())
|
||||
.tenantId(1L)
|
||||
message = IotDeviceMessage.builder().requestId("TEST-001").reportTime(LocalDateTime.now()).tenantId(1L)
|
||||
.productKey("testProduct").deviceName("testDevice").deviceKey("testDeviceKey")
|
||||
.type("property").identifier("temperature").data("{\"value\": 60}")
|
||||
.build();
|
||||
|
||||
// 配置 RestTemplate mock 返回成功响应
|
||||
Mockito.when(restTemplate.exchange(anyString(), any(HttpMethod.class), any(), any(Class.class)))
|
||||
// TODO @puhui999:这个应该放到 testHttpDataBridge 里
|
||||
when(restTemplate.exchange(anyString(), any(HttpMethod.class), any(), any(Class.class)))
|
||||
.thenReturn(new ResponseEntity<>("Success", HttpStatus.OK));
|
||||
}
|
||||
|
||||
|
@ -64,6 +58,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest {
|
|||
IotKafkaMQDataBridgeExecute action = new IotKafkaMQDataBridgeExecute();
|
||||
|
||||
// 2. 创建配置
|
||||
// TODO @puhui999:可以改成链式哈。
|
||||
IotDataBridgeKafkaMQConfig config = new IotDataBridgeKafkaMQConfig();
|
||||
config.setBootstrapServers("127.0.0.1:9092");
|
||||
config.setTopic("test-topic");
|
||||
|
|
|
@ -114,19 +114,6 @@
|
|||
<artifactId>yudao-module-iot-biz</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- IoT 数据桥梁的执行器所需消息队列。如果您只需要使用 rocketmq 那么则注释掉其它消息队列即可 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.rocketmq</groupId>-->
|
||||
<!-- <artifactId>rocketmq-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.kafka</groupId>-->
|
||||
<!-- <artifactId>spring-kafka</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-amqp</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- spring boot 配置所需依赖 -->
|
||||
<dependency>
|
||||
|
|
Loading…
Reference in New Issue