Commit 9c826a5d authored by xiamengchen's avatar xiamengchen

覆盖秒杀互动

parent df1e26e3
package com.kjj.bean.secondKill;
import lombok.Data;
@Data
public class AnchorGetKGList {
private String goodsTitle;
private String id;
}
......@@ -5,5 +5,5 @@ import lombok.Data;
@Data
public class AnchorGetSKList {
private int interactStatus;
private long id;
private String id;
}
......@@ -2324,6 +2324,25 @@ public class SaveLive implements Authorization {
Assert.assertNotNull(data, network.message(Params, BasicConfig.MANAGER_otherDetail, "查询第6轮时长红包详情失败", response.body().asString()));
}
/**
* 亲友抽奖券配置
*/
@Test(description = "保存亲友抽奖券配置", priority = 128)
public void 保存亲友抽奖券配置(){
ssoLogin();
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
Params.put("giftedImg","https://yun.dui88.com/kjy/image/20210825/1629861430316.png");
Params.put("notGiftedImg","https://yun.dui88.com/kjy/image/20210825/1629861425857.png");
Params.put("popImg","https://yun.dui88.com/kjy/image/20210825/1629861435394.png");
Params.put("envelopeWord","这是信封话术");
Params.put("lotteryName","亲友抽奖券");
Params.put("lotteryNum",3);
Params.put("lotteryDesc","这是亲友抽奖券的说明");
Response response = network.postResponse(Params, BasicConfig.MANAGER_relativeLottery);
System.out.println(response.body().asString());
boolean data =response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(Params, BasicConfig.MANAGER_relativeLottery, "保存亲友券配置失败", response.body().asString()));
}
@Test(description = "查看亲友抽奖券配置详情", priority = 129)
......
package com.kjj.cases.live.secondKill;
import com.kjj.bean.secondKill.AnchorGetKGList;
import com.kjj.bean.secondKill.AnchorGetSKList;
import com.kjj.bean.secondKill.KillGoodsList;
import com.kjj.bean.secondKill.SecondKillList;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
......@@ -22,9 +22,10 @@ public class ConfSecondKill implements Authorization {
private final long companyId = 101;
private long newSecKillId; // 会被删除的秒杀id
private static final long secKillGoodsId = 111; // 用来配置轮次的秒杀商品ID
private static final long secKillGoodsId = 115; // 用来配置轮次的秒杀商品ID
public static final String secKillGoodsIdEncode = IdMakeUtil.managerEncodingId(secKillGoodsId);
private long skId; // 秒杀id
private String skId; // 秒杀id
public static int killListSize;
@BeforeClass
public void setUp(){
......@@ -99,7 +100,7 @@ public class ConfSecondKill implements Authorization {
int goodsAmount = secondKillList.getGoodsAmount();
Assert.assertEquals(goodsAmount, 1, network.message(liveSecKillPar, BasicConfig.MANAGER_secondKillLists, "商品价格与实际添加的不符", liveSecKillRes.body().asString()));
String goodsTitle = secondKillList.getGoodsTitle();
Assert.assertEquals(goodsTitle, "秒杀商品4", network.message(liveSecKillPar, BasicConfig.MANAGER_secondKillLists, "商品名称与实际添加的不符", liveSecKillRes.body().asString()));
Assert.assertEquals(goodsTitle, "自动化专用商品", network.message(liveSecKillPar, BasicConfig.MANAGER_secondKillLists, "商品名称与实际添加的不符", liveSecKillRes.body().asString()));
int interactNum = secondKillList.getInteractNum();
Assert.assertEquals(interactNum, 3, network.message(liveSecKillPar, BasicConfig.MANAGER_secondKillLists, "商品数量与实际添加的不符", liveSecKillRes.body().asString()));
int surplusNum = secondKillList.getSurplusNum();
......@@ -164,10 +165,10 @@ public class ConfSecondKill implements Authorization {
Map<String, Object> skGoodsListPar = new HashMap<>();
skGoodsListPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response skGoodsListRes = network.getResponse(skGoodsListPar, BasicConfig.ANCHOR_skGoodsLists);
List<KillGoodsList> killGoodsLists;
List<AnchorGetKGList> anchorGetKGLists;
try {
killGoodsLists = JsonUtil.parseResponseToListBean(skGoodsListRes, KillGoodsList.class);
String goodTitle = killGoodsLists.get(0).getGoodsTitle();
anchorGetKGLists = JsonUtil.parseResponseToListBean(skGoodsListRes, AnchorGetKGList.class);
String goodTitle = anchorGetKGLists.get(0).getGoodsTitle();
Assert.assertEquals(goodTitle, "自动化专用商品", network.message(skGoodsListPar, BasicConfig.ANCHOR_skGoodsLists, "商品名称不正确", skGoodsListRes.body().asString()));
}catch (Exception e){
e.printStackTrace();
......@@ -201,8 +202,8 @@ public class ConfSecondKill implements Authorization {
List<AnchorGetSKList> secKillLists;
try {
secKillLists = JsonUtil.parseResponseToListBean(liveSecKillRes, AnchorGetSKList.class);
skId = secKillLists.get(-1).getId();
System.out.println(secKillLists);
killListSize = secKillLists.size();
skId = secKillLists.get(killListSize - 1).getId();
System.out.println(skId);
}catch (Exception e){
e.printStackTrace();
......@@ -217,7 +218,7 @@ public class ConfSecondKill implements Authorization {
secKillUpdatePar.put("goodsId", secKillGoodsIdEncode);
secKillUpdatePar.put("goodsAmount", 1);
secKillUpdatePar.put("interactNum", 3);
secKillUpdatePar.put("id", IdMakeUtil.managerEncodingId(skId));
secKillUpdatePar.put("id", skId);
secKillUpdatePar.put("ableAgent", 0);
Response secKillUpdateRes = network.postResponse(secKillUpdatePar, BasicConfig.ANCHOR_secondKillUpdate);
try {
......
package com.kjj.cases.live.secondKill;
import com.kjj.bean.secondKill.AnchorGetSKList;
import com.kjj.bean.secondKill.SecondKillList;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
......@@ -7,6 +8,7 @@ import com.kjj.constants.LiveConstants;
import com.kjj.utils.BaseUtils;
import com.kjj.utils.IdMakeUtil;
import com.kjj.utils.JsonUtil;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
......@@ -17,7 +19,8 @@ import java.util.List;
import java.util.Map;
public class SecondKill implements Authorization {
private String secKillId;
private String secKillId; // 第一轮秒杀id
private String confId1; // 第一轮秒杀confId
@BeforeClass
public void setUp(){
......@@ -42,6 +45,7 @@ public class SecondKill implements Authorization {
Assert.fail(network.message(liveSecKillPar, BasicConfig.MANAGER_secondKillLists, "未获取到数据", liveSecKillRes.body().asString()));
}
secKillId = IdMakeUtil.managerEncodingId(secondKillList.getId());
System.out.println(secKillId);
}
@Test(description = "修改秒杀商品", priority = 2)
......@@ -70,6 +74,208 @@ public class SecondKill implements Authorization {
@Test(description = "减少秒杀商品数量", priority = 4)
public void 减少秒杀商品数量() {
Map<String, Object> secKillUpdatePar = new HashMap<>();
secKillUpdatePar.put("goodsId", ConfSecondKill.secKillGoodsIdEncode);
secKillUpdatePar.put("goodsAmount", 1);
secKillUpdatePar.put("interactNum", 1);
secKillUpdatePar.put("id", secKillId);
secKillUpdatePar.put("ableAgent", 0);
Response secKillUpdateRes = network.postResponse(secKillUpdatePar, BasicConfig.ANCHOR_secondKillUpdate);
System.out.println(secKillUpdateRes.body().asString());
}
@Test(description = "增加秒杀商品数量", priority = 5)
public void 增加秒杀商品数量() {
Map<String, Object> secKillUpdatePar = new HashMap<>();
secKillUpdatePar.put("goodsId", ConfSecondKill.secKillGoodsIdEncode);
secKillUpdatePar.put("goodsAmount", 1);
secKillUpdatePar.put("interactNum", 4);
secKillUpdatePar.put("id", secKillId);
secKillUpdatePar.put("ableAgent", 0);
Response secKillUpdateRes = network.postResponse(secKillUpdatePar, BasicConfig.ANCHOR_secondKillUpdate);
try {
boolean data = secKillUpdateRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(secKillUpdatePar, BasicConfig.ANCHOR_secondKillUpdate, "增加商品数量失败", secKillUpdateRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(secKillUpdatePar, BasicConfig.ANCHOR_secondKillUpdate, "未获取到数据", secKillUpdateRes.body().asString()));
}
}
@Test(description = "修改代理人限制", priority = 6)
public void 修改代理人限制() {
Map<String, Object> secKillUpdatePar = new HashMap<>();
secKillUpdatePar.put("goodsId", ConfSecondKill.secKillGoodsIdEncode);
secKillUpdatePar.put("goodsAmount", 1);
secKillUpdatePar.put("interactNum", 4);
secKillUpdatePar.put("id", secKillId);
secKillUpdatePar.put("ableAgent", 1);
Response secKillUpdateRes = network.postResponse(secKillUpdatePar, BasicConfig.ANCHOR_secondKillUpdate);
try {
boolean data = secKillUpdateRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(secKillUpdatePar, BasicConfig.ANCHOR_secondKillUpdate, "修改代理人参与限制失败", secKillUpdateRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(secKillUpdatePar, BasicConfig.ANCHOR_secondKillUpdate, "未获取到数据", secKillUpdateRes.body().asString()));
}
}
/**
* 访客参与秒杀互动
*/
@Test(description = "获取秒杀商品列表", priority = 7)
public void 获取秒杀商品列表() {
visitorAuth();
Map<String, Object> goodsListPar = new HashMap<>();
goodsListPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response goodsListRes = network.getResponse(goodsListPar, BasicConfig.MOBILE_secondKill_getGoodsList);
try {
List<Object> goodsLists = goodsListRes.jsonPath().getList("data");
Assert.assertEquals(goodsLists.size(), ConfSecondKill.killListSize, network.message(goodsListPar, BasicConfig.MOBILE_secondKill_getGoodsList, "商品列表大小有误", goodsListRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(goodsListPar, BasicConfig.MOBILE_secondKill_getGoodsList, "未获取到数据", goodsListRes.body().asString()));
}
confId1 = goodsListRes.jsonPath().getString("data[0].confId");
}
@Test(description = "查看秒杀商品详情", priority = 8)
public void 查看秒杀商品详情() {
Map<String, Object> goodsDetailPar = new HashMap<>();
goodsDetailPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
goodsDetailPar.put("confId", confId1);
Response goodsDetailRes = network.getResponse(goodsDetailPar, BasicConfig.MOBILE_secondKill_getGoodsDetail);
try {
String goodsTitle = goodsDetailRes.jsonPath().getString("data.goodsTitle");
int interactStatus = goodsDetailRes.jsonPath().getInt("data.interactStatus");
Assert.assertEquals(goodsTitle, "自动化专用商品", network.message(goodsDetailPar, BasicConfig.MOBILE_secondKill_getGoodsDetail, "秒杀商品标题错误", goodsDetailRes.body().asString()));
Assert.assertEquals(interactStatus, 0, network.message(goodsDetailPar, BasicConfig.MOBILE_secondKill_getGoodsDetail, "该轮次状态错误", goodsDetailRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(goodsDetailPar, BasicConfig.MOBILE_secondKill_getGoodsDetail, "未获取到数据", goodsDetailRes.body().asString()));
}
}
// 助播端上架秒杀
@Test(description = "助播端上架秒杀", priority = 9)
public void 助播端上架秒杀() {
adminAuth();
Map<String, Object> goodsOnPar = new HashMap<>();
goodsOnPar.put("id", secKillId);
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()));
}
// 检查秒杀状态
Map<String, Object> goodsStatusPar = new HashMap<>();
goodsStatusPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response goodsStatusRes = network.getResponse(goodsStatusPar, BasicConfig.ANCHOR_secondKillLists);
try {
List<AnchorGetSKList> anchorGetSKLists = JsonUtil.parseResponseToListBean(goodsStatusRes, AnchorGetSKList.class);
int interactStatus = anchorGetSKLists.get(0).getInteractStatus();
Assert.assertEquals(interactStatus, 2, network.message(goodsStatusPar, BasicConfig.ANCHOR_secondKillLists, "秒杀轮次状态错误", goodsStatusRes.body().asString()));
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(goodsStatusPar, BasicConfig.ANCHOR_secondKillLists, "未获取到数据", goodsStatusRes.body().asString()));
}
}
// 切换访客
@Test(description = "查看当前秒杀商品", priority = 10)
public void 查看当前秒杀商品() {
visitorAuth();
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);
try {
String confId = goodsFirstRes.jsonPath().getString("data.confId");
Assert.assertEquals(confId, confId1, 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()));
}
}
/**
* 下单失败
*/
// 秒杀配置代理人不可参与
@Test(description = "代理人到场", priority = 10)
public void 代理人到场() {
// agentAuth();
Map<String, Object> connectSuccessPar = new HashMap<>();
connectSuccessPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response connectSuccessRes = network.getResponse(connectSuccessPar, BasicConfig.USER_connectSuccess);
try {
boolean data = connectSuccessRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(connectSuccessPar, BasicConfig.USER_connectSuccess, "代理人到场失败", connectSuccessRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(connectSuccessPar, BasicConfig.USER_connectSuccess, "数据获取失败", connectSuccessRes.body().asString()));
}
}
// @Test(description = "代理人下单", priority = 11)
// public void 代理人下单() {
//// agentAuth();
// ThreadSleepUtils.sleep(10000); // 进入直播间10s
// Map<String, Object> orderPar = new HashMap<>();
// orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
// orderPar.put("confId", confId1);
// 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 = "代理人获取下单结果", priority = 12)
public void 代理人获取下单结果() {
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", confId1);
Response orderResultRes = null;
Object data = null;
int i = 0;
try {
// 轮训下单接口
while (data == null){
ThreadSleepUtils.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");
if (state == 2){
int code = orderResultRes.jsonPath().getInt("data.code");
if (code == 4){
System.out.println("失败原因code="+code);
} else {
Assert.assertEquals(code, 1, network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是代理人限制", orderResultRes.body().asString()));
}
}else {
Assert.fail(network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "代理人未收到下单限制", orderResultRes.body().asString()));
}
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "获取数据失败", orderResultRes.body().asString()));
}
}
// 访客被黑名单限制
@Test(description = "黑名单客户", priority = 13)
public void 黑名单客户() {
}
}
......@@ -143,6 +143,12 @@ public class BasicConfig {
public static final String ANCHOR_secondKillLists = MOBILE_HOST + "/conf/live/second/kill/goods/list";
public static final String ANCHOR_secondKillUpdate = MOBILE_HOST + "/conf/live/second/kill/goods/update";
public static final String ANCHOR_skGoodsLists = MOBILE_HOST + "/conf/live/second/kill/goods/goodsList";
public static final String MOBILE_secondKill_getGoodsList = MOBILE_HOST + "/clue/goods/list";
public static final String MOBILE_secondKill_getGoodsDetail = MOBILE_HOST + "/clue/goods/detail";
public static final String ANCHOR_secondKillOn = MOBILE_HOST + "/conf/live/second/kill/goods/on";
public static final String MOBILE_secondKill_goodsFirst = MOBILE_HOST + "/clue/goods/first";
public static final String MOBILE_secondKill_goodsOrder = MOBILE_HOST + "/clue/goods/order";
public static final String MOBILE_secondKill_goodsOrderResult = MOBILE_HOST + "/clue/goods/order/result";
//客户承诺话术配置
public static final String MANAGER_saveDialogue = MANAGER_HOST + "/kjy/manager/live/potential/saveDialogue";
......
......@@ -72,11 +72,11 @@
<!-- </classes>-->
<!-- </test>-->
<test preserve-order="true" name="亲友券">
<classes>
<class name="com.kjj.cases.live.lottery.RelativeLottery"/>
</classes>
</test>
<!-- <test preserve-order="true" name="亲友券">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.lottery.RelativeLottery"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="false" name="翻牌集字红包">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.flipCard.FlipCard"/>-->
......@@ -122,11 +122,11 @@
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="直播中抽奖">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.lottery.Lottery"/>-->
<!-- </classes>-->
<!-- </test>-->
<test preserve-order="true" name="直播中抽奖">
<classes>
<class name="com.kjj.cases.live.lottery.Lottery"/>
</classes>
</test>
<test preserve-order="true" name="秒杀互动">
<classes>
<class name="com.kjj.cases.live.secondKill.SecondKill"/>
......
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