package com.usoftchina.bi.test.server.controller.chart;

import com.usoftchina.bi.core.base.RepEntity;
import com.usoftchina.bi.core.base.TestPage;
import com.usoftchina.bi.server.Application;
import com.usoftchina.bi.server.model.po.TokenData;
import com.usoftchina.bi.server.model.vo.configVo.LoginInfo;
import com.usoftchina.bi.server.service.user.UserService;
import com.usoftchina.bi.starter.test.BaseControllerTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest( classes = Application.class)
public class ChartsConfigControllerTest extends BaseControllerTest {

    @Autowired
    private UserService userService;

    private static String token = null;
    private static final Logger logger = LoggerFactory.getLogger(ChartsConfigControllerTest.class);

    @Before
    public void init(){
        if (token == null) {
            LoginInfo loginInfo = new LoginInfo();
            loginInfo.setUserName("ZHUTH");
            loginInfo.setPassWord("1111qqqq");
            RepEntity<TokenData> repEntity = userService.login(loginInfo);
            token = repEntity.getData().getToken();
            logger.info("token={}", token);
        }
    }

    @Test
    public void testA_inputCharts() throws Exception {
        /*ChartConfigInfo chartConfigInfo = new ChartConfigInfo();
        mockMvc.perform(requestBody("/inputCharts", chartConfigInfo)
                        .header("token", token))
                .andReturn();*/
    }

    @Test
    public void testB_updateCharts() throws Exception {
    }

    @Test
    public void testC_changeChartOrder() throws Exception {
    }

    @Test
    public void testD_updateConfigGroup() throws Exception {
    }

    @Test
    public void testE_delChartsConfig() throws Exception {
    }

    @Test
    public void testF_getListCharts() throws Exception {
        TestPage page = new TestPage();
        mockMvc.perform(get("/getListCharts", page)
                        .header("token", token))
                .andReturn();
    }

    @Test
    public void testG_getChartsConfig() throws Exception {
        mockMvc.perform(get("/getChartsConfig")
                .header("token", token)
                .param("id", "451"))
                .andReturn();
    }

    @Test
    public void testH_setChartsGroup() throws Exception {
    }

    @Test
    public void testI_updataChartsGroup() throws Exception {
    }

    @Test
    public void testJ_updataListGroup() throws Exception {
    }

    @Test
    public void testK_delChartsGroup() throws Exception {
    }

    /*@Test
    public void testL_getChartsGroup() throws Exception {
        MvcResult result = mockMvc.perform(post("/getListCharts")
                .header("token", token))
                .andReturn();
        RepEntity<List> repEntity = result(result, List.class);
        logger.info("result={}", JsonUtils.toJsonString(repEntity.getDate()));
    }*/

}