refactor(test): 重构测试用例并添加备注字段
- 在 DeviceServiceTest、EventServiceTest、ParamServiceTest、PropertyServiceTest 和 ServeServiceTest 中添加备注字段- 移除了未使用的导入语句 - 删除了 UserServiceTest 中的注释代码
This commit is contained in:
parent
c97e485305
commit
5e49367cf5
@ -52,13 +52,13 @@ public class DeviceServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createProduct() {
|
void createProduct() {
|
||||||
DeviceDto dto = new DeviceDto("DEVICE_3", null, null, null, null, 121L);
|
DeviceDto dto = new DeviceDto("DEVICE_3", null, null, null, null, 121L, "备注");
|
||||||
Device device = service.create(dto);
|
Device device = service.create(dto);
|
||||||
assertNotNull(device);
|
assertNotNull(device);
|
||||||
List<Device> devices = service.list(new LambdaQueryWrapper<Device>().like(Device::getName, "DEVICE"));
|
List<Device> devices = service.list(new LambdaQueryWrapper<Device>().like(Device::getName, "DEVICE"));
|
||||||
assertEquals(3, devices.size());
|
assertEquals(3, devices.size());
|
||||||
// 不能创建其他已存在的同名同代码部门
|
// 不能创建其他已存在的同名同代码部门
|
||||||
DeviceDto dto2 = new DeviceDto(device2.getName(), null, null, null, null, 121L);
|
DeviceDto dto2 = new DeviceDto(device2.getName(), null, null, null, null, 121L, "备注");
|
||||||
assertThrows(ConstraintException.class, () -> service.create(dto2));
|
assertThrows(ConstraintException.class, () -> service.create(dto2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,13 +64,13 @@ public class EventServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createProduct() {
|
void createProduct() {
|
||||||
EventDto dto = new EventDto(121L, "EVENT_3", "测试3", Event.Type.ACTIVE, createParam());
|
EventDto dto = new EventDto(121L, "EVENT_3", "测试3", "备注", Event.Type.ACTIVE, createParam());
|
||||||
Event Event = service.create(dto);
|
Event Event = service.create(dto);
|
||||||
assertNotNull(Event);
|
assertNotNull(Event);
|
||||||
List<Event> events = service.list(new QueryWrapper<Event>().like("name", "EVENT"));
|
List<Event> events = service.list(new QueryWrapper<Event>().like("name", "EVENT"));
|
||||||
assertEquals(3, events.size());
|
assertEquals(3, events.size());
|
||||||
// 不能创建其他已存在的同名同代码部门
|
// 不能创建其他已存在的同名同代码部门
|
||||||
EventDto dto2 = new EventDto(121L, event2.getName(), "测试1", null, null);
|
EventDto dto2 = new EventDto(121L, event2.getName(), "测试1", "备注", null, null);
|
||||||
assertThrows(ConstraintException.class, () -> service.create(dto2));
|
assertThrows(ConstraintException.class, () -> service.create(dto2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class ParamServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createParams() {
|
void createParams() {
|
||||||
ParamDto dto = new ParamDto("PARAM_NAME_3", "测试1", DataType.DATE, Param.Type.OUTPUT);
|
ParamDto dto = new ParamDto("PARAM_NAME_3", "测试1", "备注", DataType.DATE, Param.Type.OUTPUT);
|
||||||
List<ParamDto> params = new ArrayList<>();
|
List<ParamDto> params = new ArrayList<>();
|
||||||
params.add(dto);
|
params.add(dto);
|
||||||
Long foreignId = 1L;
|
Long foreignId = 1L;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.zsc.edu.gateway.service.iot;
|
package com.zsc.edu.gateway.service.iot;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.zsc.edu.gateway.domain.iot.ParamBuilder;
|
|
||||||
import com.zsc.edu.gateway.domain.iot.ProductBuilder;
|
import com.zsc.edu.gateway.domain.iot.ProductBuilder;
|
||||||
import com.zsc.edu.gateway.exception.ConstraintException;
|
import com.zsc.edu.gateway.exception.ConstraintException;
|
||||||
import com.zsc.edu.gateway.modules.iot.product.dto.ProductDto;
|
import com.zsc.edu.gateway.modules.iot.product.dto.ProductDto;
|
||||||
@ -12,7 +11,6 @@ import com.zsc.edu.gateway.modules.iot.tsl.dto.ParamDto;
|
|||||||
import com.zsc.edu.gateway.modules.iot.tsl.entity.DataType;
|
import com.zsc.edu.gateway.modules.iot.tsl.entity.DataType;
|
||||||
import com.zsc.edu.gateway.modules.iot.tsl.entity.Param;
|
import com.zsc.edu.gateway.modules.iot.tsl.entity.Param;
|
||||||
import com.zsc.edu.gateway.modules.iot.tsl.repo.ParamRepository;
|
import com.zsc.edu.gateway.modules.iot.tsl.repo.ParamRepository;
|
||||||
import com.zsc.edu.gateway.modules.iot.tsl.service.ParamService;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -53,7 +53,7 @@ public class PropertyServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createProduct() {
|
void createProduct() {
|
||||||
PropertyDto dto = new PropertyDto(121L, "PROPERTY_3", "测试3", null, null);
|
PropertyDto dto = new PropertyDto(121L, "PROPERTY_3", "测试3", "测试", null, null);
|
||||||
Property property = service.create(dto);
|
Property property = service.create(dto);
|
||||||
assertNotNull(property);
|
assertNotNull(property);
|
||||||
List<Property> properties = service.list(new LambdaQueryWrapper<Property>().like(Property::getName, "PROPERTY"));
|
List<Property> properties = service.list(new LambdaQueryWrapper<Property>().like(Property::getName, "PROPERTY"));
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package com.zsc.edu.gateway.service.iot;
|
package com.zsc.edu.gateway.service.iot;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.zsc.edu.gateway.domain.iot.ProductBuilder;
|
|
||||||
import com.zsc.edu.gateway.domain.iot.ServeBuilder;
|
import com.zsc.edu.gateway.domain.iot.ServeBuilder;
|
||||||
import com.zsc.edu.gateway.exception.ConstraintException;
|
import com.zsc.edu.gateway.exception.ConstraintException;
|
||||||
import com.zsc.edu.gateway.modules.iot.product.dto.ProductDto;
|
|
||||||
import com.zsc.edu.gateway.modules.iot.product.entity.Product;
|
|
||||||
import com.zsc.edu.gateway.modules.iot.tsl.dto.ParamDto;
|
import com.zsc.edu.gateway.modules.iot.tsl.dto.ParamDto;
|
||||||
import com.zsc.edu.gateway.modules.iot.tsl.dto.ServeDto;
|
import com.zsc.edu.gateway.modules.iot.tsl.dto.ServeDto;
|
||||||
import com.zsc.edu.gateway.modules.iot.tsl.entity.DataType;
|
import com.zsc.edu.gateway.modules.iot.tsl.entity.DataType;
|
||||||
@ -63,13 +60,13 @@ public class ServeServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createProduct() {
|
void createProduct() {
|
||||||
ServeDto dto = new ServeDto(121L, "SERVE_3", "测试3", createParam(), createParam());
|
ServeDto dto = new ServeDto(121L, "SERVE_3", "测试3", "备注", createParam(), createParam());
|
||||||
Serve serve = service.create(dto);
|
Serve serve = service.create(dto);
|
||||||
assertNotNull(serve);
|
assertNotNull(serve);
|
||||||
List<Serve> serves = service.list(new LambdaQueryWrapper<Serve>().like(Serve::getName, "SERVE"));
|
List<Serve> serves = service.list(new LambdaQueryWrapper<Serve>().like(Serve::getName, "SERVE"));
|
||||||
assertEquals(3, serves.size());
|
assertEquals(3, serves.size());
|
||||||
// 不能创建其他已存在的同名同代码部门
|
// 不能创建其他已存在的同名同代码部门
|
||||||
ServeDto dto2 = new ServeDto(121L, serve2.getName(), "测试1", null, null);
|
ServeDto dto2 = new ServeDto(121L, serve2.getName(), "测试1", "备注", null, null);
|
||||||
assertThrows(ConstraintException.class, () -> service.create(dto2));
|
assertThrows(ConstraintException.class, () -> service.create(dto2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,19 +109,4 @@ public class UserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Test
|
|
||||||
// void test() {
|
|
||||||
// User user=userRepository.selectByUsername("admin");
|
|
||||||
// Set<Authority> authorities= authorityRepository.selectAuthoritiesByRoleId(user.getRoleId());
|
|
||||||
// user.role.authorities=authorities;
|
|
||||||
// System.out.println(user);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// @Test
|
|
||||||
// void test1() {
|
|
||||||
//// User user=userRepository.selectByUsername("admin");
|
|
||||||
//// System.out.println(user);
|
|
||||||
// String admin = passwordEncoder.encode("admin");
|
|
||||||
// System.out.println(admin);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user