package com.xiaomai.cases.polar.schedule.camp;

import com.xiaomai.cases.polar.schedule.group.GroupScheduleTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

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

/**
 * 创建训练营排课
 *
 * @author adu
 * data 2024/7/9 14:49
 */

public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo {
    @Resource(name = "campScheduleTools")
    CampScheduleTools campScheduleTools;
    @Resource(name = "groupScheduleTools")
    GroupScheduleTools groupScheduleTools;

    String ruldId="";

    @BeforeClass
    @Override
    public void beforeTest() {
        setTestInfo(ApiModule.Polar_Schedule, "API_createCampRuleSchedule", LoginAccount.ADU_PROD, Terminal.B, "adu");
        super.beforeTest();
    }

    @Test(description = "创建训练营排课日程")
    public void testCreateCampRuleSchedule() {
        //从训练营活动中获取教练信息
        String chiefCoachId =super.chiefCoachId;

        //从训练营活动中获取助教信息
        List<String> assistCoachIds = super.assistCoachIds;

        //获取存量场地
        List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地");
        String campId=super.campId;
        //创建训练营排课：按日期
        campScheduleTools.createCampRuleSchedule(campId, assistCoachIds, chiefCoachId, super.courseId,
                super.traineeLowerLimit, super.traineeUpperLimit,
                "1020", super.openStartDate, super.openEndDate, true,
                venueAreaIds, "");

        //查询排课日程:根据训练营和教练（其中一个助教）查询
        campScheduleTools.getCampRuleScheduleList(campId,null,assistCoachIds.get(0).toString());
        Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").size()==1,"排课创建成功后，日程中没查询到对应数据");
        ruldId=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").getJSONObject(0).getString("ruleId");
    }

    @Test(description = "删除此case创建的训练营排课日程和训练营活动",priority = 1)
    public void delData() {
//直接删除训练营会的，对应的排课日程会被自动删除，校验其他case中已有
        if (null!=this.campId||!this.campId.isEmpty()) {
            this.getTrainingTools().deleteTraining(this.campId);
        }

    }


}