MainTest.java
3.01 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
package com.viontech.fanxing.task;
import com.alibaba.fastjson.JSON;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.DictCode;
import com.viontech.fanxing.task.model.TaskData;
import com.viontech.fanxing.task.model.runtime.DailyRuntimeConfig;
import com.viontech.fanxing.commons.model.main.VaServerInfo;
import com.viontech.fanxing.task.service.OpsClientService;
import com.viontech.fanxing.task.service.TaskDataService;
import com.viontech.fanxing.task.service.VAServerHttpService;
import com.viontech.fanxing.task.service.VAServerService;
import com.viontech.fanxing.task.service.impl.TaskServiceImpl;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
/**
* .
*
* @author 谢明辉
* @date 2021/7/21
*/
@SpringBootTest
@RunWith(SpringRunner.class)
@ActiveProfiles("test")
public class MainTest {
@Resource
private OpsClientService opsClientService;
@Resource
private TaskServiceImpl taskService;
@Resource
private TaskDataService taskDataService;
@Resource
private VAServerService vaServerService;
@Resource
private VAServerHttpService vaServerHttpService;
@Test
public void opsClientTest() {
DictCode nvs3000 = opsClientService.getDictCodeByUnid("460b359f-0bc6-11ec-a74d-0242ac11001d");
Channel channel = opsClientService.getChannelByChannelUnid("2200001201000D01");
String defaultConfig = opsClientService.getContentByName("defaultConfig");
System.out.println(JSON.toJSONString(nvs3000));
System.out.println(JSON.toJSONString(channel));
System.out.println(JSON.toJSONString(defaultConfig));
}
@Test
public void dailyRuntimeConfigTest() {
DailyRuntimeConfig dailyRuntimeConfig = new DailyRuntimeConfig("{\"config\":[{\"start\":\"08:00:00\",\"end\":\"10:00:00\"}]}");
ImmutablePair<Long, Long> n = dailyRuntimeConfig.getNextTimeOfExecutionAndTerminal();
System.out.println(new Date(n.left));
System.out.println(new Date(n.right));
}
@Test
public void nextTimeTest() {
TaskData taskData = taskDataService.getRepository().getTaskDataByUnid("612f56aa-3c6c-11ec-a7e6-0242ac110007");
ImmutablePair<Long, Long> next = taskData.getRuntimeConfig().getNextTimeOfExecutionAndTerminal();
System.out.println(next);
// assert next.left == 1635906774000L;
// assert next.right == 1635953574000L;
}
@Test
public void stopTask() {
String taskUnid = "090677cc-3c6c-11ec-a7e6-0242ac110007";
VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid);
vaServerHttpService.rmTask(taskUnid, vaServerInfo);
}
@Test
public void LogTest() {
opsClientService.addLog("task test test test");
}
}