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

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 com.usoftchina.bi.test.server.controller.chart.ChartsConfigControllerTest;
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;
import org.springframework.test.context.web.WebAppConfiguration;

import static org.junit.Assert.*;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest( classes = Application.class)
public class DashboardsServiceTest 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_setDashboards() throws Exception {
    }

    @Test
    public void testB_updateDashboards() throws Exception {
    }

    @Test
    public void testC_delDashboards() throws Exception {
    }

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

    @Test
    public void testE_getDashboards() throws Exception {
        mockMvc.perform(get("/getDashboards")
                .header("token", token)
                .param("id", "381"))
                .andReturn();
    }

    @Test
    public void testF_changeDashOrder() throws Exception {
    }

    @Test
    public void testG_getDashOrder() throws Exception {
    }

}