Commit 325fc96b authored by 龚小红's avatar 龚小红

Merge branch 'Feature/20210222-gxh' into 'master'

增加代理人赠送秒杀代金券的接口用例

See merge request test-group/kejiji!224
parents 1b81fd6b a4f73e9c
......@@ -6,44 +6,21 @@
<test preserve-order="true" name="创建直播">
<classes>
<class name="com.kjj.cases.live.liveConfig.SaveLive"/>
<class name="com.kjj.cases.live.liveConfig.SimpleLive"/>
</classes>
</test>
<test preserve-order="true" name="配置秒杀轮次及秒杀预告">
<test preserve-order="true" name="配置代理人赠送秒杀优惠券">
<classes>
<class name="com.kjj.cases.live.secondKill.ConfSecondKill"/>
<class name="com.kjj.cases.live.secondKill.VoucherConf"/>
</classes>
</test>
<test preserve-order="true" name="绑定关系绑定">
<test preserve-order="true" name="代理人赠送秒杀优惠券并用户使用代金券">
<classes>
<class name="com.kjj.cases.live.liveConfig.LiveBinding"/>
<class name="com.kjj.cases.live.secondKill.Voucher"/>
</classes>
</test>
<test preserve-order="true" name="助播-开启直播">
<classes>
<class name="com.kjj.cases.live.anchor.OpenLive"/>
</classes>
</test>
<!-- 仅用于自测-->
<test preserve-order="true" name="秒杀到场">
<classes>
<class name="com.kjj.cases.live.liveConfig.ConnectLive"/>
</classes>
</test>
<test preserve-order="true" name="秒杀互动">
<classes>
<class name="com.kjj.cases.live.secondKill.SecondKill"/>
</classes>
</test>
<test preserve-order="true" name="助播-结束直播">
<classes>
<class name="com.kjj.cases.live.anchor.CloseLive"/>
</classes>
</test>
</suite>
......@@ -23,4 +23,5 @@ public class AgentBean {
private int inviteAuthStatus;
private int agentAwardOpenFlag; // 是否开启代理人邀约奖励
private int agentNeedInviteNum; // 还需邀请多少人才能开启红包
private boolean agentVoucherHasOpen;//代理人赠送优惠券开关
}
......@@ -145,8 +145,8 @@ public class WhoSawMe implements Authorization {
Assert.assertTrue(success, network.message(BasicConfig.VISITHEADER, "接口请求失败", response.body().asString()));
int todayClueNum = response.jsonPath().getInt("data.todayClueNum");
int todayVisitNum = response.jsonPath().getInt("data.todayVisitNum");
Assert.assertTrue(todayClueNum == 1, network.message(BasicConfig.VISITHEADER, "获取今日线索数有误", response.body().asString()));
Assert.assertTrue(todayVisitNum == 1, network.message(BasicConfig.VISITHEADER, "获取今日访问数有误", response.body().asString()));
Assert.assertTrue(todayClueNum == 3, network.message(BasicConfig.VISITHEADER, "获取今日线索数有误", response.body().asString()));
Assert.assertTrue(todayVisitNum == 2, network.message(BasicConfig.VISITHEADER, "获取今日访问数有误", response.body().asString()));
}
// 查看谁看过我首页我的访客列表
......
......@@ -127,6 +127,7 @@ public class Agent implements Authorization {
Assert.assertNotNull(item, network.message(params, BasicConfig.MOBILE_Procurator, "查询直播列表失败", response.body().asString()));
// 判断代理人邀约奖励openFlag是否为开
Assert.assertEquals(item.getAgentAwardOpenFlag(), 1, network.message(params, MOBILE_Procurator, "代理人邀约奖励开启状态错误", response.body().asString()));
Assert.assertFalse(item.isAgentVoucherHasOpen(), network.message(params, MOBILE_Procurator, "代理人邀约奖励开启状态错误", response.body().asString()));
break;
}
}
......
package com.kjj.cases.live.liveConfig;
import com.alibaba.fastjson.JSON;
import com.kjj.bean.answer.AddReward;
import com.kjj.bean.answer.AddWelfareConf;
import com.kjj.bean.answer.RewardList;
import com.kjj.bean.issue.Dialogue;
import com.kjj.bean.lottery.ConfIdList;
import com.kjj.bean.manager.*;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.IdMakeUtil;
import com.kjj.utils.JsonUtil;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.*;
import static com.kjj.utils.BaseUtils.ssoLogin;
public class SimpleLive implements Authorization {
public String liveID;
public String EncodeLiveID;
public long welfareConfId;
private Integer taskId;
public List<RedList> redId;
public List<WelfareList> id; //奖品列表id
private int confID; // 默认抽奖券配置ID
@BeforeClass
public void setUp() {
ssoLogin();
}
/**
* 创建直播
*/
@Test(description = "创建直播", priority = 1)
public void 创建直播() {
Map<String, Object> Params = new HashMap<>();
Params.put("posterUrl", "https://streamimg.kjjcrm.com/kjy/image/20210201/e36cb31828e14a3ebb9d01e6be79ad66.jpg");
Params.put("videoUrl", "http://streamimg.kjjcrm.com/kjy/image/20210201/1612171657348.mp4");
Params.put("welfareUrl", "https://streamimg.kjjcrm.com/kjy/image/20210201/62c25dcb3b9b4d269a74894e4255a193.jpg");
Params.put("coverUrl", "https://streamimg.kjjcrm.com/kjy/image/20210201/d4093b24aaca49da8f0e3e276721feea.jpg");
Params.put("mpShareUrl", "https://streamimg.kjjcrm.com/kjy/image/20210201/182f3659e39b4ea6898af781cc6344a1.jpg");
Params.put("title", "直播测试" + RandomUtils.nextInt(1, 100));
Params.put("mpShareTitle", "自动化直播");
Params.put("companyId", 101);//公司
Params.put("agentInviteAuthType", 1);
Params.put("agentInviteAuthLimitNum", 1);
long noticeTime = DateUtils.addHours(new Date(), 2).getTime();
long broadcastTime = DateUtils.addHours(new Date(), 5).getTime();
Params.put("noticeTime", noticeTime);
Params.put("broadcastTime", broadcastTime);
Params.put("shareContent", "自动化直播 #{shortLink}");
Params.put("shelfStatus", 2);
Params.put("secondPoster", "https://streamimg.kjjcrm.com/kjy/image/20210201/cc999ebde48e49f99ac3f0d93480453f.jpg");
Params.put("regionType",1);
Params.put("preAwardUrl","https://yun.dui88.com/kjy/image/20210629/1624949155842.png");
Params.put("preWindowUrl","https://yun.dui88.com/kjy/image/20210629/1624949098093.png");
Params.put("distributionType", 1);//奖品分发方式0-代理人领奖1-快递寄送
Params.put("existSeriesPoster", 0);
Params.put("followPushState", 0); // 关注直播间用户是否推送开关,0 = false
List<ProvinceCityCodeList> provinceCityCode = new ArrayList<>();
Params.put("provinceCityCodeList", provinceCityCode);
Response response = network.postResponse(Params, BasicConfig.MANAGER_saveAndUpdate_0);
liveID = response.jsonPath().getString("data");
EncodeLiveID = IdMakeUtil.encodingId(Long.valueOf(liveID));
System.out.println(liveID);
LiveConstants.setValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey(), liveID);
LiveConstants.setValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey(), EncodeLiveID);
Assert.assertNotNull(liveID, network.message(Params, BasicConfig.MANAGER_saveAndUpdate_0, "新增直播失败", response.body().asString()));
LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey());
}
/**
* 基础配置
*/
@Test(description = "查询直播配置", priority = 2)
public void 查询直播配置() {
Map<String, Object> params = new HashMap<>();
params.put("liveId", liveID);
Response response = network.getResponse(params, BasicConfig.MANAGER_getConfDetail);
Object data = response.jsonPath().getJsonObject("data");
System.out.println(data);
Assert.assertNotNull(data, network.message(params, BasicConfig.MANAGER_getConfDetail, "查询配置失败", response.body().asString()));
}
@Test(description = "单场红包配置", priority = 3)
public void 单场红包配置() {
//单场红包限额
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", liveID);
Params.put("maxAmount", 100000);
Response response = network.postResponse(Params, BasicConfig.MANAGER_MaxAmount);
boolean data = response.jsonPath().getBoolean("data");
System.out.println(data);
Assert.assertTrue(data, network.message(Params, BasicConfig.MANAGER_MaxAmount, "单场红包限额配置失败", response.body().asString()));
}
@Test(description = "展示红包金额", priority = 4)
public void 展示红包金额() {
//展示红包金额
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", liveID);
Params.put("showAmount", 100000);
Response response = network.postResponse(Params, BasicConfig.MANAGER_ShowAmount);
boolean data = response.jsonPath().getBoolean("data");
System.out.println(data);
Assert.assertTrue(data, network.message(Params, BasicConfig.MANAGER_ShowAmount, "展示红包配置失败", response.body().asString()));
}
/**
* 直播中奖品
*/
//直播中奖品配置
@Test(description = "直播中抽奖", priority = 9)
public void 直播中抽奖() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", liveID);
Params.put("interactNum", 1);
Params.put("showInteractNum", 1);
Params.put("welfareId", 191);
Params.put("afterMin", 20);
Response response = network.postResponse(Params, BasicConfig.MANAGER_add_1);
boolean data = response.jsonPath().getBoolean("data");
System.out.println(data);
Assert.assertTrue(data, network.message(Params, BasicConfig.MANAGER_add_1, "直播中抽奖配置失败", response.body().asString()));
Params.clear();
Params.put("liveId", liveID);
Params.put("interactNum", 100);
Params.put("showInteractNum", 100);
Params.put("welfareId", 192);
Params.put("afterMin", 30);
response = network.postResponse(Params, BasicConfig.MANAGER_add_1);
boolean data1 = response.jsonPath().getBoolean("data");
System.out.println(data1);
Assert.assertTrue(data1, network.message(Params, BasicConfig.MANAGER_add_1, "直播中抽奖配置失败", response.body().asString()));
Params.clear();
Params.put("liveId", liveID);
Params.put("interactNum", 100);
Params.put("showInteractNum", 100);
Params.put("welfareId", 193);
Params.put("afterMin", 35);
response = network.postResponse(Params, BasicConfig.MANAGER_add_1);
boolean data2 = response.jsonPath().getBoolean("data");
System.out.println(data2);
Assert.assertTrue(data2, network.message(Params, BasicConfig.MANAGER_add_1, "直播中抽奖配置失败", response.body().asString()));
Params.clear();
Params.put("liveId", liveID);
Params.put("interactNum", 2);
Params.put("showInteractNum", 2);
Params.put("welfareId", 194);
Params.put("afterMin", 40);
response = network.postResponse(Params, BasicConfig.MANAGER_add_1);
boolean data3 = response.jsonPath().getBoolean("data");
System.out.println(data3);
Assert.assertTrue(data3, network.message(Params, BasicConfig.MANAGER_add_1, "直播中抽奖配置失败", response.body().asString()));
}
}
......@@ -587,7 +587,7 @@ public class ConfSecondKill implements Authorization {
long resourceConfId = response.jsonPath().getLong("data.resourceConfId");
Assert.assertNotNull(resourceConfId,network.message(params,BasicConfig.MANAGER_killGoodsDetail,"查看看秒杀优惠券商品详情失败",response.body().asString()));
}
@Test(description = "助播端获取秒杀优惠券轮次", priority = 32)
@Test(description = "助播端获取秒杀优惠券轮次", priority = 31)
public void 助播端获取秒杀优惠券轮次() {
Map<String, Object> liveSecKillPar = new HashMap<>();
liveSecKillPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -604,4 +604,18 @@ public class ConfSecondKill implements Authorization {
Assert.fail(network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "未获取到数据", liveSecKillRes.body().asString()));
}
}
@Test(description = "保存代理人赠送优惠券配置",priority = 32)
public void 保存代理人赠送优惠券配置(){
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.StringKeyEnum.LIVE_ID.getKey());
params.put("voucherPrice",1);
params.put("effectiveScope",1);
params.put("totalCount",10);
params.put("invitationNumPerVoucher",1);
params.put("maxCountPerAgent",1);
Response response = network.postResponse(params,BasicConfig.MANAGER_voucherSave);
boolean succcess = response.jsonPath().getBoolean("success");
Assert.assertFalse(succcess,network.message(params,BasicConfig.MANAGER_voucherSave,"高级玩法下可配置代理人赠送优惠券",response.body().asString()));
}
}
......@@ -44,6 +44,20 @@ public class SecondKill implements Authorization {
connectSuccess();
}
public static void killOn(String killId){
Map<String, Object> goodsOnPar = new HashMap<>();
goodsOnPar.put("id", killId);
Response goodsOnRes = network.postResponse(goodsOnPar, BasicConfig.ANCHOR_secondKillOn);
System.out.println(goodsOnRes.body().asString());
try {
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()));
}
}
/**
* 直播中编辑秒杀轮次
*/
......@@ -163,17 +177,7 @@ public class SecondKill implements Authorization {
@Test(description = "助播端上架秒杀", priority = 10)
public void 助播端上架秒杀() {
adminAuth();
Map<String, Object> goodsOnPar = new HashMap<>();
goodsOnPar.put("id", ConfSecondKill.skIdFirst);
Response goodsOnRes = network.postResponse(goodsOnPar, BasicConfig.ANCHOR_secondKillOn);
System.out.println(goodsOnRes.body().asString());
try {
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()));
}
killOn(ConfSecondKill.skIdFirst);
// 检查秒杀状态
Map<String, Object> goodsStatusPar = new HashMap<>();
......@@ -192,17 +196,7 @@ public class SecondKill implements Authorization {
@Test(description = "同时上架0秒杀商品", priority = 11)
public void 同时上架0秒杀商品() {
adminAuth();
Map<String, Object> goodsOnPar = new HashMap<>();
goodsOnPar.put("id", ConfSecondKill.skIdThird);
Response goodsOnRes = network.postResponse(goodsOnPar, BasicConfig.ANCHOR_secondKillOn);
System.out.println(goodsOnRes.body().asString());
try {
boolean data = goodsOnRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(goodsOnPar, BasicConfig.ANCHOR_secondKillOn, "上架0元商品秒杀失败", goodsOnRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(goodsOnPar, BasicConfig.ANCHOR_secondKillOn, "未获取到数据", goodsOnRes.body().asString()));
}
killOn(ConfSecondKill.skIdThird);
}
// 切换访客
......@@ -585,16 +579,7 @@ public class SecondKill implements Authorization {
@Test(description = "上架第二轮秒杀,代理人可参与", priority = 28)
public void 上架第二轮秒杀() {
Map<String, Object> skOnPar = new HashMap<>();
skOnPar.put("id", ConfSecondKill.skIdSecond);
Response goodsOnRes = network.postResponse(skOnPar, BasicConfig.ANCHOR_secondKillOn);
try {
boolean data = goodsOnRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(skOnPar, BasicConfig.ANCHOR_secondKillOn, "上架秒杀失败", goodsOnRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(skOnPar, BasicConfig.ANCHOR_secondKillOn, "未获取到数据", goodsOnRes.body().asString()));
}
killOn(ConfSecondKill.skIdSecond);
}
@Test(description = "代理人成功下单-占用库存", priority = 29)
......@@ -809,16 +794,7 @@ public class SecondKill implements Authorization {
@Test(description = "上架需要秒杀资格的商品", priority = 36)
public void 上架需要秒杀资格的商品(){
adminAuth();
Map<String, Object> goodsOnPar = new HashMap<>();
goodsOnPar.put("id",ConfSecondKill.QualifiedId);
Response goodsOnRes = network.postResponse(goodsOnPar, BasicConfig.ANCHOR_secondKillOn);
try {
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()));
}
killOn(ConfSecondKill.QualifiedId);
}
@Test(description = "推送秒杀资格券",priority = 37)
public void 推送秒杀资格券(){
......@@ -1128,16 +1104,7 @@ public class SecondKill implements Authorization {
@Test(description = "上架秒杀优惠券商品",priority = 54)
public void 上架秒杀优惠券商品(){
adminAuth();
Map<String, Object> goodsOnPar = new HashMap<>();
goodsOnPar.put("id",ConfSecondKill.couponId);
Response goodsOnRes = network.postResponse(goodsOnPar, BasicConfig.ANCHOR_secondKillOn);
try {
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()));
}
killOn(ConfSecondKill.couponId);
}
@Test(description = "下单秒杀优惠券商品", priority = 55)
......
package com.kjj.cases.live.secondKill;
import com.alibaba.fastjson.JSON;
import com.kjj.bean.agent.AgentBean;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.JsonUtil;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.kjj.cases.live.anchor.CloseLive.closeLive;
import static com.kjj.cases.live.anchor.OpenLive.openLive;
import static com.kjj.cases.live.liveConfig.LiveBinding.binding;
import static com.kjj.cases.live.liveConfig.LiveBinding.share;
import static com.kjj.cases.live.secondKill.SecondKill.killOn;
import static com.kjj.config.BasicConfig.*;
import static com.kjj.config.BasicConfig.USER_clueInfoData;
import static com.kjj.utils.BaseUtils.connectSuccess;
import static com.kjj.utils.BaseUtils.ssoLogin;
import static com.kjj.utils.ThreadSleepUtils.sleep;
public class Voucher implements Authorization {
private String shareSign;
private String voucherId;
private String visitorUserId;
private String userId;
@Test(description = "直播前查看直播列表是否开启",priority = 1)
public void 直播前查看直播列表是否开启(){
agentAuth();
binding(shareSign);;
shareSign = share();
Map<String, Object> params = new HashMap<>();
params.put("pageIndex", 1);
params.put("pageSize", 20);
Response response = network.getResponse(params, BasicConfig.MOBILE_Procurator);
List<AgentBean> agentBeans = JsonUtil.parseResponseToPageBean(response, AgentBean.class);
if (agentBeans.size() > 0) {
for (AgentBean item:agentBeans) {
if(item.getLiveId().equals(LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()))){
System.out.println(JSON.toJSONString(item));
Assert.assertNotNull(item, network.message(params, BasicConfig.MOBILE_Procurator, "查询直播列表失败", response.body().asString()));
// 判断代理人邀约奖励openFlag是否为开
Assert.assertTrue(item.isAgentVoucherHasOpen(), network.message(params, MOBILE_Procurator, "代理人邀约奖励开启状态错误", response.body().asString()));
break;
}
}
}
}
@Test(description = "查询代金券详情",priority = 2)
public void 查询代金券详情(){
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherDetail);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_voucherDetail,"代金券详情为空",response.body().asString()));
int voucherPrice = response.jsonPath().getInt("data.voucherPrice");
int effectiveScope = response.jsonPath().getInt("data.effectiveScope");
int needInviteNum = response.jsonPath().getInt("data.needInviteNum");
int totalRemainNum = response.jsonPath().getInt("data.totalRemainNum");
Assert.assertEquals(voucherPrice,2 ,network.message(params,BasicConfig.MOBILE_voucherDetail,"代金券价格错误",response.body().asString()));
Assert.assertEquals(needInviteNum,2 ,network.message(params,BasicConfig.MOBILE_voucherDetail,"代金券邀请门槛错误",response.body().asString()));
Assert.assertEquals(effectiveScope,1, network.message(params,BasicConfig.MOBILE_voucherDetail,"代金券使用范围错误",response.body().asString()));
Assert.assertEquals(totalRemainNum,3, network.message(params,BasicConfig.MOBILE_voucherDetail,"代金券剩余数量为空",response.body().asString()));
voucherId = response.jsonPath().getString("data.voucherId");
}
@Test(description = "查询代理人参与信息",priority = 3)
public void 查询代理人参与信息(){
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherJoinInfo);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券详情为空",response.body().asString()));
int agentVoucherCanGiftNum = response.jsonPath().getInt("data.agentVoucherCanGiftNum");
int agentVoucherHasGiftedNume = response.jsonPath().getInt("data.agentVoucherHasGiftedNum");
int invitationProgress = response.jsonPath().getInt("data.invitationProgress");
Assert.assertEquals(agentVoucherCanGiftNum,0 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券可赠送张数错误",response.body().asString()));
Assert.assertEquals(agentVoucherHasGiftedNume,0 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券已赠送张数错误",response.body().asString()));
Assert.assertEquals(invitationProgress,0, network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"当前剩余邀请人数错误",response.body().asString()));
}
@Test(description = "代理人查看赠送明细",priority = 4)
public void 代理人查看赠送明细(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherGiftList);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_voucherGiftList,"代金券详情为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
Assert.assertEquals(size,0, network.message(params,BasicConfig.MOBILE_voucherGiftList,"赠送明细不为空",response.body().asString()));
}
@Test(description = "代理人邀请客户A",priority = 5)
public void 代理人邀请客户A(){
visitorAuth3();
binding(shareSign);
}
@Test(description = "代理人邀请进度更新",priority = 6)
public void 代理人邀请进度更新(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherJoinInfo);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券详情为空",response.body().asString()));
int agentVoucherCanGiftNum = response.jsonPath().getInt("data.agentVoucherCanGiftNum");
int agentVoucherHasGiftedNum = response.jsonPath().getInt("data.agentVoucherHasGiftedNum");
int invitationProgress = response.jsonPath().getInt("data.invitationProgress");
Assert.assertEquals(agentVoucherCanGiftNum,0 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券可赠送张数错误",response.body().asString()));
Assert.assertEquals(agentVoucherHasGiftedNum,0 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券已赠送张数错误",response.body().asString()));
Assert.assertEquals(invitationProgress,1, network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"当前剩余邀请人数错误",response.body().asString()));
}
@Test(description = "代理人邀请客户B",priority = 7)
public void 代理人邀请客户B(){
visitorAuth2();
binding(shareSign);
}
@Test(description = "代理人达成第一张代金券门槛",priority = 8)
public void 代理人达成第一张代金券门槛(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherJoinInfo);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券详情为空",response.body().asString()));
int agentVoucherCanGiftNum = response.jsonPath().getInt("data.agentVoucherCanGiftNum");
int agentVoucherHasGiftedNum = response.jsonPath().getInt("data.agentVoucherHasGiftedNum");
int invitationProgress = response.jsonPath().getInt("data.invitationProgress");
Assert.assertEquals(agentVoucherCanGiftNum,1 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券可赠送张数错误",response.body().asString()));
Assert.assertEquals(agentVoucherHasGiftedNum,0 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券已赠送张数错误",response.body().asString()));
Assert.assertEquals(invitationProgress,2, network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"当前剩余邀请人数错误",response.body().asString()));
}
@Test(description = "代理人的赠送对象列表",priority = 9)
public void 代理人的赠送对象列表(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("pageIndex",1);
params.put("pageSize",10);
Response response = network.getResponse(params,BasicConfig.MOBILE_agentSelectList);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_agentSelectList,"代金券详情为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
int giftStatus = response.jsonPath().getInt("data.list[0].giftStatus");
Assert.assertEquals(size,2 ,network.message(params,BasicConfig.MOBILE_agentSelectList,"可赠送对象数错误",response.body().asString()));
Assert.assertEquals(giftStatus,1 ,network.message(params,BasicConfig.MOBILE_agentSelectList,"用户赠送状态错误非未赠送",response.body().asString()));
visitorUserId = response.jsonPath().getString("data.list[1].visitorUserId");
userId = response.jsonPath().getString("data.list[0].visitorUserId");
}
@Test(description = "代理人赠送代金券给客户A",priority = 10)
public void 代理人赠送代金券给客户A(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("voucherId",voucherId);
params.put("visitorUserId",visitorUserId);
Response response = network.postResponse(params,BasicConfig.MOBILE_agentGift);
Assert.assertTrue(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_agentGift,"代理人赠送代金券失败",response.body().asString()));
}
@Test(description = "代理人参与进度更新",priority = 11)
public void 代理人参与进度更新(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherJoinInfo);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券详情为空",response.body().asString()));
int agentVoucherCanGiftNum = response.jsonPath().getInt("data.agentVoucherCanGiftNum");
int agentVoucherHasGiftedNume = response.jsonPath().getInt("data.agentVoucherHasGiftedNum");
int invitationProgress = response.jsonPath().getInt("data.invitationProgress");
Assert.assertEquals(agentVoucherCanGiftNum,0 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券可赠送张数错误",response.body().asString()));
Assert.assertEquals(agentVoucherHasGiftedNume,1 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券已赠送张数错误",response.body().asString()));
Assert.assertEquals(invitationProgress,2, network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"当前剩余邀请人数错误",response.body().asString()));
}
@Test(description = "代理人邀请客户",priority = 12)
public void 代理人邀请客户(){
visitorAuth1();
binding(shareSign);
visitorAuth4();
binding(shareSign);
visitorAuth5();
binding(shareSign);
visitorAuth6();
binding(shareSign);
}
@Test(description = "代理人的赠送对象列表更新",priority = 13)
public void 代理人的赠送对象列表更新(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("pageIndex",1);
params.put("pageSize",10);
Response response = network.getResponse(params,BasicConfig.MOBILE_agentSelectList);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_agentSelectList,"代金券详情为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
int giftStatus = response.jsonPath().getInt("data.list[5].giftStatus");
Assert.assertEquals(size,6 ,network.message(params,BasicConfig.MOBILE_agentSelectList,"可赠送对象数错误",response.body().asString()));
Assert.assertEquals(giftStatus,2 ,network.message(params,BasicConfig.MOBILE_agentSelectList,"用户赠送状态错误非已赠送未收下",response.body().asString()));
}
@Test(description = "代理人代金券数量达上限",priority = 14)
public void 代理人代金券数量达上限(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherJoinInfo);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券详情为空",response.body().asString()));
int agentVoucherCanGiftNum = response.jsonPath().getInt("data.agentVoucherCanGiftNum");
int agentVoucherHasGiftedNume = response.jsonPath().getInt("data.agentVoucherHasGiftedNum");
int invitationProgress = response.jsonPath().getInt("data.invitationProgress");
Assert.assertEquals(agentVoucherCanGiftNum,1 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券可赠送张数错误",response.body().asString()));
Assert.assertEquals(agentVoucherHasGiftedNume,1 ,network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"代金券已赠送张数错误",response.body().asString()));
Assert.assertEquals(invitationProgress,6, network.message(params,BasicConfig.MOBILE_voucherJoinInfo,"当前剩余邀请人数错误",response.body().asString()));
}
@Test(description = "客户A查询直播前代金券配置",priority = 15)
public void 客户A查询直播前代金券配置(){
sleep(1000);
visitorAuth3();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,MOBILE_allLottery);
try{
int on = response.jsonPath().getInt("data.on");
System.out.println(on);
String confStr = Integer.toBinaryString(on);
System.out.println(confStr);
char confStatus = confStr.charAt(confStr.length()-6);
Assert.assertEquals(confStatus, '1',network.message(params,MOBILE_allLottery, "代理人赠送代金券未开启", response.body().asString()));
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(params, MOBILE_allLottery, "未获取到数据", response.body().asString()));
}
}
@Test(description = "客户A收下代金券",priority = 16)
public void 客户A收下代金券(){
sleep(1000);
visitorAuth3();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("voucherId", voucherId);
Response response = network.postResponse(params,BasicConfig.MOBILE_acceptGift);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(params,BasicConfig.MOBILE_acceptGift, "代理人赠送代金券未开启", response.body().asString()));
}
@Test(description = "代理人的赠送对象列表为已赠送",priority = 17)
public void 代理人的赠送对象列表为已赠送(){
sleep(1000);
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("pageIndex",1);
params.put("pageSize",10);
Response response = network.getResponse(params,BasicConfig.MOBILE_agentSelectList);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_agentSelectList,"代金券详情为空",response.body().asString()));
int giftStatus = response.jsonPath().getInt("data.list[5].giftStatus");
Assert.assertEquals(giftStatus,3 ,network.message(params,BasicConfig.MOBILE_agentSelectList,"用户赠送状态错误非已赠送未收下",response.body().asString()));
}
@Test(description = "已收下客户用户代金券列表",priority = 18)
public void 已收下客户用户代金券列表(){
sleep(1000);
visitorAuth3();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherList);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"),network.message(params,BasicConfig.MOBILE_voucherList, "代理人赠送代金券未开启", response.body().asString()));
String id = response.jsonPath().getString("data[0].voucherId");
int voucherPrice = response.jsonPath().getInt("data[0].voucherPrice");
int voucherStatus = response.jsonPath().getInt("data[0].voucherStatus");
Assert.assertEquals(id,voucherId,network.message(params,BasicConfig.MOBILE_voucherList, "代金券ID错误", response.body().asString()));
Assert.assertEquals(voucherPrice,2,network.message(params,BasicConfig.MOBILE_voucherList, "代金券价格错误", response.body().asString()));
Assert.assertEquals(voucherStatus,2,network.message(params,BasicConfig.MOBILE_voucherList, "代金券状态错误非已收下", response.body().asString()));
}
@Test(description = "未收下客户用户代金券列表",priority = 19)
public void 未赠送客户用户代金券列表(){
sleep(1000);
visitorAuth2();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherList);
int size = response.jsonPath().getInt("data.size()");
Assert.assertEquals(size , 0, network.message(params,BasicConfig.MOBILE_voucherList, "未赠送返回结果不为空", response.body().asString()));
}
@Test(description = "开启直播并上架秒杀", priority = 20)
public void 开启直播并上架秒杀() {
//开启直播
adminAuth();
openLive(LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
killOn(VoucherConf.skIdFirst);
killOn(VoucherConf.skIdSecond);
visitorAuth3();
connectSuccess();
visitorAuth2();
connectSuccess();
}
@Test(description = "直播中查看直播列表是否开启", priority = 21)
public void 直播中查看直播列表是否开启() {
//切换为访客
visitorAuth3();
sleep(10000);
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,USER_clueInfoData);
try{
int on = response.jsonPath().getInt("data.on");
System.out.println(on);
String confStr = Integer.toBinaryString(on);
System.out.println(confStr);
char confStatus = confStr.charAt(confStr.length()-17);
Assert.assertEquals(confStatus, '1',network.message(params,USER_clueInfoData, "代理人赠送代金券未开启", response.body().asString()));
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(params, MOBILE_allLottery, "未获取到数据", response.body().asString()));
}
}
@Test(description = "客户A使用代金券下单价格大于代金券的商品", priority = 22)
public void 客户A使用代金券下单价格大于代金券的商品() {
visitorAuth3();
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", VoucherConf.skIdFirst);
orderPar.put("voucherId",voucherId);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder, "下单失败", orderRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder, "未获取到数据", orderRes.body().asString()));
}
}
@Test(description = "客户A获取下单结果", priority = 23)
public void 客户A获取下单结果() {
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", VoucherConf.skIdFirst);
Response orderResultRes = null;
Object data = null;
int i = 0;
try {
// 轮训下单接口
while (data == null){
sleep(2000);
orderResultRes = network.getResponse(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult);
data = orderResultRes.jsonPath().getJsonObject("data");
i++;
if (i == 10){
Assert.fail(network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "轮训下单结果超过10次", orderResultRes.body().asString()));
}
}
int state = orderResultRes.jsonPath().getInt("data.state");
Assert.assertEquals(state, 4, network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "下单未成功", orderResultRes.body().asString()));
System.out.println(data);
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "获取数据失败", orderResultRes.body().asString()));
}
}
@Test(description = "客户A用户代金券列表更新",priority = 24)
public void 客户A用户代金券列表更新(){
sleep(1000);
visitorAuth3();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherList);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"),network.message(params,BasicConfig.MOBILE_voucherList, "代理人赠送代金券未开启", response.body().asString()));
int voucherStatus = response.jsonPath().getInt("data[0].voucherStatus");
Assert.assertEquals(voucherStatus,3,network.message(params,BasicConfig.MOBILE_voucherList, "代金券状态错误", response.body().asString()));
}
@Test(description = "代理人赠送第二张代金券并收下",priority = 25)
public void 代理人赠送第二张代金券并收下(){
agentAuth();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("voucherId",voucherId);
params.put("visitorUserId",userId);
Response response = network.postResponse(params,BasicConfig.MOBILE_agentGift);
Assert.assertTrue(response.jsonPath().getJsonObject("data"), network.message(params,BasicConfig.MOBILE_agentGift,"代理人赠送代金券失败",response.body().asString()));
}
@Test(description = "未收下客户用户代金券列表",priority = 26)
public void 未收下客户用户代金券列表(){
sleep(1000);
visitorAuth2();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,BasicConfig.MOBILE_voucherList);
Assert.assertNotNull(response.jsonPath().getJsonObject("data"),network.message(params,BasicConfig.MOBILE_voucherList, "代理人赠送代金券未开启", response.body().asString()));
String id = response.jsonPath().getString("data[0].voucherId");
int voucherStatus = response.jsonPath().getInt("data[0].voucherStatus");
Assert.assertEquals(id,voucherId,network.message(params,BasicConfig.MOBILE_voucherList, "代金券ID错误", response.body().asString()));
Assert.assertEquals(voucherStatus,1,network.message(params,BasicConfig.MOBILE_voucherList, "代金券状态错误非未收下", response.body().asString()));
}
@Test(description = "客户B收下代金券",priority = 27)
public void 客户B收下代金券(){
visitorAuth2();
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("voucherId", voucherId);
Response response = network.postResponse(params,BasicConfig.MOBILE_acceptGift);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(params,BasicConfig.MOBILE_acceptGift, "代理人赠送代金券未开启", response.body().asString()));
}
@Test(description = "客户B使用代金券下单价格小于代金券的商品", priority = 28)
public void 客户B使用代金券下单价格小于代金券的商品() {
visitorAuth2();
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", VoucherConf.skIdSecond);
orderPar.put("voucherId",voucherId);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder, "下单失败", orderRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder, "未获取到数据", orderRes.body().asString()));
}
}
@Test(description = "客户B获取下单结果", priority = 29)
public void 客户B获取下单结果() {
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", VoucherConf.skIdSecond);
Response orderResultRes = null;
Object data = null;
int i = 0;
try {
// 轮训下单接口
while (data == null){
sleep(2000);
orderResultRes = network.getResponse(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult);
data = orderResultRes.jsonPath().getJsonObject("data");
i++;
if (i == 10){
Assert.fail(network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "轮训下单结果超过10次", orderResultRes.body().asString()));
}
}
int state = orderResultRes.jsonPath().getInt("data.state");
Assert.assertEquals(state, 3, network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "下单未成功", orderResultRes.body().asString()));
System.out.println(data);
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "获取数据失败", orderResultRes.body().asString()));
}
}
@Test(description = "管理后台查看用户代金券秒杀订单",priority = 30)
public void 管理后台查看用户代金券秒杀订单(){
sleep(10000);
ssoLogin();
Map<String,Object> params =new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
params.put("companyId",101);
params.put("liveVisitorId",101);
params.put("pageIndex",1);
params.put("pageSize",10);
Response response = network.getResponse(params,BasicConfig.MANAGER_order_detail);
int size = response.jsonPath().getInt("data.list.size()");
Assert.assertEquals(size, 1, network.message(params,BasicConfig.MANAGER_order_detail,"用户秒杀订单为空",response.body().asString()));
int orderAmount = response.jsonPath().getInt("data.list[0].orderAmount");
Assert.assertEquals(orderAmount, 1, network.message(params,BasicConfig.MANAGER_order_detail,"用户秒杀支付金额错误",response.body().asString()));
}
@Test(description = "直播结束后查看直播列表是否开启",priority = 31)
public void 直播结束后查看直播列表是否开启(){
Map<String, Object> params = new HashMap<>();
params.put("pageIndex", 1);
params.put("pageSize", 20);
Response response = network.getResponse(params, BasicConfig.MOBILE_Procurator);
List<AgentBean> agentBeans = JsonUtil.parseResponseToPageBean(response, AgentBean.class);
if (agentBeans.size() > 0) {
for (AgentBean item:agentBeans) {
if(item.getLiveId().equals(LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()))){
System.out.println(JSON.toJSONString(item));
Assert.assertNotNull(item, network.message(params, BasicConfig.MOBILE_Procurator, "查询直播列表失败", response.body().asString()));
// 判断代理人邀约奖励openFlag是否为开
Assert.assertTrue(item.isAgentVoucherHasOpen(), network.message(params, MOBILE_Procurator, "代理人邀约奖励开启状态错误", response.body().asString()));
break;
}
}
}
}
@Test(description = "结束直播", priority = 32)
public void 结束直播() {
adminAuth();
closeLive(LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
}
}
package com.kjj.cases.live.secondKill;
import com.kjj.bean.secondKill.AnchorGetSKList;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.JsonUtil;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class VoucherConf implements Authorization {
private static final long secKillGoodsId = 115; // 用来配置轮次的秒杀商品ID
private long voucherConfId;
public static String skIdFirst; // 第一轮秒杀id
public static String skIdSecond; // 第二轮秒杀ID
@Test(description = "添加秒杀互动", priority = 1)
public void 添加秒杀互动() {
Map<String, Object> secKillAddPar = new HashMap<>();
secKillAddPar.put("goodsId", secKillGoodsId);
secKillAddPar.put("goodsAmount",2); // 1 == 0.01
secKillAddPar.put("interactNum", 3);
secKillAddPar.put("ableAgent", 0); // 代理人不可参与
secKillAddPar.put("isNeedQualified", 0); // 不需要秒杀资格
secKillAddPar.put("playType",0);//高级玩法配置,0为不配置,1为秒杀资格,2为秒杀优惠券
secKillAddPar.put("afterPrice","");
secKillAddPar.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
Response secKillAddRes = network.postResponse(secKillAddPar, BasicConfig.MANAGER_secondKillSave);
boolean data = secKillAddRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(secKillAddPar, BasicConfig.MANAGER_secondKillSave, "添加秒杀互动失败", secKillAddRes.body().asString()));
secKillAddPar.put("goodsAmount",3);
secKillAddRes = network.postResponse(secKillAddPar, BasicConfig.MANAGER_secondKillSave);
data = secKillAddRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(secKillAddPar, BasicConfig.MANAGER_secondKillSave, "添加秒杀互动失败", secKillAddRes.body().asString()));
}
@Test(description = "保存代理人赠送优惠券配置",priority = 2)
public void 保存代理人赠送优惠券配置(){
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
params.put("voucherPrice",1);
params.put("effectiveScope",1);
params.put("totalCount",2);
params.put("invitationNumPerVoucher",1);
params.put("maxCountPerAgent",1);
Response response = network.postResponse(params, BasicConfig.MANAGER_voucherSave);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(params,BasicConfig.MANAGER_voucherSave,"配置代理人赠送优惠券失败",response.body().asString()));
}
@Test(description = "查询代理人赠送优惠券配置",priority = 3)
public void 查询代理人赠送优惠券配置(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
Response response = network.getResponse(params, BasicConfig.MANAGER_voucherDetail);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(params,BasicConfig.MANAGER_voucherDetail,"查询代理人赠送优惠券失败",response.body().asString()));
Assert.assertNotNull(response.jsonPath().getJsonObject("data"),network.message(params,BasicConfig.MANAGER_voucherDetail,"代理人赠送优惠券配置为空",response.body().asString()));
voucherConfId = response.jsonPath().getLong("data.id");
}
@Test(description = "减少优惠券总数失败",priority = 3)
public void 减少优惠券总数失败(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
params.put("id",voucherConfId);
params.put("voucherPrice",1);
params.put("effectiveScope",1);
params.put("totalCount",1);
params.put("invitationNumPerVoucher",1);
params.put("maxCountPerAgent",1);
Response response = network.postResponse(params, BasicConfig.MANAGER_voucherSave);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertFalse(success,network.message(params,BasicConfig.MANAGER_voucherSave,"减少优惠券总数成功",response.body().asString()));
}
@Test(description = "修改代理人赠送优惠券配置",priority = 4)
public void 修改代理人赠送优惠券配置(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
params.put("id",voucherConfId);
params.put("voucherPrice",2);
params.put("effectiveScope",1);
params.put("totalCount",3);
params.put("invitationNumPerVoucher",2);
params.put("maxCountPerAgent",2);
Response response = network.postResponse(params, BasicConfig.MANAGER_voucherSave);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(params,BasicConfig.MANAGER_voucherSave,"修改代理人赠送优惠券配置失败",response.body().asString()));
}
@Test(description = "开启代理人赠送优惠券配置",priority = 6)
public void 开启代理人赠送优惠券配置(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
params.put("open",false);
Response response = network.postResponse(params, BasicConfig.MANAGER_voucherModifyState);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(params,BasicConfig.MANAGER_voucherModifyState,"关闭代理人赠送优惠券配置失败",response.body().asString()));
params.put("open",true);
response = network.postResponse(params, BasicConfig.MANAGER_voucherModifyState);
success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(params,BasicConfig.MANAGER_voucherModifyState,"开启代理人赠送优惠券配置失败",response.body().asString()));
}
@Test(description = "查询代理人赠送优惠券状态",priority = 7)
public void 查询代理人赠送优惠券状态(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
Response response = network.getResponse(params, BasicConfig.MANAGER_voucherState);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(params,BasicConfig.MANAGER_voucherState,"代理人赠送优惠券配置未开启",response.body().asString()));
}
@Test(description = "助播端获取秒杀轮次列表", priority = 8)
public void 助播端获取秒杀轮次列表() {
adminAuth();
Map<String, Object> liveSecKillPar = new HashMap<>();
liveSecKillPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response liveSecKillRes = network.getResponse(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists);
List<AnchorGetSKList> secKillLists;
secKillLists = JsonUtil.parseResponseToListBean(liveSecKillRes, AnchorGetSKList.class);
skIdFirst = secKillLists.get(0).getId();
skIdSecond = secKillLists.get(1).getId();
}
}
......@@ -193,6 +193,17 @@ public class BasicConfig {
public static final String MANAGER_killGoodsDetail= MANAGER_HOST + "/kjy/manager/live/second/kill/goods/detail";
public static final String MOBILE_couponsList= MOBILE_HOST + "/clue/goods/coupons/list";
public static final String MOBILE_couponsReceive= MOBILE_HOST +"/clue/goods/coupons/receive";
public static final String MANAGER_voucherSave= MANAGER_HOST +"/kjy/manager/live/voucher/save";
public static final String MANAGER_voucherDetail= MANAGER_HOST + "/kjy/manager/live/voucher/detail";
public static final String MANAGER_voucherModifyState= MANAGER_HOST +"/kjy/manager/live/voucher/modifyState";
public static final String MANAGER_voucherState = MANAGER_HOST + "/kjy/manager/live/voucher/state";
public static final String MOBILE_voucherDetail = MOBILE_HOST + "/kjy/live/voucher/detail";
public static final String MOBILE_voucherJoinInfo = MOBILE_HOST + "/kjy/live/voucher/agent/joinInfo";
public static final String MOBILE_voucherGiftList = MOBILE_HOST + "/kjy/live/voucher/agent/giftList";
public static final String MOBILE_agentSelectList = MOBILE_HOST + "/kjy/live/voucher/agent/selectList";
public static final String MOBILE_agentGift = MOBILE_HOST + "/kjy/live/voucher/agent/gift";
public static final String MOBILE_acceptGift = MOBILE_HOST + "/clue/goods/voucher/accept";
public static final String MOBILE_voucherList = MOBILE_HOST + "/clue/goods/voucher/list";
//客户承诺话术配置
public static final String MANAGER_saveDialogue = MANAGER_HOST + "/kjy/manager/live/potential/saveDialogue";
public static final String MANAGER_findDialogue = MANAGER_HOST + "/kjy/manager/live/potential/findDialogue";
......
......@@ -203,7 +203,7 @@ public class BaseUtils {
}
/*
* 访客到场
* 访客到场(仅直播开始后才可调用)
* */
public static void connectSuccess() {
Map<String, Object> connectSuccessParam = new HashMap<>();
......
......@@ -273,5 +273,23 @@
<class name="com.kjj.cases.live.customer.PersonalPage" />
</classes>
</test>
<test preserve-order="true" name="创建简易直播">
<classes>
<class name="com.kjj.cases.live.liveConfig.SimpleLive"/>
</classes>
</test>
<test preserve-order="true" name="配置代理人赠送秒杀优惠券">
<classes>
<class name="com.kjj.cases.live.secondKill.VoucherConf"/>
</classes>
</test>
<test preserve-order="true" name="代理人赠送秒杀优惠券并用户使用代金券">
<classes>
<class name="com.kjj.cases.live.secondKill.Voucher"/>
</classes>
</test>
</suite>
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