package com.zd.laboratory.controller.bigview;

import com.zd.laboratory.base.BaseControllerTest;
import com.zd.laboratory.domain.vo.SubSimpleVO;
import io.swagger.annotations.ApiOperation;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

import static org.junit.jupiter.api.Assertions.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

/**
 * @Author: zhoupan
 * @Date: 2021/09/22/17:38
 * @Description:
 */
@DisplayName("数据大屏")
class BigViewControllerTest extends BaseControllerTest {
    /**
     * controller 前缀
     */
    private String cp = "/bigview";

    /**
     * 测试前置方法
     *
     * @throws Exception
     */
    @BeforeAll
    void init() throws Exception {
        //使用账号登陆
        beforeAll("admin", "admin123");
    }

    @Test
    @DisplayName("设备状态")
    void echartsHardwareOverview() throws Exception {

        MvcResult mvcResult = (MvcResult) mockMvc
                .perform(MockMvcRequestBuilders.get(cp + "/hardware").headers(httpHeaders).accept(MediaType.APPLICATION_JSON_UTF8))
                .andDo(print())
                .andExpect(status().isOk())
                .andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200))
                .andReturn();
        logger.info("测试结果:" + mvcResult.getResponse().getContentAsString());
    }

    @Test
    @DisplayName("查询重点实验室")
    void echartsSubview() throws Exception {

        MvcResult mvcResult = (MvcResult) mockMvc
                .perform(MockMvcRequestBuilders.get(cp + "/sub/99").headers(httpHeaders).accept(MediaType.APPLICATION_JSON_UTF8))
                .andDo(print())
                .andExpect(status().isOk())
                .andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200))
                .andReturn();
        logger.info("测试结果:" + mvcResult.getResponse().getContentAsString());
    }

    @Test
    @DisplayName("查询实验室人数")
    void querySubOnline() throws Exception {

        MvcResult mvcResult = (MvcResult) mockMvc
                .perform(MockMvcRequestBuilders.get(cp + "/sub/online").headers(httpHeaders).accept(MediaType.APPLICATION_JSON_UTF8))
                .andDo(print())
                .andExpect(status().isOk())
                .andExpect(MockMvcResultMatchers.jsonPath("$.code").value(200))
                .andReturn();
        logger.info("测试结果:" + mvcResult.getResponse().getContentAsString());
    }

}
