Commit dc710dd4 by zhangying

补充case和优化代码

parent 0f454559
...@@ -31,7 +31,7 @@ public class TestChangeCourseState extends XMBaseTest { ...@@ -31,7 +31,7 @@ public class TestChangeCourseState extends XMBaseTest {
* 测试改变直播课次状态 * 测试改变直播课次状态
*/ */
@Test @Test
public void testChangeCourseState() { public void testChangeCourseState() throws InterruptedException {
GetLiveCourseData getLiveCourseData=new GetLiveCourseData(); GetLiveCourseData getLiveCourseData=new GetLiveCourseData();
JSONObject largeCourse=getLiveCourseData.createLargeClassLive(); JSONObject largeCourse=getLiveCourseData.createLargeClassLive();
......
...@@ -31,7 +31,7 @@ public class TestInitXmLive extends XMBaseTest { ...@@ -31,7 +31,7 @@ public class TestInitXmLive extends XMBaseTest {
* 测试初始化直播间信息 * 测试初始化直播间信息
*/ */
@Test @Test
public void testInitXmLive() { public void testInitXmLive() throws InterruptedException {
GetLiveCourseData getLiveCourseData=new GetLiveCourseData(); GetLiveCourseData getLiveCourseData=new GetLiveCourseData();
JSONObject largeClassCourse=getLiveCourseData.getLargeClassLiveList(); JSONObject largeClassCourse=getLiveCourseData.getLargeClassLiveList();
......
...@@ -30,7 +30,7 @@ public class TestQueryStudentByCourseId extends XMBaseTest { ...@@ -30,7 +30,7 @@ public class TestQueryStudentByCourseId extends XMBaseTest {
* 测试通过课次id查询直播学员API * 测试通过课次id查询直播学员API
*/ */
@Test @Test
public void testQueryStudentByCourseId() { public void testQueryStudentByCourseId() throws InterruptedException {
GetLiveCourseData getLiveCourseData=new GetLiveCourseData(); GetLiveCourseData getLiveCourseData=new GetLiveCourseData();
JSONObject largeClassCourse=getLiveCourseData.getLargeClassLiveList(); JSONObject largeClassCourse=getLiveCourseData.getLargeClassLiveList();
......
...@@ -85,7 +85,7 @@ public class TestLargeClassDelCourse extends XMBaseTest { ...@@ -85,7 +85,7 @@ public class TestLargeClassDelCourse extends XMBaseTest {
* 大班直播课-删除课程(待上课) * 大班直播课-删除课程(待上课)
*/ */
@Test @Test
public void testLargeClassDelCourse2() { public void testLargeClassDelCourse2() throws InterruptedException {
GetLiveCourseData getLiveCourseData = new GetLiveCourseData(); GetLiveCourseData getLiveCourseData = new GetLiveCourseData();
JSONObject getLargeCourseData = getLiveCourseData.createLargeClassLive(); JSONObject getLargeCourseData = getLiveCourseData.createLargeClassLive();
String liveCourseId = getLargeCourseData.getString("result"); String liveCourseId = getLargeCourseData.getString("result");
...@@ -113,12 +113,16 @@ public class TestLargeClassDelCourse extends XMBaseTest { ...@@ -113,12 +113,16 @@ public class TestLargeClassDelCourse extends XMBaseTest {
* 大班直播课-删除课程(上课中) * 大班直播课-删除课程(上课中)
*/ */
@Test @Test
public void testLargeClassDelCourse3() { public void testLargeClassDelCourse3() throws InterruptedException {
GetLiveCourseData getLiveCourseData = new GetLiveCourseData(); GetLiveCourseData getLiveCourseData = new GetLiveCourseData();
JSONObject getLargeCourseData = getLiveCourseData.getLargeClassLiveListStarting(); JSONObject getLargeCourseData = getLiveCourseData.createLargeClassLive();
String liveCourseId = getLargeCourseData.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("liveCourseId"); String liveCourseId = getLargeCourseData.getString("result");
System.out.println("liveCourseId =="+liveCourseId); System.out.println("liveCourseId =="+liveCourseId);
JSONObject getStartingCourse = getLiveCourseData.changeCourseStateToStarting(liveCourseId);
System.out.println("getStartingCourse =="+getStartingCourse);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("liveCourseId",liveCourseId); jsonObject.put("liveCourseId",liveCourseId);
......
package com.live.cases.largeClassLive;
import com.alibaba.fastjson.JSONArray;
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.GetLiveCourseData;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* @author zhangying
* @date 2021/2/24 3:53 下午
*/
public class TestUpdateCourse extends XMBaseTest {
@BeforeMethod
public void beforeTest() {
xmAppApi.setApiModule(ApiModele.CloudClass_B) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_updateCourse") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
dal.setCase_owner("张莹");
super.beforeTest();
}
/**
* 测试大班直播课,编辑课程-编辑名称
*/
@Test
public void testUpdateCourse() throws InterruptedException {
GetLiveCourseData getLiveCourseData = new GetLiveCourseData();
JSONObject getLargeCourseData = getLiveCourseData.createLargeClassLive();
String liveCourseId = getLargeCourseData.getString("result");
System.out.println("liveCourseId =="+liveCourseId);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("adminIds",jsonArray);
jsonObject.put("applyMode","ANYONE"); //分享设置-任何学员
jsonObject.put("autoSendReport","OFF_AUTO");
jsonObject.put("consumeClassTime",1);
jsonObject.put("consumeHourNum",1);
jsonObject.put("consumeStudentIds",jsonArray);
jsonObject.put("courseName",RandomStringUtil.randomNumber(14, "测试编辑_course_"));
jsonObject.put("TestUpdateCourse","https://image.xiaomaiketang.com/xm/YNfi45JwFA.png");
jsonObject.put("endTime",System.currentTimeMillis() + 30 * 60 * 1000);
jsonObject.put("liveCourseId",liveCourseId);
jsonObject.put("liveCourseMediaRequests",jsonArray);
jsonObject.put("liveType","LARGE_CLASS_LIVE");
jsonObject.put("needRecord","YES");
jsonObject.put("startTime",System.currentTimeMillis() + 60 * 1000);
jsonObject.put("studentIds",jsonArray);
jsonObject.put("teacherId",xmAppApi.getLoginInfo().getTid());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
System.out.println(xmAppApi);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
System.out.println("jsonBody ="+jsonBody );
JSONObject getLargeCourseData1 = getLiveCourseData.getLargeClassLiveList();
String liveCourseId1 = getLargeCourseData1.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("liveCourseId");
System.out.println("liveCourseId1 =="+liveCourseId1);
Assert.assertEquals(liveCourseId1, liveCourseId);
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("200", jsonBody.getString("code"));
}
/**
* 测试大班直播课,编辑课程-修改分享设置
*/
@Test
public void testUpdateCourse1() {
GetLiveCourseData getLiveCourseData = new GetLiveCourseData();
JSONObject getLargeCourseData = getLiveCourseData.getLargeClassLiveList();
String liveCourseId = getLargeCourseData.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("liveCourseId");
System.out.println("liveCourseId =="+liveCourseId);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("adminIds",jsonArray);
jsonObject.put("applyMode","ONLY_READ"); //分享设置-仅在读
jsonObject.put("autoSendReport","OFF_AUTO");
jsonObject.put("consumeClassTime",1);
jsonObject.put("consumeHourNum",1);
jsonObject.put("consumeStudentIds",jsonArray);
jsonObject.put("courseName",RandomStringUtil.randomNumber(14, "测试编辑_course_"));
jsonObject.put("TestUpdateCourse","https://image.xiaomaiketang.com/xm/YNfi45JwFA.png");
jsonObject.put("endTime",System.currentTimeMillis() + 30 * 60 * 1000);
jsonObject.put("liveCourseId",liveCourseId);
jsonObject.put("liveCourseMediaRequests",jsonArray);
jsonObject.put("liveType","LARGE_CLASS_LIVE");
jsonObject.put("needRecord","YES");
jsonObject.put("startTime",System.currentTimeMillis() + 60 * 1000);
jsonObject.put("studentIds",jsonArray);
jsonObject.put("teacherId",xmAppApi.getLoginInfo().getTid());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
System.out.println(xmAppApi);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
System.out.println("jsonBody ="+jsonBody );
JSONObject getLargeCourseData1 = getLiveCourseData.getLargeClassLiveList();
String liveCourseId1 = getLargeCourseData1.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("liveCourseId");
System.out.println("liveCourseId1 =="+liveCourseId1);
Assert.assertEquals(liveCourseId1, liveCourseId);
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("200", jsonBody.getString("code"));
}
/**
* 测试大班直播课,编辑课程-添加扣课时学员
*/
@Test
public void testUpdateCourse2() {
GetLiveCourseData getLiveCourseData = new GetLiveCourseData();
JSONObject getLargeCourseData = getLiveCourseData.getLargeClassLiveList();
String liveCourseId = getLargeCourseData.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("liveCourseId");
System.out.println("liveCourseId =="+liveCourseId);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("name","扣课时学员(自动化测试)");
jsonObject1.put("phone","12300000003");
jsonObject1.put("studentId","1358346398485405697");
jsonObject1.put("consumeHourNum","100");
jsonObject1.put("classHourId","1235120275888328705");
JSONArray jsonArray1 = new JSONArray();
jsonArray1.add(jsonObject1);
JSONObject jsonObject = new JSONObject();
jsonObject.put("adminIds",jsonArray);
jsonObject.put("applyMode","ONLY_READ"); //分享设置-仅在读
jsonObject.put("autoSendReport","OFF_AUTO");
jsonObject.put("consumeClassTime",1);
jsonObject.put("consumeHourNum",1);
jsonObject.put("consumeStudentIds",jsonArray1);
jsonObject.put("courseName",RandomStringUtil.randomNumber(14, "测试编辑_course_"));
jsonObject.put("TestUpdateCourse","https://image.xiaomaiketang.com/xm/YNfi45JwFA.png");
jsonObject.put("endTime",System.currentTimeMillis() + 30 * 60 * 1000);
jsonObject.put("liveCourseId",liveCourseId);
jsonObject.put("liveCourseMediaRequests",jsonArray);
jsonObject.put("liveType","LARGE_CLASS_LIVE");
jsonObject.put("needRecord","YES");
jsonObject.put("startTime",System.currentTimeMillis() + 60 * 1000);
jsonObject.put("studentIds",jsonArray);
jsonObject.put("teacherId",xmAppApi.getLoginInfo().getTid());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
System.out.println(xmAppApi);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
System.out.println("jsonBody ="+jsonBody );
JSONObject getLargeCourseData1 = getLiveCourseData.getLargeClassLiveList();
String liveCourseId1 = getLargeCourseData1.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("liveCourseId");
System.out.println("liveCourseId1 =="+liveCourseId1);
Assert.assertEquals(liveCourseId1, liveCourseId);
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("200", jsonBody.getString("code"));
}
/**
* 测试大班直播课,编辑课程-添加封面图
*/
@Test
public void testUpdateCourse3() {
GetLiveCourseData getLiveCourseData = new GetLiveCourseData();
JSONObject getLargeCourseData = getLiveCourseData.getLargeClassLiveList();
String liveCourseId = getLargeCourseData.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("liveCourseId");
System.out.println("liveCourseId =="+liveCourseId);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("studentId","1235120275888328705");
jsonObject1.put("classHourId","1358346398485405697");
JSONArray jsonArray1 = new JSONArray();
jsonArray1.add(jsonObject1);
JSONObject jsonObject = new JSONObject();
jsonObject.put("adminIds",jsonArray);
jsonObject.put("applyMode","ONLY_READ"); //分享设置-仅在读
jsonObject.put("autoSendReport","OFF_AUTO");
jsonObject.put("consumeClassTime",1);
jsonObject.put("consumeHourNum",1);
jsonObject.put("consumeStudentIds",jsonArray1);
jsonObject.put("courseName",RandomStringUtil.randomNumber(14, "测试编辑_course_"));
jsonObject.put("TestUpdateCourse","https://image.xiaomaiketang.com/xm/YNfi45JwFA.png");
jsonObject.put("endTime",System.currentTimeMillis() + 30 * 60 * 1000);
jsonObject.put("liveCourseId",liveCourseId);
jsonObject.put("liveCourseMediaRequests",jsonArray);
jsonObject.put("liveType","LARGE_CLASS_LIVE");
jsonObject.put("needRecord","YES");
jsonObject.put("startTime",System.currentTimeMillis() + 60 * 1000);
jsonObject.put("studentIds",jsonArray);
jsonObject.put("teacherId",xmAppApi.getLoginInfo().getTid());
jsonObject.put("coverUrl","blob:https://b.xiaomai5.com/34279850-7b4a-4695-b19c-0da735864190"); //编辑封面图片
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
System.out.println(xmAppApi);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
System.out.println("jsonBody ="+jsonBody );
JSONObject getLargeCourseData1 = getLiveCourseData.getLargeClassLiveList();
String liveCourseId1 = getLargeCourseData1.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("liveCourseId");
System.out.println("liveCourseId1 =="+liveCourseId1);
Assert.assertEquals(liveCourseId1, liveCourseId);
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("200", jsonBody.getString("code"));
}
}
package com.live.xmutils; package com.live.xmutils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.live.client.XMAppApi;
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;
...@@ -9,6 +10,7 @@ import com.live.utils.XMBaseTest; ...@@ -9,6 +10,7 @@ import com.live.utils.XMBaseTest;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
public class GetLiveCourseData extends XMBaseTest { public class GetLiveCourseData extends XMBaseTest {
...@@ -104,7 +106,27 @@ public class GetLiveCourseData extends XMBaseTest { ...@@ -104,7 +106,27 @@ public class GetLiveCourseData extends XMBaseTest {
return liveCourseList; return liveCourseList;
} }
public JSONObject createLargeClassLive() { public JSONObject changeCourseStateToStarting(String liveCourseId) {
dataApi.setApiModule(ApiModele.CloudClass_apollo) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("api_changeCourseState") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
super.beforeDataRequest();
JSONObject jsonObject = new JSONObject();
jsonObject.put("liveCourseId",liveCourseId);
jsonObject.put("courseState","STARTING");
dataApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), dataheadrs);
System.out.println(dataApi);
JSONObject liveCourseList=dataApi.getBodyInJSON();
return liveCourseList;
}
public JSONObject createLargeClassLive() throws InterruptedException {
dataApi.setApiModule(ApiModele.CloudClass_B) dataApi.setApiModule(ApiModele.CloudClass_B)
.setApiName("API_createLargeClassLive") .setApiName("API_createLargeClassLive")
.setLoginUser("zhangy-b") .setLoginUser("zhangy-b")
...@@ -113,6 +135,7 @@ public class GetLiveCourseData extends XMBaseTest { ...@@ -113,6 +135,7 @@ public class GetLiveCourseData extends XMBaseTest {
dataApi.doRequest(RequestType.JSON, params, buildCreateLargeClassLiveParam().toJSONString(), dataheadrs); dataApi.doRequest(RequestType.JSON, params, buildCreateLargeClassLiveParam().toJSONString(), dataheadrs);
TimeUnit.SECONDS.sleep(3);
JSONObject liveCourse=dataApi.getBodyInJSON(); JSONObject liveCourse=dataApi.getBodyInJSON();
return liveCourse; return liveCourse;
......
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