Commit 54902544 by DuJunLi

增加团课课表分享case

parent 590b2972
......@@ -76,7 +76,7 @@ public class GroupScheduleTools extends XMBaseTest {
}
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"));
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
}
......@@ -102,7 +102,7 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("coachId", coachId);
}
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"));
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
return XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result");
}
......@@ -149,7 +149,7 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("force", force);
body.put("ruleId", ruleId);
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"));
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
}
......@@ -235,7 +235,7 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("id", ruldId);
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"));
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
}
......@@ -257,7 +257,7 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("id", scheduleId);
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"));
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
return dataApi.getBodyInJSON().getJSONObject("result");
}
......@@ -270,13 +270,13 @@ public class GroupScheduleTools extends XMBaseTest {
* @date: 2024/6/23 17:46
* @return: com.alibaba.fastjson.JSONArray
**/
public JSONArray getGroupScheduleTable(Long startDate, Long endDate,String courseId) {
public JSONArray getGroupScheduleTable(Long startDate, Long endDate, String courseId) {
setUP("API_getGroupScheduleTable");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
if (courseId.equals("")){
if (courseId.equals("")) {
body.put("courseId", courseId);
}
body.put("startDate", startDate);
......@@ -284,8 +284,7 @@ public class GroupScheduleTools extends XMBaseTest {
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
if (Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalCount")) > 0) {
return dataApi.getBodyInJSON().getJSONObject("result").getJSONArray("timetableGroups").getJSONObject(0).getJSONArray("timetableList");
}
else {
} else {
return null;
}
}
......@@ -320,7 +319,7 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("spanMinutes", 60);
body.put("force", false);
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"));
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
}
......@@ -344,18 +343,19 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("applyRestRule", false);
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"));
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
}
/**
* 获取指定下周某一天的课次ID
*
* @param n
* @return 判断某天没排课 scheduleIds5.size() == 0 || scheduleIds5 == null
*/
public Set<String> getTableDate(int n) {
//查看团课课表
getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekStartDay()), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()),"");
getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekStartDay()), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()), "");
//获取下周周N及后续的课次
String date = CommUtil.oneKeyGetNextWeekXDay(n);//下周N 日期时间戳
int count = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").size();
......@@ -376,24 +376,25 @@ public class GroupScheduleTools extends XMBaseTest {
/**
* 选择匹配到对应规则ID的课次
* 选择匹配到对应规则ID的课次
*
* @param n
* @param ruldId
* @return
*/
public String getTableDate(int n,String ruldId) {
public String getTableDate(int n, String ruldId) {
//查看团课课表
getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekStartDay()), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()),"");
getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekStartDay()), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()), "");
//获取下周周N及后续的课次
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 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))
.filter(e -> e.getString("ruleId").equals(ruldId))
.map(e -> e.getString("scheduleId"))//获取scheduleId
.findFirst().orElse("");
return scheduleIds;
......@@ -404,6 +405,34 @@ public class GroupScheduleTools extends XMBaseTest {
}
/**
* 团课分享课表时获取课表配置
*/
public void getShareScheduleConfig() {
setUP("API_getShareScheduleConfig");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
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"));
}
/**
* 下载课表
* @param data
*/
public void saveShareScheduleConfig(JSONObject data) {
setUP("API_saveShareScheduleConfig");
data.put("operatorId", dataApi.getLoginInfo().getAdminId());
data.put("studioId", dataApi.getLoginInfo().getStudioId());
data.put("brandId", dataApi.getLoginInfo().getBrandId());
dataApi.doRequest(RequestType.JSON, dataparams, data.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
}
}
......
package com.xiaomai.cases.polar.schedule.group;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 团课课表,分享课表-下载课表
*
* @author adu
* data 2024/11/6 10:26
*/
public class TestSaveShareScheduleConfig extends BaseTestImpl {
@Resource(name = "groupScheduleTools")
GroupScheduleTools groupScheduleTools;
@BeforeClass
@Override
public void beforeTest() {
setTestInfo(ApiModule.Polar_Schedule, "API_saveShareScheduleConfig", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
}
@Test(description = "测试团课课表-分享课表-下载课表")
public void testSaveShareScheduleConfig() {
//点击分享获取课表配置信息:默认配置
groupScheduleTools.getShareScheduleConfig();
JSONObject configInfo= XMJSONPath.getJSONObjectByReadPath(dataApi.getApi_response(),"$.result");
//什么都不操作,走默认配置,下载课表
groupScheduleTools.saveShareScheduleConfig(configInfo);
//修改配置,然后操作下载课表check
JSONObject body = new JSONObject();
String shareTitle="阿杜测试团课课表分享";
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("shareTitle",shareTitle);
body.put("showCustomBg", false);
body.put("showCustomQrCode", false);
List<String> showContent=new ArrayList<>();
showContent.add("COACH_NICK_NAME");
showContent.add("AREA_NAME");
body.put("showContent", showContent);
//修改后再调用获取配置接口check是否同步修改
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"));
//查看配置信息
groupScheduleTools.getShareScheduleConfig();
Assert.assertTrue(shareTitle.equals(XMJSONPath.readPath(dataApi.getApi_response(),"$.result.shareTitle")));
System.out.println("***"+XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result.showContent").size());
System.out.println("***"+!XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result.showContent").contains("AREA_NAME"));
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result.showContent").size()==2 && !XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result.showContent").contains("COURSE_COLOR"));
//还原配置
groupScheduleTools.saveShareScheduleConfig(configInfo);
//还原配置后获取配置信息
groupScheduleTools.getShareScheduleConfig();
JSONObject configInfoA= XMJSONPath.getJSONObjectByReadPath(dataApi.getApi_response(),"$.result");
//check configInfoA和configInfo是否相等
Assert.assertTrue(configInfoA.getString("shareTitle").equals(configInfo.getString("shareTitle")),"还原配置后,课表名称没恢复");
Assert.assertTrue(configInfoA.getJSONArray("showContent").containsAll(configInfo.getJSONArray("showContent")),"还原配置后,课表内容展示没恢复默认");
}
}
\ 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