Commit 8cccbce9 authored by xiamengchen's avatar xiamengchen

秒杀互动

parent 8a6b9b9c
...@@ -6,4 +6,5 @@ import lombok.Data; ...@@ -6,4 +6,5 @@ import lombok.Data;
public class AnchorGetSKList { public class AnchorGetSKList {
private int interactStatus; private int interactStatus;
private String id; 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; package com.kjj.cases.live.secondKill;
import com.kjj.bean.secondKill.AnchorGetSKList; import com.kjj.bean.secondKill.AnchorGetSKList;
import com.kjj.bean.secondKill.KillGoods;
import com.kjj.bean.secondKill.SecondKillList; import com.kjj.bean.secondKill.SecondKillList;
import com.kjj.cases.admin.Authorization; import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig; import com.kjj.config.BasicConfig;
...@@ -205,7 +206,7 @@ public class SecondKill implements Authorization { ...@@ -205,7 +206,7 @@ public class SecondKill implements Authorization {
* 下单失败 * 下单失败
*/ */
// 秒杀配置代理人不可参与 // 秒杀配置代理人不可参与
@Test(description = "代理人下单", priority = 11) @Test(description = "代理人下单", priority = 12)
public void 代理人下单() { public void 代理人下单() {
agentAuth(); agentAuth();
Map<String, Object> orderPar = new HashMap<>(); Map<String, Object> orderPar = new HashMap<>();
...@@ -221,7 +222,7 @@ public class SecondKill implements Authorization { ...@@ -221,7 +222,7 @@ public class SecondKill implements Authorization {
} }
} }
@Test(description = "代理人获取下单结果", priority = 12) @Test(description = "代理人获取下单结果", priority = 13)
public void 代理人获取下单结果() { public void 代理人获取下单结果() {
Map<String, Object> orderResultPar = new HashMap<>(); Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey())); orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
...@@ -258,8 +259,235 @@ public class SecondKill implements Authorization { ...@@ -258,8 +259,235 @@ public class SecondKill implements Authorization {
} }
// 访客被黑名单限制 // 访客被黑名单限制
@Test(description = "黑名单客户", priority = 13) @Test(description = "黑名单客户下单", priority = 14)
public void 黑名单客户() { 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 { ...@@ -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_goodsFirst = MOBILE_HOST + "/clue/goods/first";
public static final String MOBILE_secondKill_goodsOrder = MOBILE_HOST + "/clue/goods/order"; 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_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"; public static final String MANAGER_saveDialogue = MANAGER_HOST + "/kjy/manager/live/potential/saveDialogue";
......
...@@ -133,117 +133,117 @@ ...@@ -133,117 +133,117 @@
</classes> </classes>
</test> </test>
<!-- <test preserve-order="true" name="猜数字红包">--> <test preserve-order="true" name="猜数字红包">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.guess.LiveGuess"/>--> <class name="com.kjj.cases.live.guess.LiveGuess"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="看直播攒现金">--> <test preserve-order="true" name="看直播攒现金">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.treasure.TimeRed"/>--> <class name="com.kjj.cases.live.treasure.TimeRed"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="免费领福利">--> <test preserve-order="true" name="免费领福利">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.FreeReward.FreeReward"/>--> <class name="com.kjj.cases.live.FreeReward.FreeReward"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="我要咨询">--> <test preserve-order="true" name="我要咨询">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.agent.Potential"/>--> <class name="com.kjj.cases.live.agent.Potential"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="访客领取资料">--> <test preserve-order="true" name="访客领取资料">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.anchor.LiveVisitors"/>--> <class name="com.kjj.cases.live.anchor.LiveVisitors"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="红包领取">--> <test preserve-order="true" name="红包领取">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.red.LiveVistorRed"/>--> <class name="com.kjj.cases.live.red.LiveVistorRed"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="有奖答题">--> <test preserve-order="true" name="有奖答题">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.answer.Answer"/>--> <class name="com.kjj.cases.live.answer.Answer"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="投票">--> <test preserve-order="true" name="投票">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.choice.Choice"/>--> <class name="com.kjj.cases.live.choice.Choice"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="问题">--> <test preserve-order="true" name="问题">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.question.Question"/>--> <class name="com.kjj.cases.live.question.Question"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="直播中时长宝箱">--> <test preserve-order="true" name="直播中时长宝箱">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.treasure.TreasureTime"/>--> <class name="com.kjj.cases.live.treasure.TreasureTime"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="闯关答题">--> <test preserve-order="true" name="闯关答题">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.answer.passQues"/>--> <class name="com.kjj.cases.live.answer.passQues"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="直播中获取线索统计">--> <test preserve-order="true" name="直播中获取线索统计">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.agent.LiveAgent"/>--> <class name="com.kjj.cases.live.agent.LiveAgent"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="助播-结束直播">--> <test preserve-order="true" name="助播-结束直播">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.anchor.CloseLive"/>--> <class name="com.kjj.cases.live.anchor.CloseLive"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="直播结束-我的客户页">--> <test preserve-order="true" name="直播结束-我的客户页">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.agent.LiveLater"/>--> <class name="com.kjj.cases.live.agent.LiveLater"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="奖品发放配置">--> <test preserve-order="true" name="奖品发放配置">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.agent.Reward"/>--> <class name="com.kjj.cases.live.agent.Reward"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="指定中奖付款码">--> <test preserve-order="true" name="指定中奖付款码">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.liveConfig.spec"/>--> <class name="com.kjj.cases.live.liveConfig.spec"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="客户管理">--> <test preserve-order="true" name="客户管理">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.agent.Customer"/>--> <class name="com.kjj.cases.live.agent.Customer"/>
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="访客端直播结束页">--> <test preserve-order="true" name="访客端直播结束页">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.customer.AfterLive" />--> <class name="com.kjj.cases.live.customer.AfterLive" />
<!-- </classes>--> </classes>
<!-- </test>--> </test>
<!-- <test preserve-order="true" name="访客端个人主页">--> <test preserve-order="true" name="访客端个人主页">
<!-- <classes>--> <classes>
<!-- <class name="com.kjj.cases.live.customer.PersonalPage" />--> <class name="com.kjj.cases.live.customer.PersonalPage" />
<!-- </classes>--> </classes>
<!-- </test>--> </test>
</suite> </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