Commit b13a21d3 by DuJunLi

优化代码,解决集成测试报错问题

parent 23a17183
......@@ -61,11 +61,11 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
@AfterTest(description = "删除此case创建的训练营排课日程和训练营活动")
public void delData() {
//直接删除训练营会的,对应的排课日程会被自动删除,校验其他case中已有
if (null!=campId||!campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
}
if (null!=this.campId||!this.campId.isEmpty()) {
this.getTrainingTools().deleteTraining(this.campId);
}
}
}
}
\ No newline at end of file
......@@ -16,16 +16,13 @@ import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
/**
* 删除训练营课次(单个/当前及后续)
*
* @author adu
* data 2024/7/12 17:05
* data 2024/8/1 11:16
*/
public class TestDelCampScheduleItem extends SelectTargetTrainingCampAndGetInfo {
public class TestDelCurrentAndSubsequentCampSchedule extends SelectTargetTrainingCampAndGetInfo {
@Resource(name = "campScheduleTools")
CampScheduleTools campScheduleTools;
String campId = "";
......@@ -57,40 +54,7 @@ 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() {
//获取下周日课次ID(只删除匹配到ruldId的课次)
String scheduleId7 = campScheduleTools.getCampTableDate(13, ruldId);
if (!StringUtils.isEmpty(scheduleId7)) {
//删除本次规则创建的下周日所有的课次
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", 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);
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))
.map(e -> e.getString("scheduleId")).count();//获取scheduleId 的数量
Assert.assertTrue(goalCount == 0, "删除当前课次后,再去课表中查看,后端仍然返回数据");
}
}
@Test(description = "删除当前及后续课次", priority = 1)
@Test(description = "删除当前及后续课次")
public void testDelCurrentAndSubsequentCampSchedule() {
//获取下周六课次ID
String scheduleIds6 = campScheduleTools.getCampTableDate(12, ruldId);
......
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;
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.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 删除训练营课次(单个/当前及后续)
*
* @author adu
* data 2024/7/12 17:05
*/
public class TestDelCurrentCampScheduleItem extends SelectTargetTrainingCampAndGetInfo {
@Resource(name = "campScheduleTools")
CampScheduleTools campScheduleTools;
String campId = "";
String chiefCoachId = "";
String ruldId = "";
int loopNum = 0;
String[] weekDaysArray = {"TUESDAY", "THURSDAY", "SATURDAY", "SUNDAY"};
List<String> weekdaysList = Arrays.asList(weekDaysArray);
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Schedule, "API_delCampScheduleItem", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
// 获取选择的训练营ID
campId = super.campId;
//1.2获取训练营活动的指定教练ID
chiefCoachId = super.chiefCoachId;
//获取目标时间段内 最大有效课时数
loopNum = campScheduleTools.queryExpectedLoopNum(CommUtil.oneKeyGetAddDay(3), super.openEndDate, weekdaysList);
//创建训练营排课:按次数 星期:2,4,6,7
campScheduleTools.oneKeyCreateCampRuleSchedule(campId, chiefCoachId, super.courseId,
super.traineeLowerLimit, super.traineeUpperLimit,
"1140", super.openEndDate, true,
String.valueOf(loopNum));
//查询排课日程:根据训练营和关联课程查询
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");
}
@Test(description = "删除当前课次")
public void testDelCurrentCampScheduleItem() {
//获取下周日课次ID(只删除匹配到ruldId的课次)
String scheduleId7 = campScheduleTools.getCampTableDate(13, ruldId);
if (!StringUtils.isEmpty(scheduleId7)) {
//删除本次规则创建的下周日所有的课次
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", 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);
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))
.map(e -> e.getString("scheduleId")).count();//获取scheduleId 的数量
Assert.assertTrue(goalCount == 0, "删除当前课次后,再去课表中查看,后端仍然返回数据");
}
}
@AfterTest(description = "删除此case创建的训练营排课日程")
public void delData() {
//先删除规则,再操作删除对应的训练营活动,此处顺序不能换,如果先删除训练营活动,对应的排课会自动删除,所以就不用删除排课日程了,这个场景其他case中会体现
if (null != ruldId || !ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId);
//删除日程后check 日程列表数据是否还能搜索到,期望搜索结果数据为空
campScheduleTools.getCampRuleScheduleList(campId, super.courseId, "");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 0, "日程被删除后,对应的排课日程列表还可以查到相关数据");
}
if (null != campId || !campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
}
}
}
\ No newline at end of file
......@@ -26,10 +26,10 @@ import java.util.stream.Collectors;
* data 2024/7/12 17:08
*/
public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo {
public class TestEditCurrentAndSubsequentCampSchedule extends SelectTargetTrainingCampAndGetInfo {
public static Date now = new Date();
String scheduleIdsN;
//String scheduleIdsN;
@Resource(name = "groupScheduleTools")
GroupScheduleTools groupScheduleTools;
@Resource(name = "campScheduleTools")
......@@ -46,7 +46,7 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
public int scheduleClassHourEditBefore = 0;
public int scheduleClassHourEditAfter = 0;
public List<String> venueAreaIdsEditAfter;
// public List<String> venueAreaIdsEditAfter;
public Boolean flag;
@BeforeClass
......@@ -77,48 +77,8 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
}
@Test(description = "编辑当前课次")
public void testEditCurrentCampSchedule() {
//获取本次创建规则中下周日课次ID
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", scheduleIdsN);
body.put("startTime", startStamp);//修改上课时间
body.put("chiefCoachId", chiefCoachId);
body.put("minMemberNum", super.traineeLowerLimit);
body.put("maxMemberNum", super.traineeUpperLimit);
body.put("venueAreaIds", new ArrayList<>());
body.put("assistCoachIds", super.assistCoachIds);//有空改为有数据2个教练
body.put("spanMinutes", 50);
body.put("force", true);//有冲突时忽略冲突
body.put("retainBooking", 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(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 = "编辑当前及后续课次")
public void testEditCurrentAndSubsequentCampSchedule() throws InterruptedException {
//获取存量场地
List<String> venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地");
......@@ -203,8 +163,8 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
}
});
Assert.assertTrue(flag == true, "新规则的场地数据为空了");
//编辑当前及后续课次后,已排课次数量变更check
Assert.assertTrue(scheduleClassHourEditBefore + 1 == scheduleClassHourEditAfter, "编辑当前及后续课次后,训练营已排课次数+1(独立出去的课次 又生成新的一个课次;之前删除的课次,也生成新的课次了)");
//编辑当前及后续课次后,已排课次数量变更check 【独立出去的课次 又生成新的一个课次本次没造该场景】
Assert.assertTrue(scheduleClassHourEditBefore == scheduleClassHourEditAfter, "编辑当前及后续课次后,训练营已排课次数不变(之前删除的课次,也生成新的课次了)");
//新日程的开始日期check
Assert.assertEquals(sDateBefore, CommUtil.getXStartOfDateNextXWeek(5, 1), "新规则的开始日期不对,应该是下周六的时间");
//Assert.assertEquals(eDateBefore.substring(0, 9), super.openEndDate.substring(0, 9), "新规则的结束日期不对");
......@@ -218,8 +178,8 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.venueAreaIds").size() == 0, "课次创建时场地为空,查看课次详情不为空");
}
// 3.check下周日的课次(以独立出去的课次是否受到影响:不受影响)
//因为编辑单个课次 移除了本类,所以独立出去的课次 再本case中不设计了
/*// 3.check下周日的课次(以独立出去的课次是否受到影响:不受影响)
if (!StringUtils.isEmpty(scheduleIdsN)) {
campScheduleTools.getCampScheduleItemDetail(scheduleIdsN);
String detailResult = dataApi.getApi_response();
......@@ -232,9 +192,8 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
//4.check 下周日是否又生成一条新的课次
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), "场地有空改为有数据,但是课次详情中显示不正确哦");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.venueAreaIds").containsAll(venueAreaIds), "场地有空改为有数据,但是课次详情中显示不正确哦");*/
//5.check 下下周二是否生成一条新的课次
campScheduleTools.getCampScheduleTable(targetStartDate, targetendDate);
......@@ -261,10 +220,10 @@ public class TestEditCampScheduleItem extends SelectTargetTrainingCampAndGetInfo
campScheduleTools.delCampRuleSchedule(newRuldId);
}*/
if (null != campId || !campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
if (null != super.campId || !super.campId.isEmpty()) {
this.getTrainingTools().deleteTraining(super.campId);
//训练营被删除后,对应的排课日程会被自动删除check
campScheduleTools.getCampRuleScheduleList(campId, "", "");
campScheduleTools.getCampRuleScheduleList(super.campId, "", "");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 0, "训练营被删除后,对应的排课日程会被自动删除,目前还有相关数据请检查");
......
package com.xiaomai.cases.polar.schedule.camp;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.schedule.group.GroupScheduleTools;
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.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author adu
* data 2024/8/1 11:19
*/
public class TestEditCurrentCampSchedule extends SelectTargetTrainingCampAndGetInfo {
public static Date now = new Date();
String scheduleIdsN;
@Resource(name = "groupScheduleTools")
GroupScheduleTools groupScheduleTools;
@Resource(name = "campScheduleTools")
CampScheduleTools campScheduleTools;
String campId = "";
String chiefCoachId = "";
String ruldId = "";
//获取下周日某个时间点的开始时间戳
String startStamp = CommUtil.getWholeHourTimeStamp(13, "13:30");
public int scheduleClassHourEditBefore = 0;
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Schedule, "API_editCampSchedule", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
// 获取选择的训练营ID
campId = super.campId;
//1.2获取训练营活动的指定教练ID
chiefCoachId = super.chiefCoachId;
//获取目标时间段内 最大有效课时数
String[] weekDaysArray = {"TUESDAY", "THURSDAY", "SATURDAY", "SUNDAY"};
List<String> weekdaysList = Arrays.asList(weekDaysArray);
int loopNum = campScheduleTools.queryExpectedLoopNum(CommUtil.oneKeyGetAddDay(3), super.openEndDate, weekdaysList);
//创建训练营排课:按次数 星期:2,4,6,7
campScheduleTools.oneKeyCreateCampRuleSchedule(campId, chiefCoachId, super.courseId,
super.traineeLowerLimit, super.traineeUpperLimit,
"1140", super.openEndDate, true,
String.valueOf(loopNum));
//查询排课日程:根据训练营和关联课程查询
campScheduleTools.getCampRuleScheduleList(super.campId, super.courseId, "");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 1, "排课创建成功后,日程中没查询到对应数据");
ruldId = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getString("ruleId");
//获取训练营活动已排课课次数
scheduleClassHourEditBefore = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getJSONObject("campVO").getIntValue("scheduleClassHour");
}
@Test(description = "编辑当前课次")
public void testEditCurrentCampSchedule() {
//获取本次创建规则中下周日课次ID
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", scheduleIdsN);
body.put("startTime", startStamp);//修改上课时间
body.put("chiefCoachId", chiefCoachId);
body.put("minMemberNum", super.traineeLowerLimit);
body.put("maxMemberNum", super.traineeUpperLimit);
body.put("venueAreaIds", new ArrayList<>());
body.put("assistCoachIds", super.assistCoachIds);//有空改为有数据2个教练
body.put("spanMinutes", 50);
body.put("force", true);//有冲突时忽略冲突
body.put("retainBooking", 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(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, "课次创建时场地为空,查看课次详情不为空");
}
}
@AfterTest(description = "删除此case创建的训练营排课日程")
public void delData() {
if (null != campId || !campId.isEmpty()) {
this.getTrainingTools().deleteTraining(campId);
//训练营被删除后,对应的排课日程会被自动删除check
campScheduleTools.getCampRuleScheduleList(campId, "", "");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 0, "训练营被删除后,对应的排课日程会被自动删除,目前还有相关数据请检查");
}
}
}
\ No newline at end of file
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;
import com.xiaomai.enums.LoginAccount;
......@@ -14,11 +13,6 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 删除课次(删除当前课次/删除当前及后续课次)
*
......@@ -26,7 +20,7 @@ import java.util.stream.Collectors;
* data 2024/6/30 17:02
*/
public class TestDelGroupScheduleItem extends UniversalDataScheduling {
public class TestDelCurrentAndSubsequentGroupSchedule extends UniversalDataScheduling {
@BeforeClass
@Override
......@@ -36,34 +30,8 @@ public class TestDelGroupScheduleItem extends UniversalDataScheduling {
}
@Test(description = "删除当前课次")
public void testDelCurrentGroupSchedule() {
//获取下周四的课次ID(匹配到刚创建的规则ID)
String scheduleId = groupScheduleTools.getTableDate(10, groupRuldId);
//如果课次ID有值则继续走删除的case
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()
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())
.filter(e -> e.getString("scheduleId").equals(scheduleId)).count();
Assert.assertTrue(countA == 0, "删除课次后,课表中后端返回数据有问题,目前还能发现数据");
}
}
@Test(description = "删除当前及后续课次", dependsOnMethods = {"testDelCurrentGroupSchedule"}, alwaysRun = true)
@Test(description = "删除当前及后续课次")
public void testDelCurrentAndSubsequentGroupSchedule() {
//获取下周三的课次ID(匹配到对应的规则ID)
String scheduleIdsG = groupScheduleTools.getTableDate(9, groupRuldId);
......@@ -93,29 +61,16 @@ public class TestDelGroupScheduleItem extends UniversalDataScheduling {
@AfterTest(description = "删除此case创建的日程")
public void delData() {
List<String> ruleIdIds = new ArrayList<>();
//查询这个case创建的相关日程
JSONArray result = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
int count = result.size();
if (count > 0) {//如果有数据,则获取对应日程ID
ruleIdIds = result.stream().map(obj -> {
JSONObject ruldIdInfo = (JSONObject) obj;
return ruldIdInfo.getString("ruleId");
}
).collect(Collectors.toList());
}
if (ruleIdIds != null) {//获取到的日程ID不为空时,则逐个删除相关日程
ruleIdIds.stream().forEach(ruleId -> {
if (!StringUtils.isEmpty(groupRuldId)) {//获取到的日程ID不为空时,则逐个删除相关日程
//删除对应日程
groupScheduleTools.delGroupRuleSchedule(ruleId, true);
});
groupScheduleTools.delGroupRuleSchedule(groupRuldId, true);
}
}
}
}
\ No newline at end of file
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;
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.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author adu
* data 2024/8/1 10:00
*/
public class TestDelCurrentSingleGroupSchedule extends UniversalDataScheduling{
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Schedule, "API_delGroupScheduleItem", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
}
@Test(description = "删除当前课次")
public void testDelCurrentSingleGroupSchedule() {
//获取下周四的课次ID(匹配到刚创建的规则ID)
String scheduleId = groupScheduleTools.getTableDate(10, groupRuldId);
//如果课次ID有值则继续走删除的case
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()
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())
.filter(e -> e.getString("scheduleId").equals(scheduleId)).count();
Assert.assertTrue(countA == 0, "删除课次后,课表中后端返回数据有问题,目前还能发现数据");
}
}
@AfterTest(description = "删除此case创建的日程")
public void delData() {
if (!StringUtils.isEmpty(groupRuldId)) {//获取到的日程ID不为空时,则逐个删除相关日程
//删除对应日程
groupScheduleTools.delGroupRuleSchedule(groupRuldId, true);
}
}
}
\ No newline at end of file
package com.xiaomai.cases.polar.schedule.group;
import com.alibaba.druid.util.StringUtils;
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.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Date;
/**
* @author adu
* data 2024/8/1 11:09
*/
public class TestEditCurrentAndSubsequentGroupSchedule extends UniversalDataScheduling{
public static Date now = new Date();
String newGroupRuldId="";
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Schedule, "API_editGroupSchedule", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
}
@Test(description = "编辑当前及后续课次")
public void testEditCurrentAndSubsequentGroupSchedule() {
//获取下周二的课次ID(匹配到刚创建的规则ID)
String scheduleId = groupScheduleTools.getTableDate(8, groupRuldId);
//如果课次ID有值则继续走编辑的case
if (!StringUtils.isEmpty(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);
//获取下周二某个时间点的开始时间戳
String startStamp1 = CommUtil.getWholeHourTimeStamp(8, "13:00");
body.put("startTime", startStamp1);
body.put("chiefCoachId", chiefCoachIdS);
body.put("minMemberNum", 6);//修改开课人数
body.put("maxMemberNum", 999);
body.put("venueAreaIds", venueAreaIds);
body.put("assistCoachIds", new ArrayList<>());//修改教练
body.put("spanMinutes", 50);
body.put("force", true);//有冲突时忽略冲突
//body.put("retainBooking", 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);
//通过课次详情,活动课次对应的ruldId
newGroupRuldId = XMJSONPath.readPath(dataApi.getApi_response(), "$.result.ruleId");
//查看下周三课次是否同步被修改
String scheduleIdX = groupScheduleTools.getTableDate(9, newGroupRuldId);
String startStamp2 = CommUtil.getWholeHourTimeStamp(9, "13:00");
if (!StringUtils.isEmpty(scheduleIdX)) {
//编辑成功后check同规则中下周三课次详情修改内容是否同步成功
checkData(scheduleIdX, startStamp2);
}
}
//获取下周一的课次ID,查看下周一课次是否还是原来的(没被修改,还是原来的规则)
String scheduleId1 = groupScheduleTools.getTableDate(7, groupRuldId);
String startStamp3 = CommUtil.getWholeHourTimeStamp(7, "13:00");
if (!StringUtils.isEmpty(scheduleId1)) {
//编辑成功后check同规则中下周一课次详情
groupScheduleTools.getScheduleItemDetail(scheduleId1);
String detailResult1 = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.chiefCoachId"), chiefCoachIdS);
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.minMemberNum"), "2");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.maxMemberNum"), "999");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.startTime"), startStamp3);
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){
groupScheduleTools.getScheduleItemDetail(scheduleId);
String detailResult1 = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.chiefCoachId"), chiefCoachIdS);
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.minMemberNum"), "6");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.maxMemberNum"), "999");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.startTime"), tiemStamp);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult1, "$.result.assistCoachIds").size() == 0, "助教修改后(置空)没生效");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult1, "$.result.venueAreaIds").containsAll(venueAreaIds), "场地无修改,但是却变动了");
}
@AfterTest(description = "删除此case创建的日程")
public void delData () {
if (!StringUtils.isEmpty(groupRuldId)) {//获取到的日程ID不为空时,则逐个删除相关日程
//删除对应原日程
groupScheduleTools.delGroupRuleSchedule(groupRuldId, true);
}
if (!StringUtils.isEmpty(newGroupRuldId)) {
//删除编辑当前及后续生成的新规则
groupScheduleTools.delGroupRuleSchedule(newGroupRuldId, true);
}
}
}
\ No newline at end of file
......@@ -17,7 +17,6 @@ import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
......@@ -26,7 +25,7 @@ import java.util.stream.Collectors;
* data 2024/7/2 10:45
*/
public class TestEditGroupSchedule extends UniversalDataScheduling {
public class TestEditCurrentGroupSchedule extends UniversalDataScheduling {
public static Date now = new Date();
String scheduleIdsN;
String newGroupRuldId="";
......@@ -88,114 +87,15 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
}
@Test(description = "编辑当前及后续课次", dependsOnMethods = {"testEditCurrentGroupSchedule"},alwaysRun=true)
public void testEditCurrentAndSubsequentGroupSchedule() {
//获取下周二的课次ID(匹配到刚创建的规则ID)
String scheduleId = groupScheduleTools.getTableDate(8, groupRuldId);
//如果课次ID有值则继续走编辑的case
if (!StringUtils.isEmpty(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);
//获取下周二某个时间点的开始时间戳
String startStamp1 = CommUtil.getWholeHourTimeStamp(8, "13:00");
body.put("startTime", startStamp1);
body.put("chiefCoachId", chiefCoachIdS);
body.put("minMemberNum", 6);//修改开课人数
body.put("maxMemberNum", 999);
body.put("venueAreaIds", venueAreaIds);
body.put("assistCoachIds", new ArrayList<>());//修改教练
body.put("spanMinutes", 50);
body.put("force", true);//有冲突时忽略冲突
//body.put("retainBooking", 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);
//通过课次详情,活动课次对应的ruldId
newGroupRuldId = XMJSONPath.readPath(dataApi.getApi_response(), "$.result.ruleId");
//查看下周三课次是否同步被修改
String scheduleIdX = groupScheduleTools.getTableDate(9, newGroupRuldId);
String startStamp2 = CommUtil.getWholeHourTimeStamp(9, "13:00");
if (!StringUtils.isEmpty(scheduleIdX)) {
//编辑成功后check同规则中下周三课次详情修改内容是否同步成功
checkData(scheduleIdX, startStamp2);
}
}
//获取下周一的课次ID,查看下周一课次是否还是原来的(没被修改,还是原来的规则)
String scheduleId1 = groupScheduleTools.getTableDate(7, groupRuldId);
String startStamp3 = CommUtil.getWholeHourTimeStamp(7, "13:00");
if (!StringUtils.isEmpty(scheduleId1)) {
//编辑成功后check同规则中下周一课次详情
groupScheduleTools.getScheduleItemDetail(scheduleId1);
String detailResult1 = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.chiefCoachId"), chiefCoachIdS);
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.minMemberNum"), "2");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.maxMemberNum"), "999");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.startTime"), startStamp3);
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){
groupScheduleTools.getScheduleItemDetail(scheduleId);
String detailResult1 = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.chiefCoachId"), chiefCoachIdS);
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.minMemberNum"), "6");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.maxMemberNum"), "999");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.startTime"), tiemStamp);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult1, "$.result.assistCoachIds").size() == 0, "助教修改后(置空)没生效");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult1, "$.result.venueAreaIds").containsAll(venueAreaIds), "场地无修改,但是却变动了");
}
@AfterTest(description = "删除此case创建的日程")
public void delData () {
List<String> ruleIdIds = new ArrayList<>();
//查询这个case创建的相关日程
JSONArray result = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
int count = result.size();
if (count > 0) {//如果有数据,则获取对应日程ID
ruleIdIds = result.stream().map(obj -> {
JSONObject ruldIdInfo = (JSONObject) obj;
return ruldIdInfo.getString("ruleId");
}
).collect(Collectors.toList());
}
if (ruleIdIds != null) {//获取到的日程ID不为空时,则逐个删除相关日程
ruleIdIds.stream().forEach(ruleId -> {
//删除对应日程
groupScheduleTools.delGroupRuleSchedule(ruleId, true);
});
if (!StringUtils.isEmpty(groupRuldId)) {//获取到的日程ID不为空时,则逐个删除相关日程
//删除对应日程
groupScheduleTools.delGroupRuleSchedule(groupRuldId, true);
}
if (!scheduleIdsN.isEmpty()) {
......
......@@ -83,7 +83,7 @@ public class TestEditGroupRuleSchedule extends BaseTestImpl {
body.put("assistCoachIds", new ArrayList<>()); //有数据AB改成空
body.put("ruleId", ruldId);
body.put("spanMinutes", 50);
body.put("endDate", CommUtil.getNDayEndTimeTamp(0)); //结束日期缩短了,改成当天结束
body.put("endDate", todayEndDateTimeTamp); //结束日期缩短了,改成当天结束
body.put("force", false);
body.put("retainBooking", true);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers);
......
......@@ -31,11 +31,7 @@ public class TestDoSignCampOrder extends SelectTargetTrainingCampAndGetInfo {
TrainingTools trainingTools;
@Resource(name = "tools")
Tools tools;
@Resource(name = "orderTools")
OrderTools orderTools;
String memberId = "";
String memberId2 = "";
String orderId = "";
@BeforeClass
@Override
......@@ -52,7 +48,8 @@ public class TestDoSignCampOrder extends SelectTargetTrainingCampAndGetInfo {
if (memberId.isEmpty()) {
memberId = tools.create("阿杜", phone).getString("result");
}
//给会员报名
//给会员报名,报名前先等待3秒,防止上一个case中有创建订单的接口,这样不会报错(创建订单接口做了3秒的重复调用限制)
Thread.sleep(3000);
trainingTools.doSignCampOrder(memberId, this.price, this.campId,"");
Thread.sleep(1000);
//报名成功后根据会员手机号,在报名会员列表搜索报名数据
......@@ -123,49 +120,6 @@ public class TestDoSignCampOrder extends SelectTargetTrainingCampAndGetInfo {
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getApi_response(), "$.message"), "签单失败,已报名该训练营无需重复操作");
}
@Test(description = "给学员报名训练营活动构造待支付订单",dependsOnMethods = {"testDoSignCampOrder"},alwaysRun = true)
public void testUnpaidOrder() throws InterruptedException {
//搜索目标会员
String phone = "15658063769";
memberId2 = trainingTools.searchTargerMember(phone);
if (memberId2.isEmpty()) {
memberId2 = tools.create("晨晨爸爸", phone).getString("result");
}
//报名接口做了重复调用限制,间隔3000秒,否则提示:调用过于频繁,请稍后重试
Thread.sleep(4000);
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("salesmanId", xmAppApi.getLoginInfo().getAdminId());
body.put("operationTime", TimeUtils.getCurrentTime());
body.put("objectId", RandomStringUtil.randomString(20));
body.put("memberId", memberId2);
body.put("receivableAmount", this.price);
JSONObject campInfo = new JSONObject();
campInfo.put("campId", this.campId);
body.put("camp", campInfo);
body.put("paymentWays", new JSONArray());//支付方式传空
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);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 1, "给学员报名后,在报名列表没查询到数据");
//check订单 待支付状态
Assert.assertEquals(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getString("state"), "WAITING");
//操作取消订单
orderTools.cancel(orderId);
trainingTools.getTrainingApplyRecordsList(this.campId, phone);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 0, "取消学员订单后,在报名列表中还能查询到数据");
}
@AfterTest(description = "删除此case创建的训练营活动-退单/取消订单后可以删除活动")
public void delData() {
......
......@@ -5,7 +5,6 @@ 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.RandomStringUtil;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
......@@ -14,9 +13,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 编辑训练营活动
......@@ -27,11 +23,10 @@ import java.util.stream.Collectors;
* data 2024/7/3 20:51
*/
public class TestEditTraining extends BaseCreateTrainingData {
public class TestEditNoPublishTraining extends BaseCreateTrainingData {
@Resource(name = "trainingTools")
TrainingTools trainingTools;
String trainingId = "";
String oneKeytTrainingId = "";
@BeforeClass
@Override
......@@ -41,7 +36,7 @@ public class TestEditTraining extends BaseCreateTrainingData {
}
@Test(description = "测试编辑未发布的训练营活动")
public void testEditTraining() {
public void testEditNoPublishTraining() {
//1创建未发布的训练营活动
String title = "杭州减肥训练营-未发布" + RandomStringUtil.randomString(3);
trainingId = trainingTools.createTrainingNoPublish(title, courseId, trainerListIdS);
......@@ -87,65 +82,7 @@ public class TestEditTraining extends BaseCreateTrainingData {
}
@Test(description = "编辑已发布训练营活动", priority = 1)
public void editPublishTraining() throws InterruptedException {
//1.查询关联对应课程的活动数据
trainingTools.searchTrainingList(courseId, "", new ArrayList<>());
int listCountBefore = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records").size();
//2.创建已发布的训练营活动,报名开始时间晚于当前时间半小时
oneKeytTrainingId = trainingTools.oneKeyCreateTraining(courseId, trainerListIdS, CommUtil.getTodayGoalTime(30));
Thread.sleep(2000);
//3.列表搜索数据check
trainingTools.searchTrainingList(courseId, "", new ArrayList<>());
Long list = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records").toJavaList(JSONObject.class).stream()
.filter(object -> object.getString("id").equals(oneKeytTrainingId)).count();
Assert.assertTrue(list == 1, "训练营活动创建成功列表数据没增加");
JSONObject goalObject = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records").toJavaList(JSONObject.class).stream()
.filter(object -> object.getString("id").equals(oneKeytTrainingId)).findFirst().orElse(null);//返回第一个对象,没有就返回空
if (goalObject != null) {
String title = goalObject.getString("title");
String applyEndTime = goalObject.getString("applyEndTime");
String applyStartTime = goalObject.getString("applyStartTime");
String openStartDate = goalObject.getString("openStartDate");
String openEndDate = goalObject.getString("openEndDate");
//4.编辑已发布的活动(训练营名称,关联课程,开营时间,总课次数,售价,报名开始时间,报名结束时间不能修改)check不能修改的传值后也不会改变
JSONObject editBody = new JSONObject();
editBody.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
editBody.put("studioId", xmAppApi.getLoginInfo().getStudioId()); // 场馆
editBody.put("brandId", xmAppApi.getLoginInfo().getBrandId());
editBody.put("applyEndTime", applyEndTime);//报名结束时间
editBody.put("applyStartTime", applyStartTime);//报名开始时间
editBody.put("courseId", courseId); //关联课程ID
editBody.put("creatorId", xmAppApi.getLoginInfo().getAdminId()); // 创建人即操作者
editBody.put("openEndDate", openEndDate); //开营结束时间
editBody.put("openStartDate", openStartDate); //开营开始时间
editBody.put("price", 10); //售卖价格
editBody.put("surfaceUrl", "https://xiaomai-res.oss-cn-hangzhou.aliyuncs.com/xmfit/course_cover/training_camp_0.png"); // 默认活动封面图
editBody.put("title", "title");//名称不能修改,这里故意修改了,等保存后check数据
editBody.put("totalClassHour", 20); // 总课时数,不能修改,这里故意修改了,等保存后check数据
editBody.put("traineeLowerLimit", 1); // 开营人数
editBody.put("traineeUpperLimit", 99); // 人数上限
editBody.put("trainerList", trainerListIdS); // 上课教练
editBody.put("xcxSaleStatus", "YES"); //开启小程序售卖
editBody.put("underlinePrice", 29.9);//可以修改
editBody.put("id", oneKeytTrainingId); //活动ID
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(修改后和修改前比对)
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.title"), title);
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalClassHour"), "2");
Assert.assertEquals(Double.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.price")), 0.00);
//5.2可以修改字段check是否被同步修改
Assert.assertEquals(Double.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.underlinePrice")), 29.90);
}
}
@AfterTest(description = "删除此case创建的训练营")
......@@ -153,9 +90,6 @@ public class TestEditTraining extends BaseCreateTrainingData {
if (!trainingId.isEmpty()) {
trainingTools.deleteTraining(trainingId);
}
if (!oneKeytTrainingId.isEmpty()) {
trainingTools.deleteTraining(oneKeytTrainingId);
}
}
......
package com.xiaomai.cases.polar.training;
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.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.ArrayList;
/**
* @author adu
* data 2024/8/1 09:45
*/
public class TestEditPublishTraining extends BaseCreateTrainingData{
@Resource(name = "trainingTools")
TrainingTools trainingTools;
String oneKeytTrainingId = "";
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Training, "API_editTraining", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
}
@Test(description = "编辑已发布训练营活动")
public void editPublishTraining() throws InterruptedException {
//1.查询关联对应课程的活动数据
trainingTools.searchTrainingList(courseId, "", new ArrayList<>());
int listCountBefore = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records").size();
//2.创建已发布的训练营活动,报名开始时间晚于当前时间半小时
oneKeytTrainingId = trainingTools.oneKeyCreateTraining(courseId, trainerListIdS, CommUtil.getTodayGoalTime(30));
Thread.sleep(2000);
//3.列表搜索数据check
trainingTools.searchTrainingList(courseId, "", new ArrayList<>());
Long list = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records").toJavaList(JSONObject.class).stream()
.filter(object -> object.getString("id").equals(oneKeytTrainingId)).count();
Assert.assertTrue(list == 1, "训练营活动创建成功列表数据没增加");
JSONObject goalObject = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records").toJavaList(JSONObject.class).stream()
.filter(object -> object.getString("id").equals(oneKeytTrainingId)).findFirst().orElse(null);//返回第一个对象,没有就返回空
if (goalObject != null) {
String title = goalObject.getString("title");
String applyEndTime = goalObject.getString("applyEndTime");
String applyStartTime = goalObject.getString("applyStartTime");
String openStartDate = goalObject.getString("openStartDate");
String openEndDate = goalObject.getString("openEndDate");
//4.编辑已发布的活动(训练营名称,关联课程,开营时间,总课次数,售价,报名开始时间,报名结束时间不能修改)check不能修改的传值后也不会改变
JSONObject editBody = new JSONObject();
editBody.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
editBody.put("studioId", xmAppApi.getLoginInfo().getStudioId()); // 场馆
editBody.put("brandId", xmAppApi.getLoginInfo().getBrandId());
editBody.put("applyEndTime", applyEndTime);//报名结束时间
editBody.put("applyStartTime", applyStartTime);//报名开始时间
editBody.put("courseId", courseId); //关联课程ID
editBody.put("creatorId", xmAppApi.getLoginInfo().getAdminId()); // 创建人即操作者
editBody.put("openEndDate", openEndDate); //开营结束时间
editBody.put("openStartDate", openStartDate); //开营开始时间
editBody.put("price", 10); //售卖价格
editBody.put("surfaceUrl", "https://xiaomai-res.oss-cn-hangzhou.aliyuncs.com/xmfit/course_cover/training_camp_0.png"); // 默认活动封面图
editBody.put("title", "title");//名称不能修改,这里故意修改了,等保存后check数据
editBody.put("totalClassHour", 20); // 总课时数,不能修改,这里故意修改了,等保存后check数据
editBody.put("traineeLowerLimit", 1); // 开营人数
editBody.put("traineeUpperLimit", 99); // 人数上限
editBody.put("trainerList", trainerListIdS); // 上课教练
editBody.put("xcxSaleStatus", "YES"); //开启小程序售卖
editBody.put("underlinePrice", 29.9);//可以修改
editBody.put("id", oneKeytTrainingId); //活动ID
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(修改后和修改前比对)
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.title"), title);
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalClassHour"), "2");
Assert.assertEquals(Double.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.price")), 0.00);
//5.2可以修改字段check是否被同步修改
Assert.assertEquals(Double.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.underlinePrice")), 29.90);
}
}
@AfterTest(description = "删除此case创建的训练营")
public void delData() {
if (!oneKeytTrainingId.isEmpty()) {
trainingTools.deleteTraining(oneKeytTrainingId);
}
}
}
\ No newline at end of file
package com.xiaomai.cases.polar.training;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.finance.order.OrderTools;
import com.xiaomai.cases.polar.member.Tools;
import com.xiaomai.cases.polar.schedule.camp.SelectTargetTrainingCampAndGetInfo;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.RandomStringUtil;
import com.xiaomai.utils.TimeUtils;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
/**
* @author adu
* data 2024/8/1 13:55
*/
public class TestUnpaidCampOrder extends SelectTargetTrainingCampAndGetInfo {
@Resource(name = "trainingTools")
TrainingTools trainingTools;
@Resource(name = "tools")
Tools tools;
@Resource(name = "orderTools")
OrderTools orderTools;
String memberId2 = "";
String orderId = "";
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Training, "API_signOrderCamp", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
}
@Test(description = "给学员报名训练营活动构造待支付订单")
public void testUnpaidOrder() throws InterruptedException {
//搜索目标会员
String phone = "15658063769";
memberId2 = trainingTools.searchTargerMember(phone);
if (memberId2.isEmpty()) {
memberId2 = tools.create("晨晨爸爸", phone).getString("result");
}
//报名接口做了重复调用限制,间隔3000秒,否则提示:调用过于频繁,请稍后重试
Thread.sleep(3000);
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("salesmanId", xmAppApi.getLoginInfo().getAdminId());
body.put("operationTime", TimeUtils.getCurrentTime());
body.put("objectId", RandomStringUtil.randomString(20));
body.put("memberId", memberId2);
body.put("receivableAmount", this.price);
JSONObject campInfo = new JSONObject();
campInfo.put("campId", this.campId);
body.put("camp", campInfo);
body.put("paymentWays", new JSONArray());//支付方式传空
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);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 1, "给学员报名后,在报名列表没查询到数据");
//check订单 待支付状态
Assert.assertEquals(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").getJSONObject(0).getString("state"), "WAITING");
//操作取消订单
orderTools.cancel(orderId);
trainingTools.getTrainingApplyRecordsList(this.campId, phone);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result").size() == 0, "取消学员订单后,在报名列表中还能查询到数据");
}
@AfterTest(description = "删除此case创建的训练营活动-退单/取消订单后可以删除活动")
public void delData() {
if (!this.campId.isEmpty()) {
trainingTools.deleteTraining(this.campId);
}
}
}
\ No newline at end of file
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