Commit 23a17183 by DuJunLi

优化代码

parent 930c0c82
......@@ -85,7 +85,8 @@ public class TestBatchSendCouponToMember extends SelectTargetTrainingCampAndGetI
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("couponId", couponId);
body.put("receiverIds", receiverIds);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
String taskId = XMJSONPath.readPath(xmAppApi.getApi_response(), "$.result");
//check任务中心生成一条任务
......
......@@ -10,6 +10,7 @@ import com.xiaomai.utils.CommUtil;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.springframework.stereotype.Component;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -74,7 +75,9 @@ public class CampScheduleTools extends XMBaseTest {
body.put("assistCoachIds", assistCoachIds); //设置助教,可设置为空 new ArrayList<>();
body.put("force", force); //是否有冲突 true,false
body.put("enableCustomerReserve", "NO"); //能否用户自己约课,不能
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
......@@ -115,7 +118,9 @@ public class CampScheduleTools extends XMBaseTest {
body.put("assistCoachIds", new ArrayList<>()); //设置助教,可设置为空 new ArrayList<>();
body.put("force", force); //是否有冲突 true,false
body.put("enableCustomerReserve", "NO"); //能否用户自己约课,不能
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -146,7 +151,9 @@ public class CampScheduleTools extends XMBaseTest {
body.put("coachId", coachId);
}*/
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -162,7 +169,9 @@ public class CampScheduleTools extends XMBaseTest {
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("force", true);//删除学员约课记录
body.put("ruleId", ruleId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -180,7 +189,9 @@ public class CampScheduleTools extends XMBaseTest {
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("startDate", startDate);
body.put("endDate", endDate);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
if (Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalCount")) > 0) {
return dataApi.getBodyInJSON().getJSONObject("result").getJSONArray("timetableGroups").getJSONObject(0).getJSONArray("timetableList");
}
......@@ -205,7 +216,9 @@ public class CampScheduleTools extends XMBaseTest {
body.put("startDate", startDate);
body.put("endDate", endDate);
body.put("weekdays", weekdaysList);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
return Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.result"));
}
......@@ -220,7 +233,9 @@ public class CampScheduleTools extends XMBaseTest {
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);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -235,7 +250,9 @@ public class CampScheduleTools extends XMBaseTest {
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);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
......@@ -251,7 +268,9 @@ public class CampScheduleTools extends XMBaseTest {
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("scheduleId", scheduleId);
body.put("applyRestRule", applyRestRule);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
......@@ -283,7 +302,7 @@ public class CampScheduleTools extends XMBaseTest {
* @param ruldId
* @return
*/
public Set<String> getCampTableDate(int n,String ruldId) {
/* public Set<String> getCampTableDate(int n,String ruldId) {
//查看下周训练营课表
getCampScheduleTable(CommUtil.oneKeyGetNextWeekStartDay(), CommUtil.oneKeyGetNextWeekEndDay());
String date = CommUtil.oneKeyGetNextWeekXDay(n);//下周N 日期时间戳
......@@ -301,6 +320,26 @@ public class CampScheduleTools extends XMBaseTest {
}
return null;
}*/
public String getCampTableDate(int n,String ruldId) {
//查看下周训练营课表
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");
String scheduleId = array.toJavaList(JSONObject.class).stream()
.filter(e -> e.getString("date").equals(date))//过滤出日期等于下周N的数据
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.filter(e -> null != e.getString("ruleId"))
.filter(e ->e.getString("ruleId").equals(ruldId))
.map(e -> e.getString("scheduleId"))//获取scheduleId
.findFirst().orElse("");
return scheduleId; //如果当天没排课,
}
return "";
}
......
package com.xiaomai.cases.polar.schedule.camp;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
......@@ -19,17 +20,18 @@ import java.util.Set;
/**
* 删除训练营课次(单个/当前及后续)
*
* @author adu
* data 2024/7/12 17:05
*/
public class TestDelCampScheduleItem extends SelectTargetTrainingCampAndGetInfo{
public class TestDelCampScheduleItem extends SelectTargetTrainingCampAndGetInfo {
@Resource(name = "campScheduleTools")
CampScheduleTools campScheduleTools;
String campId = "";
String chiefCoachId = "";
String ruldId = "";
int loopNum=0;
int loopNum = 0;
String[] weekDaysArray = {"TUESDAY", "THURSDAY", "SATURDAY", "SUNDAY"};
List<String> weekdaysList = Arrays.asList(weekDaysArray);
......@@ -55,33 +57,34 @@ public class TestDelCampScheduleItem extends SelectTargetTrainingCampAndGetInfo{
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 1, "排课创建成功后,日程中没查询到对应数据");
ruldId = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getString("ruleId");
}
@Test(description = "删除当前课次")
public void testDelCurrentCampScheduleItem(){
public void testDelCurrentCampScheduleItem() {
//获取下周日课次ID(只删除匹配到ruldId的课次)
Set<String> scheduleIds7 = campScheduleTools.getCampTableDate(13,ruldId);
if(scheduleIds7.size() != 0 && scheduleIds7 != null){
String scheduleId7 = campScheduleTools.getCampTableDate(13, ruldId);
if (!StringUtils.isEmpty(scheduleId7)) {
//删除本次规则创建的下周日所有的课次
scheduleIds7.stream().forEach(scheduleId -> {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", false);
body.put("scheduleId", scheduleId);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
});
body.put("scheduleId", scheduleId7);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
//删除成功后check 下周日课表是否包含删除的课次
String startDate = CommUtil.oneKeyGetNextWeekXDay(13);//下周日00点时间
String endDate = CommUtil.oneKeyGetNextWeekEndXDay(7);//下周日23:59
campScheduleTools.getCampScheduleTable(startDate,endDate);
campScheduleTools.getCampScheduleTable(startDate, endDate);
Long goalCount= XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
Long goalCount = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.filter(e -> null != e.getString("ruleId"))
.filter(e ->e.getString("ruleId").equals(ruldId))
.filter(e -> e.getString("ruleId").equals(ruldId))
.map(e -> e.getString("scheduleId")).count();//获取scheduleId 的数量
Assert.assertTrue(goalCount==0,"删除当前课次后,再去课表中查看,后端仍然返回数据");
Assert.assertTrue(goalCount == 0, "删除当前课次后,再去课表中查看,后端仍然返回数据");
}
......@@ -90,40 +93,39 @@ public class TestDelCampScheduleItem extends SelectTargetTrainingCampAndGetInfo{
@Test(description = "删除当前及后续课次", priority = 1)
public void testDelCurrentAndSubsequentCampSchedule() {
//获取下周六课次ID
Set<String> scheduleIds6 = campScheduleTools.getCampTableDate(12,ruldId);
if(scheduleIds6.size() != 0 && scheduleIds6 != null){
String scheduleIds6 = campScheduleTools.getCampTableDate(12, ruldId);
if (!StringUtils.isEmpty(scheduleIds6)) {
//删除下周六即后续所有的课次
scheduleIds6.stream().forEach(scheduleId -> {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", true);
body.put("scheduleId", scheduleId);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
});
body.put("scheduleId", scheduleIds6);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"));
//删除成功后check从下周六到排课结束日期课表是否有数据
String startDate = CommUtil.oneKeyGetNextWeekXDay(12);//下周六00点时间
campScheduleTools.getCampScheduleTable(startDate, super.openEndDate);
if(Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalCount"))>0){
Long goalCount= XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
if (Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalCount")) > 0) {
Long goalCount = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.filter(e -> null != e.getString("ruleId"))
.filter(e ->e.getString("ruleId").equals(ruldId)).count();
Assert.assertTrue(goalCount==0,"删除当前课次后,再去课表中查看,后端仍然返回数据");
.filter(e -> e.getString("ruleId").equals(ruldId)).count();
Assert.assertTrue(goalCount == 0, "删除当前课次后,再去课表中查看,后端仍然返回数据");
}
else {
} else {
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalCount"), "0");
}
//删除成功后,check对应训练营活动的已排课次数是否同步变更
int delLoopNum=campScheduleTools.queryExpectedLoopNum(startDate, super.openEndDate, weekdaysList);
int delLoopNum = campScheduleTools.queryExpectedLoopNum(startDate, super.openEndDate, weekdaysList);
//查看日程,获取原规则中展示的训练营已排课课次数,原来已排课课次数-删除的已排课课次数
campScheduleTools.getCampRuleScheduleDetail(ruldId);
Assert.assertTrue(XMJSONPath.getJSONObjectByReadPath(dataApi.getApi_response(),"$.result.campVO").getIntValue("scheduleClassHour")==(loopNum-delLoopNum));
Assert.assertTrue(XMJSONPath.getJSONObjectByReadPath(dataApi.getApi_response(), "$.result.campVO").getIntValue("scheduleClassHour") == (loopNum - delLoopNum));
}
......@@ -132,14 +134,14 @@ public class TestDelCampScheduleItem extends SelectTargetTrainingCampAndGetInfo{
@AfterTest(description = "删除此case创建的训练营排课日程")
public void delData() {
//先删除规则,再操作删除对应的训练营活动,此处顺序不能换,如果先删除训练营活动,对应的排课会自动删除,所以就不用删除排课日程了,这个场景其他case中会体现
if (null!=ruldId||!ruldId.isEmpty()) {
if (null != ruldId || !ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId);
//删除日程后check 日程列表数据是否还能搜索到,期望搜索结果数据为空
campScheduleTools.getCampRuleScheduleList(campId,super.courseId,"");
campScheduleTools.getCampRuleScheduleList(campId, super.courseId, "");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 0, "日程被删除后,对应的排课日程列表还可以查到相关数据");
}
if (null!=campId||!campId.isEmpty()) {
if (null != campId || !campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
}
......
......@@ -124,7 +124,9 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
body.put("endDate", CommUtil.getNDayEndTimeTamp(22)); //结束日期缩短了20天,
body.put("force", true);
body.put("retainBooking", true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
//查询训练营日程详情,check修改项是否被同步修改
campScheduleTools.getCampRuleScheduleDetail(ruldId);
......
package com.xiaomai.cases.polar.schedule.camp;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.schedule.group.GroupScheduleTools;
......@@ -10,6 +11,7 @@ import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.CommUtil;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
......@@ -27,7 +29,7 @@ import java.util.stream.Collectors;
public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo {
public static Date now = new Date();
Set<String> scheduleIdsN;
String scheduleIdsN;
@Resource(name = "groupScheduleTools")
GroupScheduleTools groupScheduleTools;
@Resource(name = "campScheduleTools")
......@@ -78,16 +80,14 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
@Test(description = "编辑当前课次")
public void testEditCurrentCampSchedule() {
//获取本次创建规则中下周日课次ID
scheduleIdsN = campScheduleTools.getCampTableDate(13,ruldId);
if (scheduleIdsN.size() != 0 && scheduleIdsN != null) {
scheduleIdsN.stream().forEach(scheduleId -> {
scheduleIdsN = campScheduleTools.getCampTableDate(13, ruldId);
if (!StringUtils.isEmpty(scheduleIdsN)) {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", false);
body.put("scheduleId", scheduleId);
body.put("scheduleId", scheduleIdsN);
body.put("startTime", startStamp);//修改上课时间
body.put("chiefCoachId", chiefCoachId);
body.put("minMemberNum", super.traineeLowerLimit);
......@@ -98,25 +98,27 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
body.put("force", true);//有冲突时忽略冲突
body.put("retainBooking", true);//保留学员预约
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//编辑成功后check对应课次详情修改内容是否同步成功
campScheduleTools.getCampScheduleItemDetail(scheduleId);
campScheduleTools.getCampScheduleItemDetail(scheduleIdsN);
String detailResult = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.chiefCoachId"), chiefCoachId);
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.startTime"), startStamp);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.assistCoachIds").size() == 2, "助教修改后添加2个教练没生效");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.venueAreaIds").size() == 0, "课次创建时场地为空,查看课次详情不为空");
});
}
}
@Test(description = "编辑当前及后续课次",dependsOnMethods = {"testEditCurrentCampSchedule"},alwaysRun=true)
@Test(description = "编辑当前及后续课次", dependsOnMethods = {"testEditCurrentCampSchedule"}, alwaysRun = true)
public void testEditCurrentAndSubsequentCampSchedule() throws InterruptedException {
//获取存量场地
List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地");
......@@ -132,7 +134,7 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
scheduleId22 = array.toJavaList(JSONObject.class).stream()
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.filter(e -> null != e.getString("ruleId"))
.filter(e ->e.getString("ruleId").equals(ruldId))
.filter(e -> e.getString("ruleId").equals(ruldId))
.map(e -> e.getString("scheduleId"))//获取scheduleId
.collect(Collectors.toSet());
if (scheduleId22.size() != 0 && scheduleId22 != null) {
......@@ -144,16 +146,15 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
}
//获取下周六的课次ID
Set<String> scheduleIds6 = campScheduleTools.getCampTableDate(12,ruldId);
if (scheduleIds6.size() != 0 && scheduleIds6 != null) {
scheduleIds6.stream().forEach(scheduleId -> {
String scheduleIds6 = campScheduleTools.getCampTableDate(12, ruldId);
if (!StringUtils.isEmpty(scheduleIds6)) {
//编辑下周六及后续课次
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", true);
body.put("scheduleId", scheduleId);
body.put("scheduleId", scheduleIds6);
//获取下周六某个时间点的开始时间戳
String startStamp = CommUtil.getWholeHourTimeStamp(12, "19:00");
body.put("startTime", startStamp);//上课时间不做修改
......@@ -165,7 +166,9 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
body.put("spanMinutes", 50);
body.put("force", true);//有冲突时忽略冲突
body.put("retainBooking", true);//保留学员预约
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
......@@ -173,10 +176,10 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
}
//check当前课次信息是否被同步修改
campScheduleTools.getCampScheduleItemDetail(scheduleId);
campScheduleTools.getCampScheduleItemDetail(scheduleIds6);
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.startTime"), startStamp);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.venueAreaIds").containsAll(venueAreaIds), "场地有空改为有数据,但是课次详情中显示不正确哦");
});
}
//后续检查点check
Thread.sleep(1000);
......@@ -207,48 +210,40 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
//Assert.assertEquals(eDateBefore.substring(0, 9), super.openEndDate.substring(0, 9), "新规则的结束日期不对");
//2.断言check:获取下周四的课次,check是否还是原来的数据(不会受到影响)
Set<String> scheduleIds4 = campScheduleTools.getCampTableDate(10, ruldId);
if (scheduleIds4.size() != 0 && scheduleIds4 != null) {
scheduleIds4.stream().forEach(scheduleId -> {
campScheduleTools.getCampScheduleItemDetail(scheduleId);
String scheduleIds4 = campScheduleTools.getCampTableDate(10, ruldId);
if (!StringUtils.isEmpty(scheduleIds4)) {
campScheduleTools.getCampScheduleItemDetail(scheduleIds4);
String detailResult = dataApi.getApi_response();
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.assistCoachIds").size() == 0, "课次创建时助教为空,查看课次详情不为空");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.venueAreaIds").size() == 0, "课次创建时场地为空,查看课次详情不为空");
});
}
// 3.check下周日的课次(以独立出去的课次是否受到影响:不受影响)
if (scheduleIdsN.size() != 0 && scheduleIdsN != null) {
scheduleIdsN.stream().forEach(scheduleId -> {
campScheduleTools.getCampScheduleItemDetail(scheduleId);
if (!StringUtils.isEmpty(scheduleIdsN)) {
campScheduleTools.getCampScheduleItemDetail(scheduleIdsN);
String detailResult = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.startTime"), startStamp);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.assistCoachIds").size() == 2, "助教修改后添加2个教练没生效");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.venueAreaIds").size() == 0, "课次创建时为空,查看课次详情不为空");
});
}
//4.check 下周日是否又生成一条新的课次
Set<String> scheduleIds77 = campScheduleTools.getCampTableDate(13,newRuldId);
Assert.assertTrue(scheduleIds77.size() == 1);
//scheduleIds77.removeAll(scheduleIdsN);
// System.out.println(JSON.toJSONString(scheduleIds77));
if (scheduleIds77.size() != 0 && scheduleIds77 != null) {
scheduleIds77.stream().forEach(scheduleId -> {
campScheduleTools.getCampScheduleItemDetail(scheduleId);
String scheduleIds77 = campScheduleTools.getCampTableDate(13, newRuldId);
Assert.assertTrue(!StringUtils.isEmpty(scheduleIds77), "下周日没有生成一条新的数据");
campScheduleTools.getCampScheduleItemDetail(scheduleIds77);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.venueAreaIds").containsAll(venueAreaIds), "场地有空改为有数据,但是课次详情中显示不正确哦");
});
}
//5.check 下下周二是否生成一条新的课次
campScheduleTools.getCampScheduleTable(targetStartDate, targetendDate);
List<String> ruleIdIds22 = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result.timetableGroups").toJavaList(JSONObject.class).stream()
List<String> ruleIdIds22 = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
.filter(e -> e.getString("date").equals(targetStartDate))//过滤出日期等于下周日的数据
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.filter(e -> null != e.getString("ruleId"))
.filter(e ->e.getString("ruleId").equals(newRuldId))
.filter(e -> e.getString("ruleId").equals(newRuldId))
.map(e -> e.getString("ruleId"))//获取ruleId
.collect(Collectors.toList());
......@@ -257,7 +252,7 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
}
@Test(description = "删除此case创建的训练营排课日程", priority = 2)
@AfterTest(description = "删除此case创建的训练营排课日程")
public void delData() {
/* if (null != ruldId || !ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId);
......
package com.xiaomai.cases.polar.schedule.camp;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.finance.order.OrderTools;
......@@ -81,8 +82,8 @@ public class TestGetCampScheduleItemDetail extends SelectTargetTrainingCampAndGe
ruldId = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getString("ruleId");
//查看下周5的日课表,期望值无数据
Set<String> scheduleIds5 = campScheduleTools.getCampTableDate(11,ruldId);
Assert.assertTrue(scheduleIds5.size() == 0 || scheduleIds5 == null, "周五没排课,但是检查出有课次");
String scheduleIds5 = campScheduleTools.getCampTableDate(11,ruldId);
Assert.assertTrue(StringUtils.isEmpty(scheduleIds5), "周五没排课,但是检查出有课次");
//查看下周日的日课表,有数据,并查看课次详情
String startDate = CommUtil.oneKeyGetNextWeekXDay(13);//下周日00点时间
......@@ -104,7 +105,9 @@ public class TestGetCampScheduleItemDetail extends SelectTargetTrainingCampAndGe
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);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
//断言check
//课次中有1个学员check
......
......@@ -104,7 +104,9 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo
body.put("coachId", coachId);
body.put("statusSet", statusSet);
body.put("venueAreaId", venueAreaId);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
int resultCount = Integer.parseInt(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.result.totalCount"));
Assert.assertTrue(resultCount >= total, "查询到的课表数据和预期不一致");
}
......
......@@ -12,6 +12,7 @@ import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.testng.Assert;
import javax.annotation.Resource;
import java.util.ArrayList;
......@@ -74,7 +75,9 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("endDate", CommUtil.getNDayEndTimeTamp(60)); //排课结束日期,这里就设置自动延顺60天,结束日期会覆盖你传的endDate
}
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -98,7 +101,8 @@ public class GroupScheduleTools extends XMBaseTest {
if (coachId != null && coachId.length() != 0) {
body.put("coachId", coachId);
}
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
return XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result");
}
......@@ -144,7 +148,9 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("force", force);
body.put("ruleId", ruleId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -228,7 +234,9 @@ public class GroupScheduleTools extends XMBaseTest {
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);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -248,7 +256,9 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("id", scheduleId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
return dataApi.getBodyInJSON().getJSONObject("result");
}
......@@ -309,7 +319,9 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("assistCoachIds", new ArrayList());
body.put("spanMinutes", 60);
body.put("force", false);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -331,7 +343,9 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("scheduleId", scheduleId);
body.put("applyRestRule", false);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
......@@ -367,7 +381,7 @@ public class GroupScheduleTools extends XMBaseTest {
* @param ruldId
* @return
*/
public Set<String> getTableDate(int n,String ruldId) {
public String getTableDate(int n,String ruldId) {
//查看团课课表
getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekStartDay()), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()),"");
//获取下周周N及后续的课次
......@@ -375,17 +389,17 @@ public class GroupScheduleTools extends XMBaseTest {
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()
String scheduleIds = array.toJavaList(JSONObject.class).stream()
.filter(e -> e.getString("date").equals(date))//过滤出日期等于下周N的数据
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.filter(e -> null != e.getString("ruleId"))
.filter(e ->e.getString("ruleId").equals(ruldId))
.map(e -> e.getString("scheduleId"))//获取scheduleId
.collect(Collectors.toSet());
return scheduleIds; //如果当天没排课,则scheduleIds.size()==0
.findFirst().orElse("");
return scheduleIds;
}
return null;
return "";
}
......
......@@ -80,7 +80,7 @@ public class TestCreateGroupRuleSchedule extends BaseTestImpl {
List<String> assistCoachIdS = groupScheduleTools.getStudioAdminId(assistCoachIds);
//1-创建排课日程
groupScheduleTools.createGroupRuleSchedule(courseId, chiefCoachIdS, todayStartTimeTamp, endDateTimeTamp, venueAreaIds, assistCoachIdS, false, 1, 480);
groupScheduleTools.createGroupRuleSchedule(courseId, chiefCoachIdS, todayStartTimeTamp, endDateTimeTamp, venueAreaIds, assistCoachIdS, true, 1, 480);
//2-查询排课日程
JSONArray result = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
String ruldId = XMJSONPath.readPath(result.getJSONObject(0), "$.ruleId");
......
package com.xiaomai.cases.polar.schedule.group;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
......@@ -38,59 +39,60 @@ public class TestDelGroupScheduleItem extends UniversalDataScheduling {
@Test(description = "删除当前课次")
public void testDelCurrentGroupSchedule() {
//获取下周四的课次ID(匹配到刚创建的规则ID)
Set<String> scheduleIds = groupScheduleTools.getTableDate(10,groupRuldId);
String scheduleId = groupScheduleTools.getTableDate(10, groupRuldId);
//如果课次ID有值则继续走删除的case
if (scheduleIds!= null && scheduleIds.size() != 0) {
scheduleIds.stream().forEach(scheduleId -> {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", false);
body.put("scheduleId", scheduleId);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
if (!StringUtils.isEmpty(scheduleId)) {
JSONObject body1 = new JSONObject();
body1.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body1.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body1.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body1.put("applyRestRule", false);
body1.put("scheduleId", scheduleId);
xmAppApi.doRequest(RequestType.JSON, params, body1.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"));
//删除成功后check 下周四课表是否有数据
groupScheduleTools.getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekXDay(10)), Long.valueOf(CommUtil.oneKeyGetNextWeekEndXDay(4)),courseId);
Long countA=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
groupScheduleTools.getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekXDay(10)), Long.valueOf(CommUtil.oneKeyGetNextWeekEndXDay(4)), courseId);
Long countA = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())
.filter(e ->e.getString("scheduleId").equals(scheduleId)).count();
Assert.assertTrue(countA==0,"删除课次后,课表中后端返回数据有问题,目前还能发现数据");
});
.filter(e -> e.getString("scheduleId").equals(scheduleId)).count();
Assert.assertTrue(countA == 0, "删除课次后,课表中后端返回数据有问题,目前还能发现数据");
}
}
@Test(description = "删除当前及后续课次", dependsOnMethods = {"testDelCurrentGroupSchedule"},alwaysRun = true)
@Test(description = "删除当前及后续课次", dependsOnMethods = {"testDelCurrentGroupSchedule"}, alwaysRun = true)
public void testDelCurrentAndSubsequentGroupSchedule() {
//获取下周三的课次ID(匹配到对应的规则ID)
Set<String> scheduleIds = groupScheduleTools.getTableDate(9,groupRuldId);
String scheduleIdsG = groupScheduleTools.getTableDate(9, groupRuldId);
//如果课次ID有值则继续走删除的case
if (scheduleIds!= null && scheduleIds.size() != 0) {
scheduleIds.stream().forEach(scheduleId -> {
if (!StringUtils.isEmpty(scheduleIdsG)) {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", true);
body.put("scheduleId", scheduleId);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
body.put("scheduleId", scheduleIdsG);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"));
//删除成功后check 从下周三到下周日课表是否有数据
groupScheduleTools.getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekXDay(9)), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()),courseId);
Long countB=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
groupScheduleTools.getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekXDay(9)), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()), courseId);
Long countB = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").toJavaList(JSONObject.class).stream()
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())
.filter(e -> null != e.getString("ruleId"))
.filter(e ->e.getString("ruleId").equals(groupRuldId)).count();
Assert.assertTrue(countB==0,"删除当前及后续课次后,课表中后端返回数据有问题,目前还能发现数据"); });
.filter(e -> e.getString("ruleId").equals(groupRuldId)).count();
Assert.assertTrue(countB == 0, "删除当前及后续课次后,课表中后端返回数据有问题,目前还能发现数据");
}
}
@AfterTest(description = "删除此case创建的日程")
public void delData(){
public void delData() {
List<String> ruleIdIds = new ArrayList<>();
//查询这个case创建的相关日程
JSONArray result = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
......@@ -114,7 +116,6 @@ public class TestDelGroupScheduleItem extends UniversalDataScheduling {
}
}
\ No newline at end of file
......@@ -86,7 +86,9 @@ public class TestEditGroupRuleSchedule extends BaseTestImpl {
body.put("endDate", CommUtil.getNDayEndTimeTamp(0)); //结束日期缩短了,改成当天结束
body.put("force", false);
body.put("retainBooking", true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
//4-查看日程详情,check修改内容是否同步变更
groupScheduleTools.getGroupRuleScheduleDetail(ruldId);
......
package com.xiaomai.cases.polar.schedule.group;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
......@@ -27,7 +28,7 @@ import java.util.stream.Collectors;
public class TestEditGroupSchedule extends UniversalDataScheduling {
public static Date now = new Date();
Set<String> scheduleIdsN;
String scheduleIdsN;
String newGroupRuldId="";
......@@ -44,14 +45,13 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
//获取下周四的课次ID(匹配到刚创建的规则ID)
scheduleIdsN = groupScheduleTools.getTableDate(10,groupRuldId);
//如果课次ID有值则继续走删除的case
if ( scheduleIdsN!= null && scheduleIdsN.size() != 0) {
scheduleIdsN.stream().forEach(scheduleId -> {
if (!StringUtils.isEmpty(scheduleIdsN)) {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", false);
body.put("scheduleId", scheduleId);
body.put("scheduleId", scheduleIdsN);
//获取下周四某个时间点的开始时间戳
String startStamp = CommUtil.getWholeHourTimeStamp(10,"13:30");
body.put("startTime", startStamp);
......@@ -65,14 +65,16 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
body.put("force", true);//有冲突时忽略冲突
body.put("retainBooking", false);//不保留学员预约
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//编辑成功后check对应课次详情修改内容是否同步成功
groupScheduleTools.getScheduleItemDetail(scheduleId);
groupScheduleTools.getScheduleItemDetail(scheduleIdsN);
String detailResult = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.chiefCoachId"), chiefCoachIdS);
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.minMemberNum"), "1");
......@@ -82,7 +84,6 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.venueAreaIds").size() == 0, "场地修改后(置空)没生效");
});
}
}
......@@ -90,10 +91,10 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
@Test(description = "编辑当前及后续课次", dependsOnMethods = {"testEditCurrentGroupSchedule"},alwaysRun=true)
public void testEditCurrentAndSubsequentGroupSchedule() {
//获取下周二的课次ID(匹配到刚创建的规则ID)
Set<String> scheduleIds = groupScheduleTools.getTableDate(8,groupRuldId);
String scheduleId = groupScheduleTools.getTableDate(8, groupRuldId);
//如果课次ID有值则继续走编辑的case
if (scheduleIds!= null && scheduleIds.size() != 0) {
scheduleIds.stream().forEach(scheduleId -> {
if (!StringUtils.isEmpty(scheduleId)) {
{
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
......@@ -101,7 +102,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
body.put("applyRestRule", true);//改的时日程当前及后续
body.put("scheduleId", scheduleId);
//获取下周二某个时间点的开始时间戳
String startStamp1 =CommUtil.getWholeHourTimeStamp(8,"13:00");
String startStamp1 = CommUtil.getWholeHourTimeStamp(8, "13:00");
body.put("startTime", startStamp1);
body.put("chiefCoachId", chiefCoachIdS);
......@@ -113,39 +114,38 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
body.put("force", true);//有冲突时忽略冲突
//body.put("retainBooking", true);//保留学员预约,无改动到时间,教练,场地则不需要传此字段
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//编辑成功后check对应课次详情修改内容是否同步成功
checkData(scheduleId,startStamp1);
checkData(scheduleId, startStamp1);
//通过课次详情,活动课次对应的ruldId
newGroupRuldId=XMJSONPath.readPath(dataApi.getApi_response(),"$.result.ruleId");
newGroupRuldId = XMJSONPath.readPath(dataApi.getApi_response(), "$.result.ruleId");
//查看下周三课次是否同步被修改
Set<String> scheduleIdX = groupScheduleTools.getTableDate(9,newGroupRuldId);
String startStamp2 = CommUtil.getWholeHourTimeStamp(9,"13:00");
if (scheduleIdX!= null && scheduleIdX.size() != 0) {
scheduleIdX.stream().forEach(scheduleId1 -> {
String scheduleIdX = groupScheduleTools.getTableDate(9, newGroupRuldId);
String startStamp2 = CommUtil.getWholeHourTimeStamp(9, "13:00");
if (!StringUtils.isEmpty(scheduleIdX)) {
//编辑成功后check同规则中下周三课次详情修改内容是否同步成功
checkData(scheduleId1,startStamp2);
});
checkData(scheduleIdX, startStamp2);
}
});
}
//获取下周一的课次ID,查看下周一课次是否还是原来的(没被修改,还是原来的规则)
Set<String> scheduleId1 = groupScheduleTools.getTableDate(7,groupRuldId);
String startStamp3=CommUtil.getWholeHourTimeStamp(7,"13:00");
if (scheduleId1!= null && scheduleId1.size() != 0) {
scheduleId1.stream().forEach(scheduleId0 -> {
String scheduleId1 = groupScheduleTools.getTableDate(7, groupRuldId);
String startStamp3 = CommUtil.getWholeHourTimeStamp(7, "13:00");
if (!StringUtils.isEmpty(scheduleId1)) {
//编辑成功后check同规则中下周一课次详情
groupScheduleTools.getScheduleItemDetail(scheduleId0);
groupScheduleTools.getScheduleItemDetail(scheduleId1);
String detailResult1 = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.chiefCoachId"), chiefCoachIdS);
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.minMemberNum"), "2");
......@@ -154,19 +154,17 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult1, "$.result.assistCoachIds").containsAll(assistCoachIdS), "助教无修改,但是却变动了");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult1, "$.result.venueAreaIds").containsAll(venueAreaIds), "场地无修改,但是却变动了");
});
}
}
}
/**
* 编辑后通过查看课次详情check数据是否同步被修改
* @param scheduleId
*/
public void checkData(String scheduleId,String tiemStamp){
public void checkData (String scheduleId, String tiemStamp){
groupScheduleTools.getScheduleItemDetail(scheduleId);
String detailResult1 = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.chiefCoachId"), chiefCoachIdS);
......@@ -179,9 +177,8 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
}
@AfterTest(description = "删除此case创建的日程")
public void delData(){
public void delData () {
List<String> ruleIdIds = new ArrayList<>();
//查询这个case创建的相关日程
JSONArray result = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
......@@ -202,16 +199,15 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
}
if (!scheduleIdsN.isEmpty()) {
scheduleIdsN.stream().forEach(scheduleId -> {
//删除case1中编辑独立出去的课次
groupScheduleTools.delGroupScheduleItem(scheduleId);
});
groupScheduleTools.delGroupScheduleItem(scheduleIdsN);
}
}
}
}
\ No newline at end of file
......@@ -126,7 +126,9 @@ public class TestGetGroupScheduleTable extends BaseTestImpl {
body.put("coachId", coachId);
body.put("venueAreaId", venueAreaId);
body.put("statusSet", statusSet);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
int resultCount=Integer.parseInt(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.result.totalCount"));
Assert.assertTrue(resultCount>=totalCount,"查询到的课表数据和预期不一致");
......
......@@ -54,9 +54,9 @@ public class TestDoForceOpenTraining extends BaseCreateTrainingData {
if (status.equals("APPLY_NOT_START")) {
//对报名未开始的活动操作立即成营
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("id", id);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"), "只有报名中的训练营能【立即成营】");
......@@ -80,11 +80,13 @@ public class TestDoForceOpenTraining extends BaseCreateTrainingData {
if(goalN>0){
goalId=XMJSONPath.readPath(dataApi.getApi_response(),"$.result.records[0].id");
JSONObject body1 = new JSONObject();
body1.put("operatorId", dataApi.getLoginInfo().getAdminId());
body1.put("studioId", dataApi.getLoginInfo().getStudioId());
body1.put("brandId", dataApi.getLoginInfo().getBrandId());
body1.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body1.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body1.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body1.put("id", goalId);
xmAppApi.doRequest(RequestType.JSON, params, body1.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body1.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
}
......
......@@ -82,7 +82,7 @@ public class TestDoSignCampOrder extends SelectTargetTrainingCampAndGetInfo {
//退单后再搜索报名记录check
trainingTools.getTrainingApplyRecordsList(this.campId, phone);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 0, "给学员退单后,在报名列表中还能查询到数据");
Thread.sleep(1000);
Thread.sleep(2000);
//退单后check训练营报名记录(入口:报名记录):根据训练营,报名记录状态,来源
List<String> cardState=new ArrayList<>();
......@@ -123,7 +123,7 @@ public class TestDoSignCampOrder extends SelectTargetTrainingCampAndGetInfo {
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"), "签单失败,已报名该训练营无需重复操作");
}
@Test(description = "给学员报名训练营活动构造待支付订单",priority = 1)
@Test(description = "给学员报名训练营活动构造待支付订单",dependsOnMethods = {"testDoSignCampOrder"},alwaysRun = true)
public void testUnpaidOrder() throws InterruptedException {
//搜索目标会员
String phone = "15658063769";
......@@ -131,8 +131,8 @@ public class TestDoSignCampOrder extends SelectTargetTrainingCampAndGetInfo {
if (memberId2.isEmpty()) {
memberId2 = tools.create("晨晨爸爸", phone).getString("result");
}
Thread.sleep(3000);
//报名接口做了重复调用限制,间隔3000秒,否则提示:调用过于频繁,请稍后重试
Thread.sleep(4000);
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
......@@ -149,7 +149,9 @@ public class TestDoSignCampOrder extends SelectTargetTrainingCampAndGetInfo {
campInfo.put("campId", this.campId);
body.put("camp", campInfo);
body.put("paymentWays", new JSONArray());//支付方式传空
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
orderId = XMJSONPath.readPath(xmAppApi.getApi_response(), "$.result");
//报名成功后根据会员手机号,在报名会员列表搜索报名数据
trainingTools.getTrainingApplyRecordsList(this.campId, phone);
......
......@@ -130,7 +130,9 @@ public class TestEditTraining extends BaseCreateTrainingData {
editBody.put("xcxSaleStatus", "YES"); //开启小程序售卖
editBody.put("underlinePrice", 29.9);//可以修改
editBody.put("id", oneKeytTrainingId); //活动ID
xmAppApi.doRequest(RequestType.JSON, params, editBody.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, editBody.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
//5.查看活动详情,check 不能修改项和一修改项是否被同步修改
trainingTools.findTrainingDetailById(oneKeytTrainingId);
//5.1不能修改的字段check(修改后和修改前比对)
......
......@@ -99,7 +99,9 @@ public class TestSearchTrainingAccountRecordsList extends SelectTargetTrainingCa
}
body.put("memberCardStateList", memberCardState);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
//有存量数据,理论上每个查询都会至少有1条数据
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(xmAppApi.getApi_response(), "$.result.records").size() >= flag, "没有搜索到相关数据");
......
......@@ -86,7 +86,9 @@ public class TestSearchTrainingList extends BaseCreateTrainingData {
body.put("courseId", courseId);
body.put("stateList", stateList);
body.put("title", title);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(xmAppApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(xmAppApi.getApi_response(),"$.message"));
//有存量数据,理论上每个查询都会至少有1条数据
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(xmAppApi.getApi_response(),"$.result.records").size()>=1,"没有搜索到相关数据");
......
......@@ -9,6 +9,7 @@ import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.*;
import org.springframework.stereotype.Component;
import org.testng.Assert;
import org.testng.Reporter;
import java.util.List;
......@@ -367,7 +368,9 @@ public class TrainingTools extends XMBaseTest {
payObject.put("voucherResourceIds",new JSONArray());
paymentWays.add(payObject);
body.put("paymentWays",paymentWays);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Reporter.log(XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -418,7 +421,9 @@ public class TrainingTools extends XMBaseTest {
payObject.put("voucherResourceIds",new JSONArray());
paymentWays.add(payObject);
body.put("paymentWays",paymentWays);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......@@ -489,7 +494,9 @@ public class TrainingTools extends XMBaseTest {
body.put("current", 0);
body.put("size", 20);
body.put("memberId", memberId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
......
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