VAServerHttpServiceTest.java 3.6 KB
package com.viontech.fanxing.task.service;

import com.alibaba.fastjson.JSON;
import com.viontech.fanxing.commons.constant.TaskStatus;
import com.viontech.fanxing.commons.model.StoreConfig;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.service.RedisService;
import com.viontech.fanxing.task.model.TaskData;
import com.viontech.fanxing.commons.model.main.VaServerInfo;
import com.viontech.fanxing.task.repository.TaskDataRedisRepository;
import com.viontech.fanxing.task.repository.VAServerRedisRepository;
import com.viontech.fanxing.task.service.adapter.TaskService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * .
 *
 * @author 谢明辉
 * @date 2021/7/21
 */
@SpringBootTest
@RunWith(SpringRunner.class)
class VAServerHttpServiceTest {

    private static final String TASK_UNID = "abcd-xxxx-xxxxxx-xxxxxx";
    private static final String DEV_ID = "sn3device1";

    @Resource
    VAServerHttpService vaServerHttpService;
    @Resource
    RedisService redisService;
    @Resource
    private VAServerRedisRepository vaServerRedisRepository;

    @Resource
    private OpsClientService opsClientService;
    private VaServerInfo vaServerInfo;
    private TaskData taskData;
    @Resource
    private TaskService taskService;
    @Resource
    private TaskDataRedisRepository taskDataRedisRepository;

    @BeforeEach
    public void before() {
        this.vaServerInfo = vaServerRedisRepository.getVAServerInfoById(DEV_ID);
        this.taskData = new TaskData();
        Task task = new Task();
        task.setUnid(TASK_UNID);
        this.taskData.setTask(task);
    }

    @Test
    void snapshot() {
        vaServerHttpService.snapshot(TASK_UNID, vaServerInfo);
    }

    @Test
    void getAnalyzeStream() {
        Object analyzeStream = vaServerHttpService.getAnalyzeStream(TASK_UNID, vaServerInfo);
    }

    @Test
    void startAnalyzeStream() {
        vaServerHttpService.startAnalyzeStream(TASK_UNID, vaServerInfo, "rtsp://192.168.9.245:10087/abcd-xxxx-xxxxxx-xxxxxx");
    }

    @Test
    void switchScene() {
        vaServerHttpService.switchScene(TASK_UNID, vaServerInfo, "1");
    }

    @Test
    void updateAlternate() {
        vaServerHttpService.updateRotationStatus(TASK_UNID, 1, vaServerInfo);
    }

    @Test
    void getAlternate() {
        vaServerHttpService.getRotationStatus(TASK_UNID, vaServerInfo);
    }

    @Test
    void status() {
        vaServerHttpService.status(vaServerInfo);
    }

    @Test
    void storeConfig() {
        String storeConfig = opsClientService.getStoreConfigById(6L);
        System.out.println(storeConfig);
    }

    @Test
    void testJsonArray() {

    }

    @Test
    void test() throws Exception {
//        RMap<String, String> taskVaServerMap = redisService.getTaskVaServerMap();
//        taskVaServerMap.put("b0c20c4a-fffd-11eb-a74d-0242ac11001d", DEV_ID);
        taskService.updateStatus(19L, TaskStatus.RUNNING.val);

//        RScoredSortedSet<String> set = redisService.getClient().getScoredSortedSet(RedisKeys.SCHEDULING_TO_BE_EXECUTED_TASK_UNID_SET);
//        RScoredSortedSet<String> set2 = redisService.getClient().getScoredSortedSet(RedisKeys.SCHEDULING_TO_BE_TERMINATED_TASK_UNID_SET);
//        set.add(DateUtil.parse("yyyy-MM-dd HH:mm:ss", "2021-08-11 13:18:00").getTime(), "tttttttttttttttttt");
//        set2.add(DateUtil.parse("yyyy-MM-dd HH:mm:ss", "2021-08-11 13:20:00").getTime(), "tttttttttttttttttt");
    }
}