Commit a5ebc163 by zhangying

创建和删除乐器陪练课

parent 7166251a
package com.live.cases.apollo;
import com.alibaba.fastjson.JSONObject;
import com.live.enums.ApiModele;
import com.live.enums.RequestType;
import com.live.enums.Terminal;
import com.live.utils.RandomStringUtil;
import com.live.utils.XMBaseTest;
import com.live.xmutils.GetOnlyOneClassLiveListData;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Created by zhangying on 2021/1/30
*/
public class TestCreateOnlyOneClassLive extends XMBaseTest {
@BeforeMethod
public void beforeTest() {
xmAppApi.setApiModule(ApiModele.CloudClass_apollo) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_createCourse") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
super.beforeTest();
System.out.println(xmAppApi);
}
/**
* 测试创建乐器陪练课
*/
@Test
public void testGetOnlyOneClassLiveList() {
JSONObject onlyOneClassLive = new JSONObject();
String courseName = RandomStringUtil.randomNumber(14, "live_course_");
onlyOneClassLive.put("courseName",courseName );
onlyOneClassLive.put("teacherId",xmAppApi.getLoginInfo().getTid());
onlyOneClassLive.put("startTime",System.currentTimeMillis() + 60 * 1000);
onlyOneClassLive.put("endTime",System.currentTimeMillis() + 60 * 60 * 1000);
onlyOneClassLive.put("needRecord","YES");
onlyOneClassLive.put("liveType","SMALL_CLASS_ONLY_ONE");
onlyOneClassLive.put("consumeHourNum",1);
onlyOneClassLive.put("consumeClassTime","1");
onlyOneClassLive.put("autoSendReport","AUTO");
onlyOneClassLive.put("consumeClassTime","30");
onlyOneClassLive.put("consumeClassTime","30");
onlyOneClassLive.put("whetherRecord","YES");
xmAppApi.doRequest(RequestType.JSON, params, onlyOneClassLive.toJSONString(), headers);
System.out.println(xmAppApi);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
GetOnlyOneClassLiveListData getOnlyOneClassLiveListData = new GetOnlyOneClassLiveListData();
JSONObject liveList = getOnlyOneClassLiveListData.getOnlyOneClassLiveList() ;
JSONObject liveCourse = liveList.getJSONObject("result").getJSONArray("records").getJSONObject(0);
String courseName1 = (String) liveCourse.get("courseName");
System.out.println("courseName ="+courseName);
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("操作成功!", jsonBody.getString("message"));
Assert.assertEquals(courseName, courseName1);
}
}
package com.live.cases.apollo;
import com.alibaba.fastjson.JSONObject;
import com.live.enums.ApiModele;
import com.live.enums.RequestType;
import com.live.enums.Terminal;
import com.live.utils.XMBaseTest;
import com.live.xmutils.GetOnlyOneClassLiveListData;
import com.live.xmutils.GetOnlyOneCourseData;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Created by zhangying on 2021/1/30
*/
public class TestDelOnlyOneClassLive extends XMBaseTest {
@BeforeMethod
public void beforeTest() {
xmAppApi.setApiModule(ApiModele.CloudClass_apollo) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_delCourse") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
super.beforeTest();
System.out.println(xmAppApi);
}
/**
* 测试删除乐器陪练课
*/
@Test
public void testDelOnlyOneClassLive() {
GetOnlyOneCourseData getOnlyOneCourseData=new GetOnlyOneCourseData();
JSONObject onlyOneClassCourse = getOnlyOneCourseData.getOnlyOneCourseList();
JSONObject liveCourse = onlyOneClassCourse.getJSONObject("result").getJSONArray("records").getJSONObject(0);
String liveCourseId = (String) liveCourse.get("liveCourseId");
if (liveCourseId == null){
onlyOneClassCourse = getOnlyOneCourseData.creatOnlyOneCourse();
liveCourseId = (String) onlyOneClassCourse.get("liveCourseId");
}
System.out.println("liveCourseId ="+liveCourseId);
GetOnlyOneClassLiveListData getOnlyOneClassLiveListData = new GetOnlyOneClassLiveListData();
JSONObject liveList = getOnlyOneClassLiveListData.getOnlyOneClassLiveList() ;
JSONObject liveCourseData = liveList.getJSONObject("result").getJSONArray("records").getJSONObject(0);
String courseName = (String) liveCourseData.get("courseName");
System.out.println("courseName ="+courseName);
JSONObject jsonObject = new JSONObject();
jsonObject.put("liveCourseId",liveCourseId);
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
JSONObject liveList1 = getOnlyOneClassLiveListData.getOnlyOneClassLiveList() ;
JSONObject liveCourseData1 = liveList1.getJSONObject("result").getJSONArray("records").getJSONObject(0);
String courseName1 = (String) liveCourseData1.get("courseName");
System.out.println("courseName ="+courseName);
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("操作成功!", jsonBody.getString("message"));
Assert.assertNotEquals(courseName, courseName1);
}
}
package com.live.xmutils;
import com.alibaba.fastjson.JSONObject;
import com.live.enums.ApiModele;
import com.live.enums.RequestType;
import com.live.enums.Terminal;
import com.live.utils.XMBaseTest;
import org.testng.Assert;
/**
* Created by zhangying on 2021/1/28
*/
public class GetOnlyOneClassLiveListData extends XMBaseTest {
/**
* 测试乐器陪练课列表
*/
public JSONObject getOnlyOneClassLiveList() {
dataApi.setApiModule(ApiModele.CloudClass_apollo) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_getOnlyOneClassLiveList") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
super.beforeDataRequest();
JSONObject jsonObject = new JSONObject();
jsonObject.put("instId","1235115978015883266");
jsonObject.put("current","1");
jsonObject.put("size","10");
dataApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
System.out.println(dataApi);
JSONObject jsonBody = dataApi.getBodyInJSON();
return jsonBody;
}
}
package com.live.xmutils;
import com.alibaba.fastjson.JSONObject;
import com.live.enums.ApiModele;
import com.live.enums.RequestType;
import com.live.enums.Terminal;
import com.live.utils.RandomStringUtil;
import com.live.utils.XMBaseTest;
import java.util.HashMap;
import java.util.Map;
public class GetOnlyOneCourseData extends XMBaseTest {
public JSONObject getOnlyOneCourseList() {
dataApi.setApiModule(ApiModele.CloudClass_apollo) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_getOnlyOneClassLiveList") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
super.beforeDataRequest();
Map bodyMap = new HashMap();
bodyMap.put("current", 1);
bodyMap.put("instId", "1235115978015883266");
bodyMap.put("size", 10);
String bodydata = JSONObject.toJSONString(bodyMap);
dataApi.doRequest(RequestType.JSON, params, bodydata, dataheadrs);
JSONObject liveCourseList=dataApi.getBodyInJSON();
return liveCourseList;
}
public JSONObject creatOnlyOneCourse() {
dataApi.setApiModule(ApiModele.CloudClass_apollo)
.setApiName("API_createCourse")
.setLoginUser("zhangy-b")
.setTerminal(Terminal.B);
super.beforeDataRequest();
dataApi.doRequest(RequestType.JSON, params, buildCreateLargeClassLiveParam().toJSONString(), dataheadrs);
JSONObject liveCourse=dataApi.getBodyInJSON();
return liveCourse;
}
//组装乐器陪练直播新增的数据
public JSONObject buildCreateLargeClassLiveParam() {
JSONObject onlyOneClassLive = new JSONObject();
onlyOneClassLive.put("courseName", RandomStringUtil.randomNumber(14, "onlyOne_course_"));
onlyOneClassLive.put("teacherId",xmAppApi.getLoginInfo().getTid());
onlyOneClassLive.put("startTime",System.currentTimeMillis() + 60 * 1000);
onlyOneClassLive.put("endTime",System.currentTimeMillis() + 30 * 60 * 1000);
onlyOneClassLive.put("needRecord","YES");
onlyOneClassLive.put("liveType","SMALL_CLASS_ONLY_ONE");
onlyOneClassLive.put("consumeHourNum",1);
onlyOneClassLive.put("consumeClassTime","1");
onlyOneClassLive.put("autoSendReport","AUTO");
onlyOneClassLive.put("consumeClassTime","30");
onlyOneClassLive.put("consumeClassTime","30");
onlyOneClassLive.put("whetherRecord","YES");
return onlyOneClassLive;
}
}
...@@ -91,6 +91,17 @@ ...@@ -91,6 +91,17 @@
"apiContentType": "application/json;charset=utf-8", "apiContentType": "application/json;charset=utf-8",
"apiName": "查询乐器陪练课列表", "apiName": "查询乐器陪练课列表",
"desc": "查询乐器陪练课列表" "desc": "查询乐器陪练课列表"
},
"API_createCourse": {
"apiPath": "/apollo/public/businessLive/createCourse",
"apiContentType": "application/json;charset=utf-8",
"apiName": "创建直播课",
"desc": "创建直播课"
},
"API_delCourse": {
"apiPath": "/apollo/public/businessLive/delCourse",
"apiContentType": "application/json;charset=utf-8",
"apiName": "删除直播课",
"desc": "删除直播课"
} }
} }
\ 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