Commit 727b319d authored by xiamengchen's avatar xiamengchen

直播中测试覆盖

parent e67c0126
......@@ -238,7 +238,7 @@ public class LiveLater implements Authorization {
List<GrabWelfares>list=JsonUtil.parseResponseToListBean(response,GrabWelfares.class,"grabWelfares");
Boolean specifyAward =list.get(0).getSpecifyAward();
Assert.assertTrue(specifyAward,network.message(params, BasicConfig.MOBILE_getClueDetail, "指定中奖为null", response.body().asString()));
List<Map<String, Object>> evaLists = response.jsonPath().getList("evaluationResources");
List<Map<String, Object>> evaLists = response.jsonPath().getList("data.evaluationResources");
System.out.println("evaLists: "+evaLists);
Assert.assertEquals(evaLists.size(), 1, network.message(params, BasicConfig.MOBILE_getClueDetail, "用户参与测试数量错误", response.body().asString()));
String evaTitle = (String) evaLists.get(0).get("resourceTitle");
......
package com.kjj.cases.live.anchor;
import com.kjj.cases.admin.Authorization;
import com.kjj.cases.live.liveConfig.LiveMaterial;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import io.restassured.response.Response;
......@@ -8,6 +9,7 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
......@@ -33,6 +35,24 @@ public class CloseLive implements Authorization {
}
@Test(description = "删除权益", priority = 2)
public void 删除权益() {
for (int resourceId : Arrays.asList(LiveMaterial.resourceId, LiveMaterial.termResourceId, LiveMaterial.freeResourceId, LiveMaterial.picResourceId)){
System.out.println(resourceId);
Map<String, Object> delResourceParam = new HashMap<>();
delResourceParam.put("id", resourceId);
Response delResourceRes = network.postResponse(delResourceParam, BasicConfig.MANAGER_delResource);
try {
boolean data = delResourceRes.jsonPath().getBoolean("data");
System.out.println(data);
Assert.assertTrue(data, network.message(delResourceParam, BasicConfig.MANAGER_delResource, "删除权益失败", delResourceRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(delResourceParam, BasicConfig.MANAGER_delResource, "获取数据失败", delResourceRes.body().asString()));
}
}
}
......
......@@ -2,6 +2,8 @@ package com.kjj.cases.live.customer;
import com.kjj.cases.admin.Authorization;
import com.kjj.cases.live.agent.Agent;
import com.kjj.cases.live.anchor.LiveVisitors;
import com.kjj.cases.live.liveConfig.LiveMaterial;
import com.kjj.cases.live.lottery.Lottery;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
......@@ -9,9 +11,9 @@ import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
public class AfterLive implements Authorization {
......@@ -61,4 +63,26 @@ public class AfterLive implements Authorization {
Object syntheticAvatar = response.jsonPath().getJsonObject("data.syntheticAvatar");
Assert.assertNotNull(syntheticAvatar, network.message(params, BasicConfig.USER_getAgentQrCode, "轮训代理人二维码失败", response.body().asString()));
}
@Test(description = "直播结束资料列表过滤关联测试资料", priority = 4)
public void 直播结束资料列表过滤关联测试资料() {
Map<String, Object> getResourceListPar = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response getResourceListRes = network.getResponse(params, BasicConfig.MOBILE_resourceList);
try {
List<Map<String, Object>> resourceLists = getResourceListRes.jsonPath().getList("data");
List<String> allResource = new ArrayList<>();
for (Map<String, Object> resource : resourceLists){
allResource.add(String.valueOf(resource.get("confId")));
}
List<String> with_outList = Lists.newArrayList(LiveVisitors.confId_eva, LiveVisitors.confId_formWithEva, LiveVisitors.confId_freeWithEva);
System.out.println("withoutList: "+with_outList);
for (String confId : allResource){
Assert.assertFalse(with_outList.contains(confId), network.message(params, BasicConfig.MOBILE_resourceList, "关联测试的资料未被过滤", getResourceListRes.body().asString()));
}
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(params, BasicConfig.MOBILE_resourceList, "获取数据失败", getResourceListRes.body().asString()));
}
}
}
......@@ -70,21 +70,13 @@ public class PersonalPage implements Authorization {
List<ResourceList> resourceLists = JsonUtil.parseResponseToPageBean(response, ResourceList.class);
ResourceList resourceList = resourceLists.get(0);
sourceRecordId = resourceList.getRecordId();
Assert.assertEquals(sourceRecordId, LiveVisitors.resourceReceiveRecordId, network.message(params, BasicConfig.USER_resourceList, "资料领取记录id不正确", response.body().asString()));
Assert.assertEquals(sourceRecordId, LiveVisitors.freeForEvaReceiveRecordId, network.message(params, BasicConfig.USER_resourceList, "资料领取记录id不正确", response.body().asString()));
String liveId = resourceList.getLiveId();
Assert.assertEquals(liveId, LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()), network.message(params, BasicConfig.USER_resourceList, "资料领取直播id不正确", response.body().asString()));
try {
for (ResourceList resourceList1 : resourceLists){
if (resourceList1.getLiveId().equals(LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()))){
Assert.assertNotEquals(resourceList1.getRecordId(), LiveVisitors.freeForEvaReceiveRecordId, network.message(params, BasicConfig.USER_resourceList, "关联测试的资料未被过滤", response.body().asString()));
}else {break;}
}
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(params, BasicConfig.USER_resourceList, "获取数据失败", response.body().asString()));
}
companyName = resourceList.getCompanyName(); // 获取领取资料的公司名称
System.out.println(companyName);
}
@Test(description = "获取访客最近观看的公司", priority = 6)
......@@ -93,7 +85,9 @@ public class PersonalPage implements Authorization {
// 管理后台根据公司名称查询公司id
Map<String, Object> searchCompanyPar = new HashMap<>();
searchCompanyPar.put("companyName", companyName);
System.out.println(searchCompanyPar);
Response searchCompanyRes = network.getResponse(searchCompanyPar, BasicConfig.MANAGER_searchCompany);
System.out.println(searchCompanyRes.body().asString());
Assert.assertTrue(searchCompanyRes.jsonPath().getBoolean("success"), network.message(searchCompanyPar, BasicConfig.MANAGER_searchCompany, "接口调用失败", searchCompanyRes.body().asString()));
long companyId = searchCompanyRes.jsonPath().getInt("data[0].id");
// 加密公司id
......
......@@ -32,14 +32,14 @@ public class EvaluationConf implements Authorization {
addEvaResourcePar.put("resourceTitle", "编辑后测试权益标题");
addEvaResourcePar.put("resourceType", 23);
Response addEvaResourceRes = network.postResponse(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource);
System.out.println(addEvaResourceRes.body().asString());
// try {
// boolean data = addEvaResourceRes.jsonPath().getBoolean("data");
// Assert.assertTrue(data, network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "编辑测试权益失败", addEvaResourceRes.body().asString()));
// }catch (NullPointerException e){
// e.printStackTrace();
// Assert.fail(network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "获取数据失败", addEvaResourceRes.body().asString()));
// }
try {
boolean success = addEvaResourceRes.jsonPath().getBoolean("success");
Assert.assertFalse(success, network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "编辑测试权益失败", addEvaResourceRes.body().asString()));
Assert.assertEquals(addEvaResourceRes.jsonPath().getString("desc"), "直播进行中,无法更新测评id", network.message(params, BasicConfig.MANAGER_evaluation_saveEvaResource, "失败原因错误", addEvaResourceRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "获取数据失败", addEvaResourceRes.body().asString()));
}
// 表单
Map<String, Object> formParam = new HashMap<>();
......@@ -53,7 +53,14 @@ public class EvaluationConf implements Authorization {
formParam.put("formBanner", "https://yun.dui88.com/kjy/image/20210306/1615033326937.jpg");
formParam.put("fieldIds", "1,2");
Response formRes = network.postResponse(formParam, BasicConfig.MANAGER_saveForm);
System.out.println(formRes.body().asString());
try {
boolean success = addEvaResourceRes.jsonPath().getBoolean("success");
Assert.assertFalse(success, network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "编辑测试权益失败", addEvaResourceRes.body().asString()));
Assert.assertEquals(addEvaResourceRes.jsonPath().getString("desc"), "直播进行中,无法更新测评id", network.message(params, BasicConfig.MANAGER_evaluation_saveEvaResource, "失败原因错误", addEvaResourceRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "获取数据失败", addEvaResourceRes.body().asString()));
}
// 免费领
Map<String, Object> freeParam = new HashMap<>();
......@@ -66,7 +73,14 @@ public class EvaluationConf implements Authorization {
freeParam.put("resourceImg", "https://yun.dui88.com/kjy/image/20210306/1615033315608.jpeg");
freeParam.put("resourcePictures", "https://yun.dui88.com/kjy/image/20210306/1615039670425.jpg");
Response FreeRes = network.postResponse(freeParam, BasicConfig.MANAGER_saveFree);
System.out.println(FreeRes.body().asString());
try {
boolean success = addEvaResourceRes.jsonPath().getBoolean("success");
Assert.assertFalse(success, network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "编辑测试权益失败", addEvaResourceRes.body().asString()));
Assert.assertEquals(addEvaResourceRes.jsonPath().getString("desc"), "直播进行中,无法更新测评id", network.message(params, BasicConfig.MANAGER_evaluation_saveEvaResource, "失败原因错误", addEvaResourceRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "获取数据失败", addEvaResourceRes.body().asString()));
}
// 图文
Map<String, Object> Params = new HashMap<>();
......@@ -79,26 +93,15 @@ public class EvaluationConf implements Authorization {
Params.put("resourcePictures", "https://yun.dui88.com/kjy/image/20210306/1615023476770.jpeg");
Params.put("resourcePicturesArr", "https://yun.dui88.com/kjy/image/20210306/1615023476770.jpeg");
Response response = network.postResponse(Params, BasicConfig.MANAGER_resource);
System.out.println(response.body().asString());
}
// @Test(description = "删除权益", priority = 2)
// public void 删除权益() {
// for (int resourceId : Arrays.asList(LiveMaterial.resourceId, LiveMaterial.termResourceId, LiveMaterial.freeResourceId, LiveMaterial.picResourceId)){
// System.out.println(resourceId);
// Map<String, Object> delResourceParam = new HashMap<>();
// delResourceParam.put("id", resourceId);
// Response delResourceRes = network.postResponse(delResourceParam, BasicConfig.MANAGER_delResource);
// try {
// boolean data = delResourceRes.jsonPath().getBoolean("data");
// System.out.println(data);
// Assert.assertTrue(data, network.message(delResourceParam, BasicConfig.MANAGER_delResource, "删除权益失败", delResourceRes.body().asString()));
// }catch (NullPointerException e){
// e.printStackTrace();
// Assert.fail(network.message(delResourceParam, BasicConfig.MANAGER_delResource, "获取数据失败", delResourceRes.body().asString()));
// }
// }
// }
try {
boolean success = addEvaResourceRes.jsonPath().getBoolean("success");
Assert.assertFalse(success, network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "编辑测试权益失败", addEvaResourceRes.body().asString()));
Assert.assertEquals(addEvaResourceRes.jsonPath().getString("desc"), "直播进行中,无法更新测评id", network.message(params, BasicConfig.MANAGER_evaluation_saveEvaResource, "失败原因错误", addEvaResourceRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "获取数据失败", addEvaResourceRes.body().asString()));
}
}
......
......@@ -6,9 +6,11 @@ import com.kjj.utils.BaseUtils;
import com.kjj.utils.JsonUtil;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.apache.poi.ss.formula.functions.Na;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
import java.util.*;
......@@ -18,9 +20,9 @@ public class LiveMaterial implements Authorization {
private final long companyId = 101;
public static long evaluationId; // 测试id
public static int resourceId; // 测试权益ID
public static Integer termResourceId = null; // 关联测试表单权益ID
public static Integer freeResourceId = null; // 关联测试免费领权益ID
public static Integer picResourceId = null; // 关联测试图文权益ID
public static int termResourceId; // 关联测试表单权益ID
public static int freeResourceId; // 关联测试免费领权益ID
public static int picResourceId; // 关联测试图文权益ID
@BeforeClass
public void setUp() {
......@@ -336,6 +338,7 @@ public class LiveMaterial implements Authorization {
e.printStackTrace();
Assert.fail(network.message(evaEnablePar, BasicConfig.MANAGER_evaluation_enable, "获取数据失败", evaEnableRes.body().asString()));
}
System.out.println("启用的测试ID" + evaluationId);
}
/**
......@@ -619,6 +622,8 @@ public class LiveMaterial implements Authorization {
e.printStackTrace();
Assert.fail(network.message(addEvaResourcePar, BasicConfig.MANAGER_evaluation_saveEvaResource, "获取数据失败", addEvaResourceRes.body().asString()));
}
System.out.println("测试权益关联测试ID: "+evaluationId);
}
@Test(description = "测试权益详情", priority = 31)
......@@ -849,22 +854,44 @@ public class LiveMaterial implements Authorization {
Response resourceListRes = network.getResponse(resourceListPar, BasicConfig.MANAGER_resourceList);
try {
List<Map<String, Object>> resourceList = resourceListRes.jsonPath().getList("data.list");
List<Map<String, Object>> term = new ArrayList<>();
List<Map<String, Object>> free = new ArrayList<>();
List<Map<String, Object>> pic = new ArrayList<>();
for (Map<String, Object> resource : resourceList){
// 找到表单
if (resource.get("resourceType").equals(12)){
if (resource.get("resourceTitle").equals("表单关联测试")){
termResourceId = (int)resource.get("id");
term.add(resource);
}
}else if (resource.get("resourceType").equals(11)){
if (resource.get("resourceTitle").equals("免费领关联测试")){
freeResourceId = (int) resource.get("id");
free.add(resource);
}
}else if (resource.get("resourceType").equals(1)){
if (resource.get("resourceTitle").equals("图文关联测试")){
picResourceId = (int) resource.get("id");
pic.add(resource);
}
}
}
int max = 0;
for (Map<String, Object> t : term){
int id = (int)t.get("id");
if (id >= max){max = id;}
}
termResourceId = max;
max = 0;
for (Map<String, Object> f : free){
int id = (int) f.get("id");
if (id >= max){max = id;}
}
freeResourceId = max;
max = 0;
for (Map<String, Object> p : pic){
int id = (int) p.get("id");
if (id >= max){max = id;}
}
picResourceId = max;
Assert.assertNotNull(termResourceId, network.message(resourceListPar, BasicConfig.MANAGER_resourceList, "未获取到表单权益ID", resourceListRes.body().asString()));
Assert.assertNotNull(freeResourceId, network.message(resourceListPar, BasicConfig.MANAGER_resourceList, "未获取到表单权益ID", resourceListRes.body().asString()));
}catch (NullPointerException e){
......
......@@ -68,7 +68,6 @@ public class Lottery implements Authorization {
Assert.assertTrue(success, network.message(connectSuccessParam, BasicConfig.USER_connectSuccess, "访客到场请求失败", response.body().asString()));
}
@Test(description = "访客A抽奖查询抽奖活动弹层", priority = 5)
public void 访客A抽奖查询抽奖活动弹层() {
visitorAuth();
......@@ -1475,6 +1474,5 @@ public class Lottery implements Authorization {
}
}
......@@ -173,12 +173,8 @@ public class SecondKill implements Authorization {
goodsOnPar.put("id", ConfSecondKill.skIdSecond);
Response goodsOnRes = network.postResponse(goodsOnPar, BasicConfig.ANCHOR_secondKillOn);
try {
boolean success = goodsOnRes.jsonPath().getBoolean("success");
if (success){
Assert.fail(network.message(goodsOnPar, BasicConfig.ANCHOR_secondKillOn, "同时上架多轮秒杀成功", goodsOnRes.body().asString()));
}
String code = goodsOnRes.jsonPath().getString("code");
Assert.assertEquals(code, "07230005", network.message(goodsOnPar, BasicConfig.ANCHOR_secondKillOn, "失败原因错误", goodsOnRes.body().asString()));
boolean data = goodsOnRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(goodsOnPar, BasicConfig.ANCHOR_secondKillOn, "上架第二轮秒杀失败", goodsOnRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(goodsOnPar, BasicConfig.ANCHOR_secondKillOn, "未获取到数据", goodsOnRes.body().asString()));
......@@ -192,9 +188,10 @@ public class SecondKill implements Authorization {
Map<String, Object> goodsFirstPar = new HashMap<>();
goodsFirstPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response goodsFirstRes = network.getResponse(goodsFirstPar, BasicConfig.MOBILE_secondKill_goodsFirst);
System.out.println(goodsFirstRes.body().asString());
try {
String confId = goodsFirstRes.jsonPath().getString("data.confId");
Assert.assertEquals(confId, ConfSecondKill.skIdFirst, network.message(goodsFirstPar, BasicConfig.MOBILE_secondKill_goodsFirst, "当前秒杀商品配置ID错误", goodsFirstRes.body().asString()));
Assert.assertEquals(confId, ConfSecondKill.skIdSecond, network.message(goodsFirstPar, BasicConfig.MOBILE_secondKill_goodsFirst, "当前秒杀商品配置ID错误", goodsFirstRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(goodsFirstPar, BasicConfig.MOBILE_secondKill_goodsFirst, "未获取到数据", goodsFirstRes.body().asString()));
......
......@@ -5,6 +5,7 @@ import com.kjj.bean.manager.RedList;
import com.kjj.bean.red.RedConf;
import com.kjj.bean.resources.ResourceForm;
import com.kjj.cases.admin.Authorization;
import com.kjj.cases.live.liveConfig.LiveMaterial;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.BaseUtils;
......@@ -544,6 +545,9 @@ public class TimeRed implements Authorization {
ids.add(new Material(359L,0));
ids.add(new Material(960L,0));
ids.add(new Material(3384L,0));
ids.add(new Material(LiveMaterial.resourceId, 0)); // 直播添加测试权益资料
ids.add(new Material(LiveMaterial.termResourceId, 0)); // 直播添加表单关联测试权益
ids.add(new Material(LiveMaterial.freeResourceId, 0)); // 直播添加免费领关联测试权益
Params.put("resourceList", ids);
Response response = network.postResponse(Params, BasicConfig.MANAGER_saveAndUpdate_8);
System.out.println(Params);
......
......@@ -548,6 +548,7 @@ public class BasicConfig {
public static final String MOBILE_getShortUrl = MOBILE_HOST + "/kjy/live/share/short/getShortUrl";
public static final String MOBILE_evaluationDetail = MOBILE_HOST + "/clue/evaluation/detail";
public static final String MOBILE_evaluationSubmit = MOBILE_HOST + "/clue/evaluation/submit";
public static final String MOBILE_resourceList = MOBILE_HOST + "/kjy/live/resource/list";
//投票
......
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