test(biz): 添加楼宇、电力环境设备及监控指标的单元测试
- 为 LcBuildingMapper 添加完整的增删改查单元测试 - 为 LcPowerEnvDeviceMapper 添加完整的增删改查单元测试 - 为 LcPowerEnvMonitorMetricMapper 添加完整的增删改查单元测试 - 验证实体类与数据库映射的正确性 - 确保基础数据操作功能稳定可靠
This commit is contained in:
@@ -0,0 +1,147 @@
|
|||||||
|
package com.jeelowcode.test.mapper;
|
||||||
|
|
||||||
|
import com.jeelowcode.module.biz.entity.LcBuildingEntity;
|
||||||
|
import com.jeelowcode.module.biz.mapper.LcBuildingMapper;
|
||||||
|
import com.jeelowcode.tool.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link LcBuildingMapper} 的单元测试类
|
||||||
|
*/
|
||||||
|
@Import(LcBuildingMapper.class)
|
||||||
|
public class LcBuildingMapperTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LcBuildingMapper lcBuildingMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInsert() {
|
||||||
|
// 准备数据
|
||||||
|
LcBuildingEntity entity = new LcBuildingEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setBuildingId("BUILDING_001");
|
||||||
|
entity.setBuildingName("测试楼宇");
|
||||||
|
entity.setCampusId("CAMPUS_001");
|
||||||
|
entity.setCampusName("测试园区");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
|
||||||
|
// 执行插入
|
||||||
|
int insertCount = lcBuildingMapper.insert(entity);
|
||||||
|
assertEquals(1, insertCount);
|
||||||
|
|
||||||
|
// 验证插入结果
|
||||||
|
LcBuildingEntity result = lcBuildingMapper.selectById(1L);
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("测试楼宇", result.getBuildingName());
|
||||||
|
assertEquals("测试园区", result.getCampusName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSelectList() {
|
||||||
|
// 准备数据
|
||||||
|
LcBuildingEntity entity1 = new LcBuildingEntity();
|
||||||
|
entity1.setId(1L);
|
||||||
|
entity1.setBuildingId("BUILDING_001");
|
||||||
|
entity1.setBuildingName("测试楼宇1");
|
||||||
|
entity1.setCampusId("CAMPUS_001");
|
||||||
|
entity1.setCampusName("测试园区1");
|
||||||
|
entity1.setTenantId(1L);
|
||||||
|
entity1.setCreateUser(1L);
|
||||||
|
entity1.setCreateTime(LocalDateTime.now());
|
||||||
|
entity1.setCreateDept(1L);
|
||||||
|
entity1.setUpdateUser(1L);
|
||||||
|
entity1.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity1.setIsDeleted(0);
|
||||||
|
lcBuildingMapper.insert(entity1);
|
||||||
|
|
||||||
|
LcBuildingEntity entity2 = new LcBuildingEntity();
|
||||||
|
entity2.setId(2L);
|
||||||
|
entity2.setBuildingId("BUILDING_002");
|
||||||
|
entity2.setBuildingName("测试楼宇2");
|
||||||
|
entity2.setCampusId("CAMPUS_001");
|
||||||
|
entity2.setCampusName("测试园区1");
|
||||||
|
entity2.setTenantId(1L);
|
||||||
|
entity2.setCreateUser(1L);
|
||||||
|
entity2.setCreateTime(LocalDateTime.now());
|
||||||
|
entity2.setCreateDept(1L);
|
||||||
|
entity2.setUpdateUser(1L);
|
||||||
|
entity2.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity2.setIsDeleted(0);
|
||||||
|
lcBuildingMapper.insert(entity2);
|
||||||
|
|
||||||
|
// 执行查询
|
||||||
|
List<LcBuildingEntity> result = lcBuildingMapper.selectList(null);
|
||||||
|
|
||||||
|
// 验证查询结果
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals(2, result.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
// 准备数据
|
||||||
|
LcBuildingEntity entity = new LcBuildingEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setBuildingId("BUILDING_001");
|
||||||
|
entity.setBuildingName("测试楼宇");
|
||||||
|
entity.setCampusId("CAMPUS_001");
|
||||||
|
entity.setCampusName("测试园区");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
lcBuildingMapper.insert(entity);
|
||||||
|
|
||||||
|
// 执行更新
|
||||||
|
entity.setBuildingName("更新后的楼宇名称");
|
||||||
|
int updateCount = lcBuildingMapper.updateById(entity);
|
||||||
|
assertEquals(1, updateCount);
|
||||||
|
|
||||||
|
// 验证更新结果
|
||||||
|
LcBuildingEntity result = lcBuildingMapper.selectById(1L);
|
||||||
|
assertEquals("更新后的楼宇名称", result.getBuildingName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDelete() {
|
||||||
|
// 准备数据
|
||||||
|
LcBuildingEntity entity = new LcBuildingEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setBuildingId("BUILDING_001");
|
||||||
|
entity.setBuildingName("测试楼宇");
|
||||||
|
entity.setCampusId("CAMPUS_001");
|
||||||
|
entity.setCampusName("测试园区");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
lcBuildingMapper.insert(entity);
|
||||||
|
|
||||||
|
// 执行删除
|
||||||
|
int deleteCount = lcBuildingMapper.deleteById(1L);
|
||||||
|
assertEquals(1, deleteCount);
|
||||||
|
|
||||||
|
// 验证删除结果
|
||||||
|
LcBuildingEntity result = lcBuildingMapper.selectById(1L);
|
||||||
|
assertNull(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
package com.jeelowcode.test.mapper;
|
||||||
|
|
||||||
|
import com.jeelowcode.module.biz.entity.LcPowerEnvDeviceEntity;
|
||||||
|
import com.jeelowcode.module.biz.mapper.LcPowerEnvDeviceMapper;
|
||||||
|
import com.jeelowcode.tool.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link LcPowerEnvDeviceMapper} 的单元测试类
|
||||||
|
*/
|
||||||
|
@Import(LcPowerEnvDeviceMapper.class)
|
||||||
|
public class LcPowerEnvDeviceMapperTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LcPowerEnvDeviceMapper lcPowerEnvDeviceMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInsert() {
|
||||||
|
// 准备数据
|
||||||
|
LcPowerEnvDeviceEntity entity = new LcPowerEnvDeviceEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setDeviceUid("DEVICE_UID_001");
|
||||||
|
entity.setDeviceCode("DEVICE_CODE_001");
|
||||||
|
entity.setDeviceTypeCode("TYPE_001");
|
||||||
|
entity.setDeviceTypeName("温度传感器");
|
||||||
|
entity.setBuildingId("BUILDING_001");
|
||||||
|
entity.setBuildingName("测试楼宇");
|
||||||
|
entity.setCampusId("CAMPUS_001");
|
||||||
|
entity.setCampusName("测试园区");
|
||||||
|
entity.setMonitorData("{\"temperature\": 25.6}");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
|
||||||
|
// 执行插入
|
||||||
|
int insertCount = lcPowerEnvDeviceMapper.insert(entity);
|
||||||
|
assertEquals(1, insertCount);
|
||||||
|
|
||||||
|
// 验证插入结果
|
||||||
|
LcPowerEnvDeviceEntity result = lcPowerEnvDeviceMapper.selectById(1L);
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("DEVICE_UID_001", result.getDeviceUid());
|
||||||
|
assertEquals("温度传感器", result.getDeviceTypeName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSelectById() {
|
||||||
|
// 准备数据
|
||||||
|
LcPowerEnvDeviceEntity entity = new LcPowerEnvDeviceEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setDeviceUid("DEVICE_UID_001");
|
||||||
|
entity.setDeviceCode("DEVICE_CODE_001");
|
||||||
|
entity.setDeviceTypeCode("TYPE_001");
|
||||||
|
entity.setDeviceTypeName("温度传感器");
|
||||||
|
entity.setBuildingId("BUILDING_001");
|
||||||
|
entity.setBuildingName("测试楼宇");
|
||||||
|
entity.setCampusId("CAMPUS_001");
|
||||||
|
entity.setCampusName("测试园区");
|
||||||
|
entity.setMonitorData("{\"temperature\": 25.6}");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
lcPowerEnvDeviceMapper.insert(entity);
|
||||||
|
|
||||||
|
// 执行查询
|
||||||
|
LcPowerEnvDeviceEntity result = lcPowerEnvDeviceMapper.selectById(1L);
|
||||||
|
|
||||||
|
// 验证查询结果
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("DEVICE_UID_001", result.getDeviceUid());
|
||||||
|
assertEquals("温度传感器", result.getDeviceTypeName());
|
||||||
|
assertEquals("测试楼宇", result.getBuildingName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
// 准备数据
|
||||||
|
LcPowerEnvDeviceEntity entity = new LcPowerEnvDeviceEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setDeviceUid("DEVICE_UID_001");
|
||||||
|
entity.setDeviceCode("DEVICE_CODE_001");
|
||||||
|
entity.setDeviceTypeCode("TYPE_001");
|
||||||
|
entity.setDeviceTypeName("温度传感器");
|
||||||
|
entity.setBuildingId("BUILDING_001");
|
||||||
|
entity.setBuildingName("测试楼宇");
|
||||||
|
entity.setCampusId("CAMPUS_001");
|
||||||
|
entity.setCampusName("测试园区");
|
||||||
|
entity.setMonitorData("{\"temperature\": 25.6}");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
lcPowerEnvDeviceMapper.insert(entity);
|
||||||
|
|
||||||
|
// 执行更新
|
||||||
|
entity.setDeviceTypeName("湿度传感器");
|
||||||
|
int updateCount = lcPowerEnvDeviceMapper.updateById(entity);
|
||||||
|
assertEquals(1, updateCount);
|
||||||
|
|
||||||
|
// 验证更新结果
|
||||||
|
LcPowerEnvDeviceEntity result = lcPowerEnvDeviceMapper.selectById(1L);
|
||||||
|
assertEquals("湿度传感器", result.getDeviceTypeName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDelete() {
|
||||||
|
// 准备数据
|
||||||
|
LcPowerEnvDeviceEntity entity = new LcPowerEnvDeviceEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setDeviceUid("DEVICE_UID_001");
|
||||||
|
entity.setDeviceCode("DEVICE_CODE_001");
|
||||||
|
entity.setDeviceTypeCode("TYPE_001");
|
||||||
|
entity.setDeviceTypeName("温度传感器");
|
||||||
|
entity.setBuildingId("BUILDING_001");
|
||||||
|
entity.setBuildingName("测试楼宇");
|
||||||
|
entity.setCampusId("CAMPUS_001");
|
||||||
|
entity.setCampusName("测试园区");
|
||||||
|
entity.setMonitorData("{\"temperature\": 25.6}");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
lcPowerEnvDeviceMapper.insert(entity);
|
||||||
|
|
||||||
|
// 执行删除
|
||||||
|
int deleteCount = lcPowerEnvDeviceMapper.deleteById(1L);
|
||||||
|
assertEquals(1, deleteCount);
|
||||||
|
|
||||||
|
// 验证删除结果
|
||||||
|
LcPowerEnvDeviceEntity result = lcPowerEnvDeviceMapper.selectById(1L);
|
||||||
|
assertNull(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
package com.jeelowcode.test.mapper;
|
||||||
|
|
||||||
|
import com.jeelowcode.module.biz.entity.LcPowerEnvMonitorMetricEntity;
|
||||||
|
import com.jeelowcode.module.biz.mapper.LcPowerEnvMonitorMetricMapper;
|
||||||
|
import com.jeelowcode.tool.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link LcPowerEnvMonitorMetricMapper} 的单元测试类
|
||||||
|
*/
|
||||||
|
@Import(LcPowerEnvMonitorMetricMapper.class)
|
||||||
|
public class LcPowerEnvMonitorMetricMapperTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LcPowerEnvMonitorMetricMapper lcPowerEnvMonitorMetricMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInsert() {
|
||||||
|
// 准备数据
|
||||||
|
LcPowerEnvMonitorMetricEntity entity = new LcPowerEnvMonitorMetricEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setDeviceUid("DEVICE_UID_001");
|
||||||
|
entity.setMetadataUid("METADATA_UID_001");
|
||||||
|
entity.setMetadataCode("METADATA_CODE_001");
|
||||||
|
entity.setMetadataName("温度");
|
||||||
|
entity.setPropertyCode("PROPERTY_TEMP");
|
||||||
|
entity.setPropertyName("温度值");
|
||||||
|
entity.setUnitCode("℃");
|
||||||
|
entity.setValueType(1);
|
||||||
|
entity.setValueTypeName("数值型");
|
||||||
|
entity.setPointType(1);
|
||||||
|
entity.setPointTypeName("模拟量");
|
||||||
|
entity.setMetricValue("26.5");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
|
||||||
|
// 执行插入
|
||||||
|
int insertCount = lcPowerEnvMonitorMetricMapper.insert(entity);
|
||||||
|
assertEquals(1, insertCount);
|
||||||
|
|
||||||
|
// 验证插入结果
|
||||||
|
LcPowerEnvMonitorMetricEntity result = lcPowerEnvMonitorMetricMapper.selectById(1L);
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("DEVICE_UID_001", result.getDeviceUid());
|
||||||
|
assertEquals("26.5", result.getMetricValue());
|
||||||
|
assertEquals("℃", result.getUnitCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSelectById() {
|
||||||
|
// 准备数据
|
||||||
|
LcPowerEnvMonitorMetricEntity entity = new LcPowerEnvMonitorMetricEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setDeviceUid("DEVICE_UID_001");
|
||||||
|
entity.setMetadataUid("METADATA_UID_001");
|
||||||
|
entity.setMetadataCode("METADATA_CODE_001");
|
||||||
|
entity.setMetadataName("温度");
|
||||||
|
entity.setPropertyCode("PROPERTY_TEMP");
|
||||||
|
entity.setPropertyName("温度值");
|
||||||
|
entity.setUnitCode("℃");
|
||||||
|
entity.setValueType(1);
|
||||||
|
entity.setValueTypeName("数值型");
|
||||||
|
entity.setPointType(1);
|
||||||
|
entity.setPointTypeName("模拟量");
|
||||||
|
entity.setMetricValue("26.5");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
lcPowerEnvMonitorMetricMapper.insert(entity);
|
||||||
|
|
||||||
|
// 执行查询
|
||||||
|
LcPowerEnvMonitorMetricEntity result = lcPowerEnvMonitorMetricMapper.selectById(1L);
|
||||||
|
|
||||||
|
// 验证查询结果
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("温度", result.getMetadataName());
|
||||||
|
assertEquals("温度值", result.getPropertyName());
|
||||||
|
assertEquals(1, result.getValueType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
// 准备数据
|
||||||
|
LcPowerEnvMonitorMetricEntity entity = new LcPowerEnvMonitorMetricEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setDeviceUid("DEVICE_UID_001");
|
||||||
|
entity.setMetadataUid("METADATA_UID_001");
|
||||||
|
entity.setMetadataCode("METADATA_CODE_001");
|
||||||
|
entity.setMetadataName("温度");
|
||||||
|
entity.setPropertyCode("PROPERTY_TEMP");
|
||||||
|
entity.setPropertyName("温度值");
|
||||||
|
entity.setUnitCode("℃");
|
||||||
|
entity.setValueType(1);
|
||||||
|
entity.setValueTypeName("数值型");
|
||||||
|
entity.setPointType(1);
|
||||||
|
entity.setPointTypeName("模拟量");
|
||||||
|
entity.setMetricValue("26.5");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
lcPowerEnvMonitorMetricMapper.insert(entity);
|
||||||
|
|
||||||
|
// 执行更新
|
||||||
|
entity.setMetricValue("27.8");
|
||||||
|
int updateCount = lcPowerEnvMonitorMetricMapper.updateById(entity);
|
||||||
|
assertEquals(1, updateCount);
|
||||||
|
|
||||||
|
// 验证更新结果
|
||||||
|
LcPowerEnvMonitorMetricEntity result = lcPowerEnvMonitorMetricMapper.selectById(1L);
|
||||||
|
assertEquals("27.8", result.getMetricValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDelete() {
|
||||||
|
// 准备数据
|
||||||
|
LcPowerEnvMonitorMetricEntity entity = new LcPowerEnvMonitorMetricEntity();
|
||||||
|
entity.setId(1L);
|
||||||
|
entity.setDeviceUid("DEVICE_UID_001");
|
||||||
|
entity.setMetadataUid("METADATA_UID_001");
|
||||||
|
entity.setMetadataCode("METADATA_CODE_001");
|
||||||
|
entity.setMetadataName("温度");
|
||||||
|
entity.setPropertyCode("PROPERTY_TEMP");
|
||||||
|
entity.setPropertyName("温度值");
|
||||||
|
entity.setUnitCode("℃");
|
||||||
|
entity.setValueType(1);
|
||||||
|
entity.setValueTypeName("数值型");
|
||||||
|
entity.setPointType(1);
|
||||||
|
entity.setPointTypeName("模拟量");
|
||||||
|
entity.setMetricValue("26.5");
|
||||||
|
entity.setTenantId(1L);
|
||||||
|
entity.setCreateUser(1L);
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
entity.setCreateDept(1L);
|
||||||
|
entity.setUpdateUser(1L);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
entity.setIsDeleted(0);
|
||||||
|
lcPowerEnvMonitorMetricMapper.insert(entity);
|
||||||
|
|
||||||
|
// 执行删除
|
||||||
|
int deleteCount = lcPowerEnvMonitorMetricMapper.deleteById(1L);
|
||||||
|
assertEquals(1, deleteCount);
|
||||||
|
|
||||||
|
// 验证删除结果
|
||||||
|
LcPowerEnvMonitorMetricEntity result = lcPowerEnvMonitorMetricMapper.selectById(1L);
|
||||||
|
assertNull(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user