TestDeviceLocationUtil.java
4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package cn.com.glsx.stdinterface.modules.util;
import cn.com.glsx.stdinterface.common.constants.Constants;
import cn.hutool.core.date.DateUtil;
import org.junit.Assert;
import org.junit.Test;
import java.util.Date;
public class TestDeviceLocationUtil {
@Test
public void testDeviceType01() {
// 无效位置数据状态验证
String gpsTime = "";
String bsTime = "";
Integer source = null;
Integer deviceType = DeviceLocationUtil.resolutionGpsType(gpsTime, bsTime, source);
Assert.assertSame(deviceType, Constants.Verification.SN_INVALID);
}
@Test
public void testDeviceType02() {
// 无效位置数据状态验证;不存在的设备类型source
String gpsTime = "";
String bsTime = "";
Integer source = 2;
Integer deviceType = DeviceLocationUtil.resolutionGpsType(gpsTime, bsTime, source);
Assert.assertSame(deviceType, Constants.Verification.SN_INVALID);
}
@Test
public void testDeviceType03() {
// 有线设备:无效位置数据状态验证,4小时内上报的数据为有效
Date gpsDate = DateUtil.offsetHour(new Date(), -4);
String gpsTime = DateUtils.toString(gpsDate, DateUtils.pattern19);
String bsTime = "";
Integer source = Constants.DeviceSource.WIRED;
Integer deviceType = DeviceLocationUtil.resolutionGpsType(gpsTime, bsTime, source);
Assert.assertSame(deviceType, Constants.Verification.SN_INVALID);
}
@Test
public void testDeviceType04() {
// 有线设备:无效位置数据状态验证,4小时内上报的数据为有效
// 有线设备只做GPS数据的验证
Date gpsDate = DateUtil.offsetHour(new Date(), -5);
String gpsTime = DateUtils.toString(gpsDate, DateUtils.pattern19);
String bsTime = "2022-02-23 09:16:17";
Integer source = Constants.DeviceSource.WIRED;
Integer deviceType = DeviceLocationUtil.resolutionGpsType(gpsTime, bsTime, source);
Assert.assertSame(deviceType, Constants.Verification.SN_INVALID);
}
@Test
public void testDeviceType05() {
// 有线设备:有效位置数据状态验证,4小时内上报的数据为有效
// 有线设备只做GPS数据的验证
Date gpsDate = DateUtil.offsetHour(new Date(), -3);
String gpsTime = DateUtils.toString(gpsDate, DateUtils.pattern19);
String bsTime = "2022-02-23 09:16:17";
Integer source = Constants.DeviceSource.WIRED;
Integer deviceType = DeviceLocationUtil.resolutionGpsType(gpsTime, bsTime, source);
Assert.assertSame(deviceType, Constants.Verification.SN_VALID);
}
@Test
public void testDeviceType06() {
// 无线设备:无效位置数据状态验证,24小时内上报的数据为有效
// 无线设备GPS和基站数据取最新的数据
Date gpsDate = DateUtil.offsetHour(new Date(), -25);
Date bsDate = DateUtil.offsetHour(new Date(), -25);
String gpsTime = DateUtils.toString(gpsDate, DateUtils.pattern19);
String bsTime = DateUtils.toString(bsDate, DateUtils.pattern19);
Integer source = Constants.DeviceSource.WIRELESS;
Integer deviceType = DeviceLocationUtil.resolutionGpsType(gpsTime, bsTime, source);
Assert.assertSame(deviceType, Constants.Verification.SN_INVALID);
}
@Test
public void testDeviceType07() {
// 无线设备:有效位置数据状态验证,24小时内上报的数据为有效
// 无线设备GPS和基站数据取最新的数据
Date gpsDate = DateUtil.offsetHour(new Date(), -25);
Date bsDate = DateUtil.offsetHour(new Date(), -5);
String gpsTime = DateUtils.toString(gpsDate, DateUtils.pattern19);
String bsTime = DateUtils.toString(bsDate, DateUtils.pattern19);
Integer source = Constants.DeviceSource.WIRELESS;
Integer deviceType = DeviceLocationUtil.resolutionGpsType(gpsTime, bsTime, source);
Assert.assertSame(deviceType, Constants.Verification.SN_VALID);
}
}