Commit 0bf67329 by DuJunLi

增加查看课次详情case,训练营活动创建后,每个case类执行完都做删除操作

parent 3b6f5297
...@@ -14,6 +14,8 @@ import org.springframework.stereotype.Component; ...@@ -14,6 +14,8 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* 训练营排课相关工具类 * 训练营排课相关工具类
...@@ -205,6 +207,73 @@ public class CampScheduleTools extends XMBaseTest { ...@@ -205,6 +207,73 @@ public class CampScheduleTools extends XMBaseTest {
body.put("weekdays", weekdaysList); body.put("weekdays", weekdaysList);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true); dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
return Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.result")); return Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.result"));
}
/**
* 查看训练营排课日程详情
* @param ruldId
*/
public void getCampRuleScheduleDetail(String ruldId){
setUP("API_getCampRuleScheduleDetail");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("id", ruldId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
}
/**
* 查看训练营排课课次详情
* @param scheduleId
*/
public void getCampScheduleItemDetail(String scheduleId){
setUP("API_getCampScheduleItemDetail");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("id", scheduleId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
}
/**
* 删除训练营课次
* @param scheduleId 课次ID
* @param applyRestRule 是否删除后续课次 false(只删除当前课次) ;true(当前及后续)
*/
public void delCampScheduleItem(String scheduleId,Boolean applyRestRule){
setUP("API_delCampScheduleItem");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("scheduleId", scheduleId);
body.put("applyRestRule", applyRestRule);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
}
/**
* 获取指定下周某一天的训练营课次ID
* @param n
* @return 判断某天没排课 scheduleIds5.size() == 0 || scheduleIds5 == null
*/
public Set<String> getCampTableDate(int n) {
//查看下周训练营课表
getCampScheduleTable(CommUtil.oneKeyGetNextWeekStartDay(), CommUtil.oneKeyGetNextWeekEndDay());
String date = CommUtil.oneKeyGetNextWeekXDay(n);//下周N 日期时间戳
int count = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").size();
if (count > 0) {
JSONArray array = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups");
Set<String> scheduleIds = array.toJavaList(JSONObject.class).stream()
.filter(e -> e.getString("date").equals(date))//过滤出日期等于下周N的数据
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.map(e -> e.getString("scheduleId"))//获取scheduleId
.collect(Collectors.toSet());
return scheduleIds; //如果当天没排课,则scheduleIds.size()==0
}
return null;
} }
......
...@@ -82,7 +82,6 @@ public class SelectTargetTrainingCampAndGetInfo extends BaseCreateTrainingData { ...@@ -82,7 +82,6 @@ public class SelectTargetTrainingCampAndGetInfo extends BaseCreateTrainingData {
chiefCoachId = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> { chiefCoachId = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> {
return "杜君丽".equals(e.getString("nickName")); return "杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).findFirst().orElse(null); }).map(e -> e.getString("id")).findFirst().orElse(null);
System.out.println(id);
assistCoachIds = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> { assistCoachIds = campInfo.get(0).getJSONArray("trainerList").toJavaList(JSONObject.class).stream().filter(e -> {
return !"杜君丽".equals(e.getString("nickName")); return !"杜君丽".equals(e.getString("nickName"));
}).map(e -> e.getString("id")).collect(Collectors.toList()); }).map(e -> e.getString("id")).collect(Collectors.toList());
......
...@@ -59,13 +59,17 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn ...@@ -59,13 +59,17 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
ruldId=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").getJSONObject(0).getString("ruleId"); ruldId=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result").getJSONObject(0).getString("ruleId");
} }
@AfterClass(description = "删除此case创建的训练营排课日程") @AfterClass(description = "删除此case创建的训练营排课日程和训练营活动")
public void delData() { public void delData() {
if (null!=ruldId||!ruldId.isEmpty()) { if (null!=ruldId||!ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId); campScheduleTools.delCampRuleSchedule(ruldId);
} }
if (null!=campId||!campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
} }
}
} }
\ No newline at end of file
...@@ -9,13 +9,14 @@ import com.xiaomai.enums.Terminal; ...@@ -9,13 +9,14 @@ import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.CommUtil; import com.xiaomai.utils.CommUtil;
import com.xiaomai.utils.XMJSONPath; import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 编辑训练营排课规则 * 编辑训练营排课规则
...@@ -44,7 +45,7 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo ...@@ -44,7 +45,7 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
//获取选择的训练营ID //获取选择的训练营ID
campId = super.campId; campId = super.campId;
//获取训练营活动的指定教练ID //获取训练营活动的指定教练ID
chiefCoachId =super.chiefCoachId; chiefCoachId = super.chiefCoachId;
//从训练营活动中获取助教信息 //从训练营活动中获取助教信息
List<String> assistCoachIds = super.assistCoachIds; List<String> assistCoachIds = super.assistCoachIds;
...@@ -59,20 +60,26 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo ...@@ -59,20 +60,26 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
campScheduleTools.getCampRuleScheduleList(campId, "", chiefCoachId); campScheduleTools.getCampRuleScheduleList(campId, "", chiefCoachId);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 1, "排课创建成功后,日程中没查询到对应数据"); Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 1, "排课创建成功后,日程中没查询到对应数据");
ruldId = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getString("ruleId"); ruldId = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getString("ruleId");
int scheduleClassHourBefore = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getJSONObject("campVO").getIntValue("scheduleClassHour");
//下面要操作缩短结束日期,check
String[] weekDaysArray = {"TUESDAY", "THURSDAY", "SATURDAY", "SUNDAY"};
List<String> weekdaysList = Arrays.asList(weekDaysArray);
int loopNum = campScheduleTools.queryExpectedLoopNum(CommUtil.getNDayEndTimeTamp(23), super.openEndDate, weekdaysList);
//编辑训练营排课日程 //编辑训练营排课日程
JSONObject body = new JSONObject(); JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId()); body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId()); body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId()); body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
chiefCoachId=assistCoachIds.get(0).toString(); chiefCoachId = assistCoachIds.get(0).toString();
body.put("chiefCoachId",chiefCoachId );//修改教练换人 body.put("chiefCoachId", chiefCoachId);//修改教练换人
body.put("minMemberNum", super.traineeLowerLimit); body.put("minMemberNum", super.traineeLowerLimit);
body.put("maxMemberNum", super.traineeUpperLimit); body.put("maxMemberNum", super.traineeUpperLimit);
body.put("minuteOffset", "1320"); body.put("minuteOffset", "1320");
List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地"); List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地");
body.put("venueAreaIds", venueAreaIds); //有空改为有数据 body.put("venueAreaIds", venueAreaIds); //有空改为有数据
List<String> assistTrainer=new ArrayList<>(); List<String> assistTrainer = new ArrayList<>();
assistTrainer.add(assistCoachIds.get(1).toString()); assistTrainer.add(assistCoachIds.get(1).toString());
body.put("assistCoachIds", assistTrainer); //空改成有数据 body.put("assistCoachIds", assistTrainer); //空改成有数据
body.put("ruleId", ruldId); body.put("ruleId", ruldId);
...@@ -82,14 +89,29 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo ...@@ -82,14 +89,29 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
body.put("retainBooking", true); body.put("retainBooking", true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true); xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
//查询训练营日程详情,check修改项是否被同步修改todo //查询训练营日程详情,check修改项是否被同步修改
campScheduleTools.getCampRuleScheduleDetail(ruldId);
//校验总课时数是否同步变更todo Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.chiefCoachId"), chiefCoachId);
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.endDate").substring(0, 9), CommUtil.getNDayEndTimeTamp(22).substring(0, 9));
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.venueAreaIds").containsAll(venueAreaIds), "场地有空改为有数据后,查看日程详情发现数据没变更");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.assistCoachIds").containsAll(assistTrainer), "助教有空改为有数据后,查看日程详情发现数据没变更");
Assert.assertEquals(XMJSONPath.getJSONObjectByReadPath(dataApi.getApi_response(), "$.result.campVO").getIntValue("totalClassHour"), super.totalClassHour, "总课时数有问题");
int scheduleClassHourAfter =XMJSONPath.getJSONObjectByReadPath(dataApi.getApi_response(), "$.result.campVO").getIntValue("scheduleClassHour");
//校验已排课次数是否同步变更:原排课次数-缩短日期那段时间的次数
Assert.assertEquals(scheduleClassHourAfter, (scheduleClassHourBefore - loopNum));
}
@AfterClass(description = "删除此case创建的训练营排课日程")
public void delData() {
if (null!=ruldId||!ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId);
}
if (null!=campId||!campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
}
} }
} }
\ No newline at end of file
package com.xiaomai.cases.polar.schedule.camp;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.CommUtil;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.Set;
/**
* 查看训练营课次详情
*
* @author adu
* data 2024/7/12 10:31
*/
public class TestGetCampScheduleItemDetail extends SelectTargetTrainingCampAndGetInfo {
@Resource(name = "campScheduleTools")
CampScheduleTools campScheduleTools;
String campId = "";
String chiefCoachId = "";
String ruldId = "";
@BeforeClass
public void beforeTest() {
setTestInfo(ApiModule.Polar_Schedule, "API_getCampScheduleItemDetail", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
}
@Test(description = "查看课次详情")
public void testGetCampScheduleItemDetail() {
//获取选择的训练营ID
campId = super.campId;
//获取训练营活动的指定教练ID
chiefCoachId = super.chiefCoachId;
//创建训练营排课:按次数 星期:2,4,6,7
campScheduleTools.oneKeyCreateCampRuleSchedule(campId, chiefCoachId, super.courseId,
super.traineeLowerLimit, super.traineeUpperLimit,
"1140", super.openEndDate, true,
"22");
//查询排课日程:根据训练营和关联课程查询
campScheduleTools.getCampRuleScheduleList(campId, super.courseId, "");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 1, "排课创建成功后,日程中没查询到对应数据");
ruldId = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getString("ruleId");
//查看下周5的日课表,期望值无数据
Set<String> scheduleIds5 = campScheduleTools.getCampTableDate(11);
Assert.assertTrue(scheduleIds5.size() == 0 || scheduleIds5 == null, "周五没排课,但是检查出有课次");
//查看下周日的日课表,有数据,并查看课次详情
String startDate = CommUtil.oneKeyGetNextWeekXDay(13);//下周日00点时间
String endDate = CommUtil.oneKeyGetNextWeekEndXDay(7);//下周日23:59
campScheduleTools.getCampScheduleTable(startDate, endDate);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").size() >= 1, "下周日排的有课次,但是发现没课次");
//过滤出刚创建的课次
JSONArray array = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups");
String scheduleId = array.toJavaList(JSONObject.class).stream()
//.filter(e -> e.getString("date").equals(startDate))//过滤出日期等于下周日的数据
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.filter(e -> e.getJSONObject("campVO").getString("id").equals(campId))
.map(e -> e.getString("scheduleId"))//获取scheduleId
.findFirst().orElse(null);
//查看课次详情
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("id", scheduleId);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
//断言check
//主教练check
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.result.chiefCoachId"), chiefCoachId, "教练和创建时设置的不一致");
//助教check
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(xmAppApi.getApi_response(), "$.result.assistCoachIds").isEmpty(), "创建排课时助教设置为空,但是课次详情中显示不为空哦");
//场地check
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(xmAppApi.getApi_response(), "$.result.venueAreaIds").isEmpty(), "创建排课时场地设置为空,但是课次详情中显示不为空哦");
}
@AfterClass(description = "删除此case创建的训练营排课日程")
public void delData() {
if (null != ruldId || !ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId);
}
if (null != campId || !campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
}
}
}
\ No newline at end of file
...@@ -118,6 +118,9 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo ...@@ -118,6 +118,9 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo
if (null!=ruldId||!ruldId.isEmpty()) { if (null!=ruldId||!ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId); campScheduleTools.delCampRuleSchedule(ruldId);
} }
if (null!=campId||!campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
}
} }
......
...@@ -334,7 +334,7 @@ public class GroupScheduleTools extends XMBaseTest { ...@@ -334,7 +334,7 @@ public class GroupScheduleTools extends XMBaseTest {
/** /**
* 获取指定下周某一天的课次ID * 获取指定下周某一天的课次ID
* @param n * @param n
* @return * @return 判断某天没排课 scheduleIds5.size() == 0 || scheduleIds5 == null
*/ */
public Set<String> getTableDate(int n) { public Set<String> getTableDate(int n) {
//查看团课课表 //查看团课课表
...@@ -349,7 +349,8 @@ public class GroupScheduleTools extends XMBaseTest { ...@@ -349,7 +349,8 @@ public class GroupScheduleTools extends XMBaseTest {
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流 .flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.map(e -> e.getString("scheduleId"))//获取scheduleId .map(e -> e.getString("scheduleId"))//获取scheduleId
.collect(Collectors.toSet()); .collect(Collectors.toSet());
return scheduleIds; return scheduleIds; //如果当天没排课,则scheduleIds.size()==0
} }
return null; return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment