Commit 5235babc authored by Su-Yi's avatar Su-Yi

更新上传素材+新手任务case、优化网络模块

parent 648bad52
package com.kjj.qa.cases;
import com.kjj.qa.utils.NetworkUtil;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class NewTask {
NetworkUtil network = NetworkUtil.getInstance();
@BeforeClass
public void setUp() {
}
//关注公众号
@Test (description = "关注导师微信和客集集VIP公众号",priority = 1) //priorty 方法执行优先级
public void Forward() throws IOException {
//未上传
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[0]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[0].code");
Assert.assertEquals(code,"0","去关注");
//关注导师微信号和关注客集集公众号
topDetailResponse = network.getResponse("/kjy/mp/seller/getScId");
String scid = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"false","");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[0]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[0].code");
Assert.assertEquals(code,"2","已完成");
}
//转发文章
@Test (description = "转发一篇文章到朋友圈",priority = 1) //priorty 方法执行优先级
public void ForwardFriends() throws IOException {
//未上传
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[1]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[1].code");
Assert.assertEquals(code,"0","未完成");
//上传并转发
topDetailResponse = network.getResponse("/kjy/mp/seller/getScId");
String scid = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"false","");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[1]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[1].code");
Assert.assertEquals(code,"0","未完成");
}
//转发动画
@Test (description = "转发一篇动画到朋友圈",priority = 1) //priorty 方法执行优先级
public void ForwardAnimation() throws IOException {
//未转发
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[2]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[2].code");
Assert.assertEquals(code,"0","去转发");
//选择一篇动画去转发
topDetailResponse = network.getResponse("kjy/mp/seller/getScId");
String contentId = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",contentId);
//转发完成
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"true","");
//领奖励
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[2]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[2].code");
Assert.assertEquals(code,"1","领奖励");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId2=topDetailResponse.jsonPath().getString("data.taskId[2]");
String code2 = topDetailResponse.jsonPath().getString("data.taskStatus[2].code");
Assert.assertEquals(code,"2","已完成");
}
//上传文章
@Test (description = "去上传文章并转发一篇文章到朋友圈",priority = 1) //priorty 方法执行优先级
public void ForwardUploadFriends() throws IOException {
//未上传
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[3]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[3].code");
Assert.assertEquals(code,"0","未完成");
//上传并转发
topDetailResponse = network.getResponse("/kjy/mp/seller/getScId");
String scid = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"false","");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[3]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[3].code");
Assert.assertEquals(code,"0","未完成");
}
//完善名片
@Test (description = "完善名片信息",priority = 1) //priorty 方法执行优先级
public void PerfectBusinessCard() throws IOException {
//未完善名片
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[4]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[4].code");
Assert.assertEquals(code,"0","去完善");
//上传并转发
topDetailResponse = network.getResponse("/kjy/mp/seller/getScId");
String scid = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"false","");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[4]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[4].code");
Assert.assertEquals(code,"0","未完成");
}
//查看访问客户
@Test (description = "收到一条访问通知并查看客户信息",priority = 1) //priorty 方法执行优先级
public void VieAccessCustomers() throws IOException {
//未上传
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[5]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[5].code");
Assert.assertEquals(code,"0","未完成");
//上传并转发
topDetailResponse = network.getResponse("/kjy/mp/seller/getScId");
String scid = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"false","");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[5]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[5].code");
Assert.assertEquals(code,"0","未完成");
}
//转发海报
@Test (description = "保存一张海报并转发到朋友圈",priority = 1) //priorty 方法执行优先级
public void ForwardPosters() throws IOException {
//未上传
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[6]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[6].code");
Assert.assertEquals(code,"0","未完成");
//转发海报(实际上只用判断是否保存海报)
topDetailResponse = network.getResponse("//kjy/mp/content/updateDownloadNum");
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId","Kj21NDIxNTk");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"true","转发海报成功");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[6]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[6].code");
Assert.assertEquals(code,"2","已完成");
}
//转发游戏
@Test (description = "转发一个游戏到朋友圈",priority = 1) //priorty 方法执行优先级
public void ForwardGame() throws IOException {
//未上传
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[7]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[7].code");
Assert.assertEquals(code,"0","未完成");
//上传并转发
topDetailResponse = network.getResponse("/kjy/mp/seller/getScId");
String scid = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"false","");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[7]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[7].code");
Assert.assertEquals(code,"0","未完成");
}
//完成课程学习
@Test (description = "进入客集集商学院并完成一门课程学习",priority = 1) //priorty 方法执行优先级
public void CompleteCourseStudies() throws IOException {
//未上传
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[8]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[8].code");
Assert.assertEquals(code,"0","未完成");
//完成学习并转发
topDetailResponse = network.getResponse("/kjy/mp/seller/getScId");
String scid = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"false","");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[8]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[8].code");
Assert.assertEquals(code,"0","未完成");
}
//邀请好友
@Test (description = "邀请好友开通客集集会员",priority = 1) //priorty 方法执行优先级
public void InviteFriends() throws IOException {
//未上传
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId=topDetailResponse.jsonPath().getString("data.taskId[9]");
String code = topDetailResponse.jsonPath().getString("data.taskStatus[9].code");
Assert.assertEquals(code,"0","去邀请");
//邀请好友开通会员成功
topDetailResponse = network.getResponse("/kjy/mp/seller/getScId");
String scid = topDetailResponse.jsonPath().getString("data");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("forwardType",1);
topDetailResponse = network.getResponse(params,"/kjy/mp/forward");
String taskStatus = topDetailResponse.jsonPath().getString("data");
Assert.assertEquals(taskStatus,"false","");
//已完成
topDetailResponse = network.getResponse("/kjy/mp/seller/novice/list");
String taskId1=topDetailResponse.jsonPath().getString("data.taskId[9]");
String code1 = topDetailResponse.jsonPath().getString("data.taskStatus[9].code");
Assert.assertEquals(code,"0","未完成");
}
//虚拟奖励用户领取滚动条
@Test (description = "虚拟奖励用户领取滚动条",priority = 1) //priorty 方法执行优先级
public void VirtualRoll() throws IOException {
Response topDetailResponse = network.getResponse("/kjy/mp/seller/novice/rewardUsers");
Map<String, Object> params = new HashMap<String, Object>();
params.put("size",20);
topDetailResponse = network.getResponse(params,"/kjy/mp/seller/novice/rewardUsers");
String nickname = topDetailResponse.jsonPath().getString("data.nickName[0]");
Assert.assertEquals(nickname,"明天更美好","获取用户昵称成功");
}
}
package com.kjj.qa.cases;
import com.alibaba.fastjson.JSONObject;
import com.kjj.qa.utils.NetworkUtil;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
......@@ -117,9 +115,20 @@ public class Upload {
@Test(description = "上传_本地视频",priority = 5)
public void 上传_本地视频() throws IOException {
Response response = network.getResponse("/kjy/mp/seller/import/taskStatus");
int taskStatus = response.jsonPath().get("data[1].taskStatus");
Assert.assertEquals(taskStatus,2,"上传成功");
//1.上传视频到oss
Response response = network.postResponse("/kjy/mp/upload/video");
String videoUrl = response.jsonPath().getString("videoUrl");
String firstFrameUrl = response.jsonPath().getString("firstFrameUrl");
Assert.assertNotNull(videoUrl,"上传本地视频-上传oss失败");
//2.开始上传视频
Map<String, Object> params = new HashMap<String, Object>();
params.put("videoUrl",videoUrl);
params.put("firstFrameUrl",firstFrameUrl);
params.put("contentTitle","=自动化测试=");
response = network.postResponse(params,"/kjy/mp/seller/upload/video");
String contentId = response.jsonPath().getString("data.contentId");
Assert.assertNotNull(videoUrl,"上传本地视频-上传第二步失败");
}
@Test(description="大家都在转_榜单列表",priority = 6)
......
......@@ -16,6 +16,16 @@
<class name="com.kjj.qa.cases.SellerCard"/>
</classes>
</test>
<test preserve-order="true" name="上传" >
<classes>
<class name="com.kjj.qa.cases.Upload"/>
</classes>
</test>
<test preserve-order="true" name="新手任务" >
<classes>
<class name="com.kjj.qa.cases.NewTask"/>
</classes>
</test>
<!-- 监听器-->
<listeners>
<listener class-name="com.kjj.qa.config.ExtentTestNGIReporterListener"/>
......
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