Commit 1daba77f authored by xiamengchen's avatar xiamengchen

Merge branch 'master' into feature/20210922-xmc

parents 9ac77614 0e76e9a5
......@@ -29,6 +29,7 @@ public class ConfSecondKill implements Authorization {
public static final String secKillGoodsIdEncode = IdMakeUtil.managerEncodingId(secKillGoodsId);
public static String skIdFirst; // 第一轮秒杀id
public static String skIdSecond; // 第二轮秒杀ID
public static String skIdThird; //0元商品秒杀ID
public static int killListSize;
@BeforeClass
......@@ -164,7 +165,7 @@ public class ConfSecondKill implements Authorization {
/**
* 助播端编辑秒杀轮次
*/
@Test(description = "助播端获取公司秒杀商品列表", priority = 6)
@Test(description = "助播端获取公司秒杀商品列表", priority = 7)
public void 助播端获取公司秒杀商品列表() {
Map<String, Object> skGoodsListPar = new HashMap<>();
skGoodsListPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -180,7 +181,7 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "助播端新增秒杀轮次", priority = 7)
@Test(description = "助播端新增秒杀轮次", priority = 8)
public void 助播端新增秒杀轮次() {
Map<String, Object> secKillAddPar = new HashMap<>();
secKillAddPar.put("goodsId", secKillGoodsIdEncode);
......@@ -198,7 +199,7 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "新增第二轮秒杀", priority = 8)
@Test(description = "新增第二轮秒杀", priority = 9)
public void 新增第二轮秒杀() {
Map<String, Object> secKillAddPar = new HashMap<>();
secKillAddPar.put("goodsId", secKillGoodsIdEncode);
......@@ -216,7 +217,25 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "助播端获取秒杀轮次列表", priority = 9)
@Test(description = "助播端新增0元秒杀商品",priority = 10)
public void 助播端新增0元秒杀商品(){
Map<String, Object> secKillAddPar = new HashMap<>();
secKillAddPar.put("goodsId", secKillGoodsIdEncode);
secKillAddPar.put("goodsAmount", 0); // 1 == 0.01
secKillAddPar.put("interactNum", 1);
secKillAddPar.put("ableAgent", 1); // 代理人可参与
secKillAddPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response secKillAddRes = network.postResponse(secKillAddPar, BasicConfig.ANCHOR_secondKillSave);
try {
boolean data = secKillAddRes.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(secKillAddPar, BasicConfig.ANCHOR_secondKillSave, "新增轮次失败", secKillAddRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(secKillAddPar, BasicConfig.ANCHOR_secondKillSave, "未获取到数据", secKillAddRes.body().asString()));
}
}
@Test(description = "助播端获取秒杀轮次列表", priority = 11)
public void 助播端获取秒杀轮次列表() {
Map<String, Object> liveSecKillPar = new HashMap<>();
liveSecKillPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -230,6 +249,7 @@ public class ConfSecondKill implements Authorization {
Assert.assertEquals(goodsId, secKillGoodsIdEncode, network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "轮次对应商品ID错误", liveSecKillRes.body().asString()));
skIdFirst = secKillLists.get(0).getId();
skIdSecond = secKillLists.get(1).getId();
skIdThird = secKillLists.get(2).getId();
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(liveSecKillPar, BasicConfig.ANCHOR_secondKillLists, "未获取到数据", liveSecKillRes.body().asString()));
......@@ -237,7 +257,7 @@ public class ConfSecondKill implements Authorization {
}
@Test(description = "助播端编辑秒杀轮次", priority = 10)
@Test(description = "助播端编辑秒杀轮次", priority = 12)
public void 助播端编辑秒杀轮次() {
Map<String, Object> secKillUpdatePar = new HashMap<>();
secKillUpdatePar.put("goodsId", secKillGoodsIdEncode);
......@@ -256,7 +276,7 @@ public class ConfSecondKill implements Authorization {
}
//****************************秒杀预告***************************************
@Test(description = "上传预告底图", priority = 11)
@Test(description = "上传预告底图", priority = 13)
public void 上传预告底图() {
BaseUtils.ssoLogin();
Map<String, Object> liveSecKillPar = new HashMap<>();
......@@ -273,7 +293,7 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "开启秒杀预告配置", priority = 12)
@Test(description = "开启秒杀预告配置", priority = 14)
public void 开启秒杀预告配置() {
Map<String, Object> liveSecKillPar = new HashMap<>();
liveSecKillPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
......@@ -289,7 +309,7 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "获取秒杀预告配置详情", priority = 13)
@Test(description = "获取秒杀预告配置详情", priority = 15)
public void 获取秒杀预告配置详情() {
Map<String, Object> liveSecKillPar = new HashMap<>();
liveSecKillPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
......@@ -307,7 +327,7 @@ public class ConfSecondKill implements Authorization {
}
//************************访客端********************************
@Test(description = "查询秒杀预告开启状态", priority = 14)
@Test(description = "查询秒杀预告开启状态", priority = 16)
public void 查询秒杀预告开启状态() {
visitorAuth9();
Map<String, Object> getLiveAwardListParam = new HashMap<>();
......@@ -325,7 +345,7 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "获取秒杀预告配置图片", priority = 15)
@Test(description = "获取秒杀预告配置图片", priority = 17)
public void 获取秒杀预告配置图片() {
visitorAuth9();
Map<String, Object> getLiveAwardListParam = new HashMap<>();
......@@ -343,7 +363,7 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "获取秒杀预告商品列表", priority = 16)
@Test(description = "获取秒杀预告商品列表", priority = 18)
public void 获取秒杀预告商品列表() {
visitorAuth9();
Map<String, Object> getLiveAwardListParam = new HashMap<>();
......@@ -361,7 +381,7 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "订阅秒杀开抢提醒", priority = 17)
@Test(description = "订阅秒杀开抢提醒", priority = 19)
public void 订阅秒杀开抢提醒() {
visitorAuth9();
Map<String, Object> getLiveAwardListParam = new HashMap<>();
......@@ -378,7 +398,7 @@ public class ConfSecondKill implements Authorization {
}
}
@Test(description = "查询秒杀订阅状态", priority = 18)
@Test(description = "查询秒杀订阅状态", priority = 20)
public void 查询秒杀订阅状态() {
visitorAuth9();
Map<String, Object> getLiveAwardListParam = new HashMap<>();
......
......@@ -167,14 +167,28 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "无法同时上架多轮秒杀", priority = 10)
public void 无法同时上架多轮秒杀() {
// @Test(description = "无法同时上架多轮秒杀", priority = 10)
// public void 无法同时上架多轮秒杀() {
// Map<String, Object> goodsOnPar = new HashMap<>();
// goodsOnPar.put("id", ConfSecondKill.skIdSecond);
// 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()));
// }
// }
@Test(description = "同时上架0秒杀商品", priority = 10)
public void 同时上架0秒杀商品() {
adminAuth();
Map<String, Object> goodsOnPar = new HashMap<>();
goodsOnPar.put("id", ConfSecondKill.skIdSecond);
goodsOnPar.put("id", ConfSecondKill.skIdThird);
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()));
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()));
......@@ -191,7 +205,7 @@ public class SecondKill implements Authorization {
System.out.println(goodsFirstRes.body().asString());
try {
String confId = goodsFirstRes.jsonPath().getString("data.confId");
Assert.assertEquals(confId, ConfSecondKill.skIdSecond, network.message(goodsFirstPar, BasicConfig.MOBILE_secondKill_goodsFirst, "当前秒杀商品配置ID错误", goodsFirstRes.body().asString()));
Assert.assertEquals(confId, ConfSecondKill.skIdThird, 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()));
......@@ -205,7 +219,8 @@ public class SecondKill implements Authorization {
Response downgradeGoodsRes = network.getResponse(downgradeGoodsPar, BasicConfig.MOBILE_secondKill_downgradeGoodsFirst);
try {
String confId = downgradeGoodsRes.jsonPath().getString("data.confId");
Assert.assertEquals(confId, ConfSecondKill.skIdSecond, network.message(downgradeGoodsPar, BasicConfig.MOBILE_secondKill_goodsFirst, "当前秒杀商品配置ID错误", downgradeGoodsRes.body().asString()));
//校验最新上架的商品
Assert.assertEquals(confId, ConfSecondKill.skIdThird, network.message(downgradeGoodsPar, BasicConfig.MOBILE_secondKill_goodsFirst, "当前秒杀商品配置ID错误", downgradeGoodsRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(downgradeGoodsPar, BasicConfig.MOBILE_secondKill_goodsFirst, "未获取到数据", downgradeGoodsRes.body().asString()));
......@@ -368,7 +383,51 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "查询待支付状态", priority = 21)
@Test(description = "正常用户下单0元秒杀商品", priority = 21)
public void 正常用户下单0元秒杀商品() {
visitorAuth();
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdThird);
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, "下单0元商品失败", orderRes.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
Assert.fail(network.message(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder, "未获取到数据", orderRes.body().asString()));
}
}
@Test(description = "正常用户获取0元商品下单结果", priority = 22)
public void 正常用户获取0元商品下单结果() {
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", ConfSecondKill.skIdThird);
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, 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 = "查询待支付状态", priority = 23)
public void 查询待支付状态() {
Map<String, Object> killGoodsPar = new HashMap<>();
killGoodsPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -391,7 +450,7 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "占用库存", priority = 22)
@Test(description = "占用库存", priority = 24)
public void 占用库存() {
// 切换助播端视角获取当前轮次剩余数量
adminAuth();
......@@ -417,7 +476,7 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "超时未支付", priority = 23)
@Test(description = "超时未支付", priority = 25)
public void 超时未支付() {
// 助播端视角查看库存是否释放
Map<String, Object> liveSecKillPar = new HashMap<>();
......@@ -463,7 +522,7 @@ public class SecondKill implements Authorization {
* 放开代理人秒杀限制
* 助播端需先下架秒杀才能进行编辑
*/
@Test(description = "助播端下架秒杀", priority = 24)
@Test(description = "助播端下架秒杀", priority = 26)
public void 助播端下架秒杀() {
adminAuth();
Map<String, Object> skOffPar = new HashMap<>();
......@@ -478,7 +537,7 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "上架第二轮秒杀,代理人可参与", priority = 25)
@Test(description = "上架第二轮秒杀,代理人可参与", priority = 27)
public void 上架第二轮秒杀() {
Map<String, Object> skOnPar = new HashMap<>();
skOnPar.put("id", ConfSecondKill.skIdSecond);
......@@ -492,7 +551,7 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "代理人成功下单-占用库存", priority = 26)
@Test(description = "代理人成功下单-占用库存", priority = 28)
public void 代理人成功下单() {
agentAuth();
// 下单
......@@ -535,7 +594,7 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "用户下单无库存秒杀失败", priority = 27)
@Test(description = "用户下单无库存秒杀失败", priority = 29)
public void 用户下单无库存秒杀() {
visitorAuth();
Map<String, Object> orderPar = new HashMap<>();
......@@ -585,7 +644,7 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "删除已上架过的轮次", priority = 28)
@Test(description = "删除已上架过的轮次", priority = 30)
public void 已上架过的轮次无法删除() {
long id = IdMakeUtil.managerDecodeingId(ConfSecondKill.skIdFirst);
Map<String, Object> delSkPar = new HashMap<>();
......@@ -604,7 +663,7 @@ public class SecondKill implements Authorization {
}
}
@Test(description = "用户成功支付", priority = 29)
@Test(description = "用户成功支付", priority = 31)
public void 用户成功支付() {
visitorAuth();
// 新建订单
......
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