Commit 8cccbce9 authored by xiamengchen's avatar xiamengchen

秒杀互动

parent 8a6b9b9c
......@@ -6,4 +6,5 @@ import lombok.Data;
public class AnchorGetSKList {
private int interactStatus;
private String id;
private int surplusNum;
}
package com.kjj.bean.secondKill;
import lombok.Data;
@Data
public class KillGoods {
private String confId;
private int chargeStatus;
}
package com.kjj.cases.live.secondKill;
import com.kjj.bean.secondKill.AnchorGetSKList;
import com.kjj.bean.secondKill.KillGoods;
import com.kjj.bean.secondKill.SecondKillList;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
......@@ -205,7 +206,7 @@ public class SecondKill implements Authorization {
* 下单失败
*/
// 秒杀配置代理人不可参与
@Test(description = "代理人下单", priority = 11)
@Test(description = "代理人下单", priority = 12)
public void 代理人下单() {
agentAuth();
Map<String, Object> orderPar = new HashMap<>();
......@@ -221,7 +222,7 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "代理人获取下单结果", priority = 12)
@Test(description = "代理人获取下单结果", priority = 13)
public void 代理人获取下单结果() {
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -258,8 +259,235 @@ public class SecondKill implements Authorization {
}
// 访客被黑名单限制
@Test(description = "黑名单客户", priority = 13)
public void 黑名单客户() {
@Test(description = "黑名单客户下单", priority = 14)
public void 黑名单客户下单() {
visitorAuth7();
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 = 15)
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, 3, 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 = 16)
public void 正常用户下单() {
visitorAuth();
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 = 17)
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");
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 = 18)
public void 查询待支付状态() {
Map<String, Object> killGoodsPar = new HashMap<>();
killGoodsPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response killGoodsRes = network.getResponse(killGoodsPar, BasicConfig.MOBILE_secondKill_killGoods);
try {
List<KillGoods> killGoods = JsonUtil.parseResponseToListBean(killGoodsRes, KillGoods.class);
boolean hasTarget = false;
for (KillGoods killGood : killGoods){
if(killGood.getConfId().equals(confId1)){
hasTarget = true;
Assert.assertEquals(killGood.getChargeStatus(), 1, network.message(killGoodsPar, BasicConfig.MOBILE_secondKill_killGoods, "对应轮次支付状态不为待支付", killGoodsRes.body().asString()));
}
}
if (!hasTarget){
Assert.fail(network.message(killGoodsPar, BasicConfig.MOBILE_secondKill_killGoods, "用户秒杀商品列表中没有对应轮次", killGoodsRes.body().asString()));
}
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(killGoodsPar, BasicConfig.MOBILE_secondKill_killGoods, "获取数据失败", killGoodsRes.body().asString()));
}
}
@Test(description = "占用库存", priority = 19)
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);
try {
List<AnchorGetSKList> secKillLists = JsonUtil.parseResponseToListBean(liveSecKillRes, AnchorGetSKList.class);
boolean hasTarget = false;
for (AnchorGetSKList secKillList : secKillLists){
if (secKillList.getId().equals(confId1)){
hasTarget = true;
int surplusNum = secKillList.getSurplusNum();
Assert.assertEquals(surplusNum, 3, network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "对应轮次剩余数量有误", liveSecKillRes.body().asString()));
}
}
if (!hasTarget){
Assert.fail(network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "未获取到对应轮次信息", liveSecKillRes.body().asString()));
}
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "获取数据失败", liveSecKillRes.body().asString()));
}
}
@Test(description = "超时未支付", priority = 20)
public void 超时未支付() {
ThreadSleepUtils.sleep(150000); // 两分钟无操作
// 助播端视角查看库存是否释放
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);
try {
List<AnchorGetSKList> secKillLists = JsonUtil.parseResponseToListBean(liveSecKillRes, AnchorGetSKList.class);
boolean hasTarget = false;
for (AnchorGetSKList secKillList : secKillLists){
if (secKillList.getId().equals(confId1)){
hasTarget = true;
int surplusNum = secKillList.getSurplusNum();
Assert.assertEquals(surplusNum, 4, network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "对应轮次剩余数量有误", liveSecKillRes.body().asString()));
}
}
if (!hasTarget){
Assert.fail(network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "未获取到对应轮次信息", liveSecKillRes.body().asString()));
}
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "获取数据失败", liveSecKillRes.body().asString()));
}
// 访客视角查看轮次状态
visitorAuth();
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 {
int chargeStatus = goodsDetailRes.jsonPath().getInt("data.chargeStatus");
int interactStatus = goodsDetailRes.jsonPath().getInt("data.interactStatus");
Assert.assertEquals(interactStatus, 2, network.message(goodsDetailPar, BasicConfig.MOBILE_secondKill_getGoodsDetail, "轮次商品状态错误", goodsDetailRes.body().asString()));
Assert.assertEquals(chargeStatus, 5, 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 = 21)
public void 用户成功支付() {
// 新建订单
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()));
}
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");
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()));
}
}
}
......@@ -149,6 +149,7 @@ public class BasicConfig {
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 MOBILE_secondKill_killGoods = MOBILE_HOST + "/clue/goods/killGoods";
//客户承诺话术配置
public static final String MANAGER_saveDialogue = MANAGER_HOST + "/kjy/manager/live/potential/saveDialogue";
......
......@@ -133,117 +133,117 @@
</classes>
</test>
<!-- <test preserve-order="true" name="猜数字红包">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.guess.LiveGuess"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="看直播攒现金">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.treasure.TimeRed"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="免费领福利">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.FreeReward.FreeReward"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="我要咨询">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.agent.Potential"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="访客领取资料">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.anchor.LiveVisitors"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="红包领取">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.red.LiveVistorRed"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="有奖答题">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.answer.Answer"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="投票">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.choice.Choice"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="问题">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.question.Question"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="直播中时长宝箱">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.treasure.TreasureTime"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="闯关答题">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.answer.passQues"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="直播中获取线索统计">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.agent.LiveAgent"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="助播-结束直播">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.anchor.CloseLive"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="直播结束-我的客户页">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.agent.LiveLater"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="奖品发放配置">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.agent.Reward"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="指定中奖付款码">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.liveConfig.spec"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="客户管理">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.agent.Customer"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="访客端直播结束页">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.customer.AfterLive" />-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="访客端个人主页">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.customer.PersonalPage" />-->
<!-- </classes>-->
<!-- </test>-->
<test preserve-order="true" name="猜数字红包">
<classes>
<class name="com.kjj.cases.live.guess.LiveGuess"/>
</classes>
</test>
<test preserve-order="true" name="看直播攒现金">
<classes>
<class name="com.kjj.cases.live.treasure.TimeRed"/>
</classes>
</test>
<test preserve-order="true" name="免费领福利">
<classes>
<class name="com.kjj.cases.live.FreeReward.FreeReward"/>
</classes>
</test>
<test preserve-order="true" name="我要咨询">
<classes>
<class name="com.kjj.cases.live.agent.Potential"/>
</classes>
</test>
<test preserve-order="true" name="访客领取资料">
<classes>
<class name="com.kjj.cases.live.anchor.LiveVisitors"/>
</classes>
</test>
<test preserve-order="true" name="红包领取">
<classes>
<class name="com.kjj.cases.live.red.LiveVistorRed"/>
</classes>
</test>
<test preserve-order="true" name="有奖答题">
<classes>
<class name="com.kjj.cases.live.answer.Answer"/>
</classes>
</test>
<test preserve-order="true" name="投票">
<classes>
<class name="com.kjj.cases.live.choice.Choice"/>
</classes>
</test>
<test preserve-order="true" name="问题">
<classes>
<class name="com.kjj.cases.live.question.Question"/>
</classes>
</test>
<test preserve-order="true" name="直播中时长宝箱">
<classes>
<class name="com.kjj.cases.live.treasure.TreasureTime"/>
</classes>
</test>
<test preserve-order="true" name="闯关答题">
<classes>
<class name="com.kjj.cases.live.answer.passQues"/>
</classes>
</test>
<test preserve-order="true" name="直播中获取线索统计">
<classes>
<class name="com.kjj.cases.live.agent.LiveAgent"/>
</classes>
</test>
<test preserve-order="true" name="助播-结束直播">
<classes>
<class name="com.kjj.cases.live.anchor.CloseLive"/>
</classes>
</test>
<test preserve-order="true" name="直播结束-我的客户页">
<classes>
<class name="com.kjj.cases.live.agent.LiveLater"/>
</classes>
</test>
<test preserve-order="true" name="奖品发放配置">
<classes>
<class name="com.kjj.cases.live.agent.Reward"/>
</classes>
</test>
<test preserve-order="true" name="指定中奖付款码">
<classes>
<class name="com.kjj.cases.live.liveConfig.spec"/>
</classes>
</test>
<test preserve-order="true" name="客户管理">
<classes>
<class name="com.kjj.cases.live.agent.Customer"/>
</classes>
</test>
<test preserve-order="true" name="访客端直播结束页">
<classes>
<class name="com.kjj.cases.live.customer.AfterLive" />
</classes>
</test>
<test preserve-order="true" name="访客端个人主页">
<classes>
<class name="com.kjj.cases.live.customer.PersonalPage" />
</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