Commit 59b9071f authored by 龚小红's avatar 龚小红

fix---修复优惠券商品秒杀id错误

parent 8b83730b
......@@ -237,48 +237,26 @@ public class SecondKill implements Authorization {
@Test(description = "代理人下单", priority = 14)
public void 代理人下单() {
agentAuth();
sleep(5000);
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdFirst);
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()));
}
order(ConfSecondKill.skIdFirst,"","");
}
@Test(description = "代理人下单失败", priority = 15)
public void 代理人下单失败() {
int code = orderResult(ConfSecondKill.skIdFirst,3);
Assert.assertEquals(code, 1, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是代理人限制", null));
Assert.assertEquals(code, 1, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是代理人限制:code="+code, null));
}
// 访客被黑名单限制
@Test(description = "黑名单客户下单", priority = 16)
public void 黑名单客户下单() {
visitorAuth7();
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdFirst);
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()));
}
order(ConfSecondKill.skIdFirst,"","");
}
@Test(description = "黑名单客户下单失败", priority = 17)
public void 黑名单客户下单失败() {
int code = orderResult(ConfSecondKill.skIdFirst,3);
Assert.assertEquals(code, 3, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是黑名单客户", null));
Assert.assertEquals(code, 3, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是黑名单客户:code="+code, null));
}
/**
......@@ -300,17 +278,7 @@ public class SecondKill implements Authorization {
@Test(description = "正常用户下单", priority = 19)
public void 正常用户下单() {
visitorAuth1();
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdFirst);
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()));
}
order(ConfSecondKill.skIdFirst,"","");
}
@Test(description = "正常用户获取下单结果", priority = 20)
......@@ -320,17 +288,7 @@ public class SecondKill implements Authorization {
@Test(description = "正常用户下单0元秒杀商品", priority = 21)
public void 正常用户下单0元秒杀商品() {
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()));
}
order(ConfSecondKill.skIdThird,"","");
}
@Test(description = "正常用户获取0元商品下单结果", priority = 22)
......@@ -472,18 +430,7 @@ public class SecondKill implements Authorization {
public void 代理人成功下单() {
agentAuth2();
// 下单
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdSecond);
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()));
}
order( ConfSecondKill.skIdSecond,"","");
// 获取下单结果
orderResult(ConfSecondKill.skIdSecond,1);
}
......@@ -491,21 +438,12 @@ public class SecondKill implements Authorization {
@Test(description = "用户下单无库存秒杀失败", priority = 30)
public void 用户下单无库存秒杀() {
visitorAuth1();
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdSecond);
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()));
}
// 下单
order( ConfSecondKill.skIdSecond,"","");
// 获取下单结果
int code = orderResult(ConfSecondKill.skIdSecond,3);
Assert.assertEquals(code, 2, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是库存不足", null));
Assert.assertEquals(code, 2, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是库存不足:code="+code, null));
}
// 秒杀限制
......@@ -554,20 +492,10 @@ public class SecondKill implements Authorization {
ThreadSleepUtils.sleep(180000);
// 用户下单
visitorAuth1();
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdSecond);
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()));
}
order( ConfSecondKill.skIdSecond,"","");
int code = orderResult(ConfSecondKill.skIdSecond,3);
Assert.assertEquals(code, 3, network.message(orderPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是被限制", orderRes.body().asString()));
Assert.assertEquals(code, 3, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是被限制:code="+code, null));
}
......@@ -717,18 +645,8 @@ public class SecondKill implements Authorization {
public void 用户成功支付_待退款() {
visitorAuth31();
// 新建订单
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdFirst);
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()));
}
order( ConfSecondKill.skIdFirst,"","");
//获取下单结果
orderResult(ConfSecondKill.skIdFirst,1);
}
......@@ -793,7 +711,7 @@ public class SecondKill implements Authorization {
Assert.assertEquals(refundStatus,5, network.message(params, BasicConfig.MOBILE_getClueDetail, "客户线索详情秒杀退款状态错误", response.body().asString()));
}
@Test(description = "获取优惠券列表",priority = 52)
@Test(description = "获取优惠券列表",priority = 53)
public void 获取优惠券列表(){
visitorAuth11();
Map<String,Object> params = new HashMap<>();
......@@ -805,7 +723,7 @@ public class SecondKill implements Authorization {
int couponsReceiveStatus = response.jsonPath().getInt("data.get(0).couponsReceiveStatus");
Assert.assertEquals(couponsReceiveStatus,0, network.message(params,BasicConfig.MOBILE_couponsList,"优惠券领取状态记录错误",response.body().asString()));
}
@Test(description = "访客填写表单",priority = 52)
@Test(description = "访客填写表单",priority = 54)
public void 访客填写表单(){
//获取表单题目id
Map<String, Object> params = new HashMap<>();
......@@ -833,7 +751,7 @@ public class SecondKill implements Authorization {
System.out.println(data);
Assert.assertTrue(data,network.message(params,BasicConfig.MOBILE_FormSubmit,"访客K提交表单资料失败",response.body().asString()));
}
@Test(description = "领取秒杀优惠券",priority = 53)
@Test(description = "领取秒杀优惠券",priority = 55)
public void 领取秒杀优惠券(){
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -853,20 +771,28 @@ public class SecondKill implements Authorization {
Assert.assertEquals(couponsReceiveStatus,1, network.message(params,BasicConfig.MOBILE_couponsList,"优惠券领取状态记录错误",statusRes.body().asString()));
}
@Test(description = "上架秒杀优惠券商品",priority = 54)
@Test(description = "上架秒杀优惠券商品",priority = 56)
public void 上架秒杀优惠券商品(){
adminAuth();
killOn(ConfSecondKill.couponId);
}
@Test(description = "下单秒杀优惠券商品", priority = 55)
@Test(description = "下单秒杀优惠券商品", priority = 57)
public void 下单秒杀优惠券商品() {
visitorAuth11();
// 新建订单
order(ConfSecondKill.couponId,couponsId,"");
//获取下单结果
orderResult(ConfSecondKill.couponId,1);
}
public static void order(String goodId,String couponsID,String voucherID) {
sleep(5000);
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", resourceConfId);
orderPar.put("couponsId",couponsId);
orderPar.put("confId", goodId);
orderPar.put("couponsId",couponsID);
orderPar.put("voucherId",voucherID);
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -878,6 +804,7 @@ public class SecondKill implements Authorization {
}
public static int orderResult(String goodId,int status) {
//status:1-判定需要支付且下单成功,2-判定不许支付且下单成功,3-判定下单失败
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", goodId);
......
......@@ -19,7 +19,7 @@ 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.cases.live.secondKill.SecondKill.*;
import static com.kjj.config.BasicConfig.*;
import static com.kjj.config.BasicConfig.USER_clueInfoData;
import static com.kjj.utils.BaseUtils.connectSuccess;
......@@ -347,50 +347,15 @@ public class Voucher implements Authorization {
}
}
@Test(description = "客户A使用代金券下单价格大于代金券的商品", priority = 22)
@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()));
}
order(VoucherConf.skIdFirst,"",voucherId);
}
@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()));
}
orderResult(VoucherConf.skIdFirst,2);
}
@Test(description = "客户A用户代金券列表更新",priority = 24)
......@@ -441,50 +406,15 @@ public class Voucher implements Authorization {
Assert.assertTrue(data,network.message(params,BasicConfig.MOBILE_acceptGift, "代理人赠送代金券未开启", response.body().asString()));
}
@Test(description = "客户B使用代金券下单价格小于代金券的商品", priority = 28)
public void 客户B使用代金券下单价格小于代金券的商品() {
@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()));
}
order(VoucherConf.skIdSecond,"",voucherId);
}
@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()));
}
orderResult(VoucherConf.skIdSecond,1);
}
@Test(description = "管理后台查看用户代金券秒杀订单",priority = 30)
......
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