package com.testor.module.train.myManagement.service;

import com.alibaba.fastjson.JSON;
import com.testor.module.train.course.model.dto.TTrainCourseParam;
import com.tongtech.tfw.backend.common.biz.models.BaseResponse;
import com.tongtech.tfw.backend.common.exception.BusinessException;
import org.junit.jupiter.api.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 java.math.BigDecimal;
import java.math.RoundingMode;

import static org.junit.jupiter.api.Assertions.*;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = StartupApplication.class)
class TTrainMyManagementServiceTest {
    @Autowired
    private TTrainMyManagementService tTrainMyManagementService;


    @Test
    void getCourseDetail() throws Exception {
        String courseId = "04fc5d89247d4c45bb3d8c9ad26a265f";
        String taskId = "5417a7e8e8bb4ea0abc58de760ee3c0f";
        BaseResponse<TTrainCourseParam> courseDetail = tTrainMyManagementService.getCourseDetail(courseId, taskId);
        System.out.println(JSON.toJSONString(courseDetail));
    }


    public static void main(String[] args) {
        int count = 1;
        int size = 2;
        BigDecimal divide = new BigDecimal(count).divide(new BigDecimal(size)).multiply(new BigDecimal("100")).setScale(0, RoundingMode.DOWN);
        System.out.println(divide.toString());
    }

    @Test
    void findAllProjectCourseCompleteState() {
        try {
            BaseResponse<Boolean> allProjectCourseCompleteState = tTrainMyManagementService.findAllProjectCourseCompleteState(null);
            System.out.println(JSON.toJSONString(allProjectCourseCompleteState));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}