package com.zd.laboratory.controller;

import com.zd.laboratory.base.BaseControllerTest;
import com.zd.laboratory.domain.vo.ToDoWork;
import com.zd.laboratory.mapper.LabWorkBenchMapper;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
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 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/9:32
 * @Description:
 */
@DisplayName("工作台")
class LabWorkBenchControllerTest extends BaseControllerTest {


    @Autowired
    private LabWorkBenchMapper labWorkBenchMapper;

    /**
     * controller 前缀
     */
    private String cp = "/workbench";

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

    @Test
    @DisplayName("工作台-展示指定数量待办")
    void doworks() throws Exception {

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

    }

    @Test
    @DisplayName("工作台-展示指定数量待办mapper")
    void queryDoWork() throws Exception {

        //获取测试
        List<ToDoWork> toDoWorks = labWorkBenchMapper.toDoWorkStatistics("3,4,5", 5L);

    }
}
