依赖包版本升级
This commit is contained in:
@@ -1,120 +0,0 @@
|
||||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.service.IDeviceAlarmService;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
class DeviceAlarmServiceImplTest {
|
||||
|
||||
@Resource
|
||||
private IDeviceAlarmService deviceAlarmService;
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void getAllAlarm() {
|
||||
// deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111",null,null,null, null, null);
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, null, null, null, null,
|
||||
// null, null).getSize());
|
||||
//
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", null, null, null,
|
||||
// null, null).getSize());
|
||||
//
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", "1", null, null,
|
||||
// null, null).getSize());
|
||||
//
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", "2", null, null,
|
||||
// null, null).getSize());
|
||||
//
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", "3", null, null,
|
||||
// null, null).getSize());
|
||||
//
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", "4", null, null,
|
||||
// null, null).getSize());
|
||||
//
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", "5", null, null,
|
||||
// null, null).getSize());
|
||||
//
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", null, "1", null,
|
||||
// null, null).getSize());
|
||||
|
||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", null, "1", null,
|
||||
// null, null).getSize());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void add() {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
DeviceAlarm deviceAlarm = new DeviceAlarm();
|
||||
deviceAlarm.setDeviceId("11111111111111111111");
|
||||
deviceAlarm.setAlarmDescription("test_" + i);
|
||||
|
||||
/**
|
||||
* 报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,
|
||||
* * 7其他报警;可以为直接组合如12为电话报警或 设备报警-
|
||||
*/
|
||||
deviceAlarm.setAlarmMethod((int)(Math.random()*7 + 1) + "");
|
||||
Instant date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00");
|
||||
deviceAlarm.setAlarmTime(DateUtil.formatter.format(date));
|
||||
/**
|
||||
* 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级 警情-
|
||||
*/
|
||||
deviceAlarm.setAlarmPriority((int)(Math.random()*4 + 1) + "");
|
||||
deviceAlarm.setLongitude(116.325);
|
||||
deviceAlarm.setLatitude(39.562);
|
||||
deviceAlarmService.add(deviceAlarm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void clearAlarmBeforeTime() {
|
||||
deviceAlarmService.clearAlarmBeforeTime(null,null, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private Instant randomDate(String beginDate, String endDate) {
|
||||
try {
|
||||
|
||||
//构造开始日期
|
||||
LocalDateTime start = LocalDateTime.parse(beginDate, DateUtil.formatter);
|
||||
|
||||
//构造结束日期
|
||||
LocalDateTime end = LocalDateTime.parse(endDate, DateUtil.formatter);
|
||||
//getTime()表示返回自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象表示的毫秒数。
|
||||
if (start.isAfter(end)) {
|
||||
return null;
|
||||
}
|
||||
long date = random(start.toInstant(ZoneOffset.of("+8")).toEpochMilli(), end.toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
||||
return Instant.ofEpochMilli(date);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static long random(long begin, long end) {
|
||||
long rtn = begin + (long) (Math.random() * (end - begin));
|
||||
//如果返回的是开始时间和结束时间,则递归调用本函数查找随机值
|
||||
if (rtn == begin || rtn == end) {
|
||||
return random(begin, end);
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.service.IRoleService;
|
||||
import com.genersoft.iot.vmp.service.IUserService;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.Role;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
class RoleServiceImplTest {
|
||||
|
||||
@Resource
|
||||
private IRoleService roleService;
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void getAllUser() {
|
||||
List<Role> all = roleService.getAll();
|
||||
Role roleById = roleService.getRoleById(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void add() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Role role = new Role();
|
||||
role.setName("test+" + i);
|
||||
role.setAuthority("adadadda");
|
||||
role.setCreateTime(DateUtil.getNow());
|
||||
role.setUpdateTime(DateUtil.getNow());
|
||||
roleService.add(role);
|
||||
}
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void delete() {
|
||||
roleService.delete(20);
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void update() {
|
||||
Role role = new Role();
|
||||
role.setId(21);
|
||||
role.setName("TTTTTT");
|
||||
role.setAuthority("adadadda");
|
||||
roleService.update(role);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.service.IUserService;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.Role;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
class UserServiceImplTest {
|
||||
|
||||
@Resource
|
||||
private IUserService userService;
|
||||
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void getAllUser() {
|
||||
List<User> allUsers = userService.getAllUsers();
|
||||
User admin = userService.getUser("admin", "21232f297a57a5a743894a0e4a801fc3");
|
||||
User admin1 = userService.getUserByUsername("admin");
|
||||
}
|
||||
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void add() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
User user = new User();
|
||||
user.setUsername("admin_" + i);
|
||||
user.setPassword("admin_password_" + i);
|
||||
|
||||
Role role = new Role();
|
||||
role.setId(1);
|
||||
user.setRole(role);
|
||||
user.setCreateTime(DateUtil.getNow());
|
||||
user.setUpdateTime(DateUtil.getNow());
|
||||
userService.addUser(user);
|
||||
}
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void delete() {
|
||||
userService.deleteUser(1002);
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
void update() {
|
||||
User user = new User();
|
||||
user.setId(11);
|
||||
user.setUsername("update" );
|
||||
user.setPassword("update");
|
||||
Role role = new Role();
|
||||
role.setId(2);
|
||||
user.setRole(role);
|
||||
user.setUpdateTime(DateUtil.getNow());
|
||||
userService.updateUsers(user);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user