import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.chushang.common.core.constant.SecurityConstants;
import com.chushang.security.service.TokenService;
import com.chushang.SystemApplication;
import com.chushang.system.entity.bo.LoginBody;
import com.chushang.system.entity.po.SysMenu;
import com.chushang.security.entity.po.SysUser;
import com.chushang.system.entity.vo.RouterVo;
import com.chushang.system.service.*;
import com.chushang.task.entity.dto.CreateTaskDTO;
import com.chushang.task.enums.ServiceEnum;
import com.chushang.task.enums.TaskTypeEnum;
import com.chushang.task.feign.RemoteTaskService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.*;

/**
 * @author by zhaowenyuan create 2022/8/22 15:20
 */
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SystemApplication.class)
public class DemoTest {

    @Resource
    RemoteTaskService remoteTaskService;

    @Test
    public void menuTest(){
        LoginBody loginBody = new LoginBody();
        loginBody.setPassword("1");
        loginBody.setUsername("2");

        // 创建任务
        remoteTaskService.createTask(CreateTaskDTO.builder()
                .params(JSON.toJSONString(loginBody))
                .taskName("测试后台任务")
                .applicationName(ServiceEnum.SYSTEM)
                .methodName("methodName")
                .className(this.getClass().getName())
                .deptId(1L)
                .taskType(TaskTypeEnum.OTHER)
                .remark("remark")
                .createBy("system")
                .build(), SecurityConstants.INNER);
    }

}
