Commit c00bcaee by zhangying

修改一些调用

parent 748a20e0
...@@ -5,6 +5,7 @@ import com.live.cases.largeClassLive.LargeClassLiveTools; ...@@ -5,6 +5,7 @@ import com.live.cases.largeClassLive.LargeClassLiveTools;
import com.live.enums.ApiModele; import com.live.enums.ApiModele;
import com.live.enums.RequestType; import com.live.enums.RequestType;
import com.live.enums.Terminal; import com.live.enums.Terminal;
import com.live.xmutils.GetLiveCourseData;
import com.xiaomai.utils.XMBaseTest; import com.xiaomai.utils.XMBaseTest;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
...@@ -30,9 +31,16 @@ public class TestChangeCourseState extends XMBaseTest { ...@@ -30,9 +31,16 @@ public class TestChangeCourseState extends XMBaseTest {
*/ */
@Test @Test
public void testChangeCourseState() { public void testChangeCourseState() {
LargeClassLiveTools getLargeClassLiveTools = new LargeClassLiveTools(); GetLiveCourseData getLiveCourseData=new GetLiveCourseData();
JSONObject largeClassLive = getLargeClassLiveTools.getLargeClassLive(); JSONObject largeClassCourse=getLiveCourseData.getLargeClassLiveList();
String liveCourseId= (String) largeClassLive.get("liveCourseId");
JSONObject liveCourse=largeClassCourse.getJSONObject("result").getJSONArray("records").getJSONObject(0);
String liveCourseId= (String) liveCourse.get("liveCourseId");
if (liveCourseId==null){
largeClassCourse=getLiveCourseData.createLargeClassLive();
liveCourseId= (String) largeClassCourse.get("liveCourseId");
}
System.out.println("liveCourseId ="+liveCourseId);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("liveCourseId",liveCourseId); jsonObject.put("liveCourseId",liveCourseId);
......
...@@ -5,6 +5,7 @@ import com.live.cases.largeClassLive.LargeClassLiveTools; ...@@ -5,6 +5,7 @@ import com.live.cases.largeClassLive.LargeClassLiveTools;
import com.live.enums.ApiModele; import com.live.enums.ApiModele;
import com.live.enums.RequestType; import com.live.enums.RequestType;
import com.live.enums.Terminal; import com.live.enums.Terminal;
import com.live.xmutils.GetLiveCourseData;
import com.xiaomai.utils.XMBaseTest; import com.xiaomai.utils.XMBaseTest;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
...@@ -31,10 +32,21 @@ public class TestInitXmLive extends XMBaseTest { ...@@ -31,10 +32,21 @@ public class TestInitXmLive extends XMBaseTest {
*/ */
@Test @Test
public void testInitXmLive() { public void testInitXmLive() {
LargeClassLiveTools getLargeClassLiveTools = new LargeClassLiveTools(); GetLiveCourseData getLiveCourseData=new GetLiveCourseData();
JSONObject largeClassLive = getLargeClassLiveTools.getLargeClassLive(); JSONObject largeClassCourse=getLiveCourseData.getLargeClassLiveList();
xmAppApi.doRequest(RequestType.JSON, params, "{\"liveCourseId\":"+largeClassLive.get("liveCourseId")+"}", headers); JSONObject liveCourse=largeClassCourse.getJSONObject("result").getJSONArray("records").getJSONObject(0);
String liveCourseId= (String) liveCourse.get("liveCourseId");
if (liveCourseId==null){
largeClassCourse=getLiveCourseData.createLargeClassLive();
liveCourseId= (String) largeClassCourse.get("liveCourseId");
}
System.out.println("liveCourseId ="+liveCourseId);
JSONObject jsonObject = new JSONObject();
jsonObject.put("liveCourseId",liveCourseId);
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
JSONObject jsonBody = xmAppApi.getBodyInJSON(); JSONObject jsonBody = xmAppApi.getBodyInJSON();
Assert.assertEquals("true", jsonBody.getString("success")); Assert.assertEquals("true", jsonBody.getString("success"));
......
package com.live.cases.apollo; package com.live.cases.apollo;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.live.cases.largeClassLive.LargeClassLiveTools; import com.live.cases.largeClassLive.LargeClassLiveTools;
import com.live.enums.ApiModele; import com.live.enums.ApiModele;
import com.live.enums.RequestType; import com.live.enums.RequestType;
import com.live.enums.Terminal; import com.live.enums.Terminal;
import com.live.xmutils.GetLiveCourseData;
import com.xiaomai.utils.XMBaseTest; import com.xiaomai.utils.XMBaseTest;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by zhangying on 2020/11/27 * Created by zhangying on 2020/11/27
*/ */
...@@ -26,13 +32,20 @@ public class TestQueryStudentByCourseId extends XMBaseTest { ...@@ -26,13 +32,20 @@ public class TestQueryStudentByCourseId extends XMBaseTest {
} }
/** /**
* 测试通过课次id查询直播学员 * 测试通过课次id查询直播学员API
*/ */
@Test @Test
public void testQueryStudentByCourseId() { public void testQueryStudentByCourseId() {
LargeClassLiveTools getLargeClassLiveTools = new LargeClassLiveTools(); GetLiveCourseData getLiveCourseData=new GetLiveCourseData();
JSONObject largeClassLive = getLargeClassLiveTools.getLargeClassLive(); JSONObject largeClassCourse=getLiveCourseData.getLargeClassLiveList();
String liveCourseId= (String) largeClassLive.get("liveCourseId");
JSONObject liveCourse=largeClassCourse.getJSONObject("result").getJSONArray("records").getJSONObject(0);
String liveCourseId= (String) liveCourse.get("liveCourseId");
if (liveCourseId==null){
largeClassCourse=getLiveCourseData.createLargeClassLive();
liveCourseId= (String) largeClassCourse.get("liveCourseId");
}
System.out.println("liveCourseId ="+liveCourseId);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("liveCourseId",liveCourseId); jsonObject.put("liveCourseId",liveCourseId);
......
package com.live.xmutils; package com.live.xmutils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.live.cases.largeClassLive.LargeClassLiveTools;
import com.live.enums.ApiModele; import com.live.enums.ApiModele;
import com.live.enums.RequestType; import com.live.enums.RequestType;
import com.live.enums.Terminal; import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.RandomStringUtil;
import com.xiaomai.utils.XMBaseTest; import com.xiaomai.utils.XMBaseTest;
import org.apache.commons.lang.StringUtils;
import org.testng.Assert; import java.util.HashMap;
import org.testng.annotations.BeforeMethod; import java.util.Map;
import org.testng.annotations.Test;
public class GetLiveCourseData extends XMBaseTest { public class GetLiveCourseData extends XMBaseTest {
@BeforeMethod public JSONObject getLargeClassLiveList() {
public void beforeTest() {
dataApi.setApiModule(ApiModele.CloudClass_B) // API 所属模块 必传 读取配置文件config.properties配置的api地址 dataApi.setApiModule(ApiModele.CloudClass_B) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_createLargeClassLive") // API 名称 必传 .setApiName("API_getLargeClassLiveList") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传 .setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传) .setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
super.beforeTest();
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 createLargeClassLive() {
dataApi.setApiModule(ApiModele.CloudClass_B)
.setApiName("API_createLargeClassLive")
.setLoginUser("zhangy-b")
.setTerminal(com.live.enums.Terminal.B);
super.beforeDataRequest();
@Test
public String getLiveCourseData() {
LargeClassLiveTools getLargeClassLiveTools = new LargeClassLiveTools();
JSONObject largeClassLive = getLargeClassLiveTools.buildCreateLargeClassLiveParam();
dataApi.doRequest(RequestType.JSON, params, largeClassLive.toString(), headers); dataApi.doRequest(RequestType.JSON, params, buildCreateLargeClassLiveParam().toJSONString(), dataheadrs);
JSONObject jsonBody = dataApi.getBodyInJSON();
System.out.println("jsonBody = "+jsonBody);
String liveCourseId=jsonBody.getString("result");
System.out.println("liveCourseId = "+liveCourseId);
Assert.assertEquals(jsonBody.getString("success"),"true"); JSONObject liveCourse=dataApi.getBodyInJSON();
Assert.assertEquals(StringUtils.isNotBlank(jsonBody.getString("result")),true); return liveCourse;
}
return liveCourseId; //组装大班直播新增的数据
public JSONObject buildCreateLargeClassLiveParam() {
JSONObject largeClassLive = new JSONObject();
largeClassLive.put("courseName", RandomStringUtil.randomNumber(14, "live_course_"));
largeClassLive.put("teacherId",xmAppApi.getLoginInfo().getTid());
largeClassLive.put("startTime",System.currentTimeMillis() + 60 * 1000);
largeClassLive.put("endTime",System.currentTimeMillis() + 30 * 60 * 1000);
largeClassLive.put("needRecord","YES");
largeClassLive.put("liveType","LARGE_CLASS_LIVE");
largeClassLive.put("consumeHourNum",1);
largeClassLive.put("consumeClassTime","1");
return largeClassLive;
} }
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
{ {
"apiPath": "/apollo/public/apollo/getUserDisk", "apiPath": "/apollo/public/apollo/getUserDisk",
"apiContentType": "", "apiContentType": "",
"apiName": "加入学习", "apiName": "获取云盘数据",
"desc": "加入学习" "desc": "获取云盘数据"
}, },
"API_commonFolderList": "API_commonFolderList":
{ {
......
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