Commit 57100bf6 authored by 龚小红's avatar 龚小红

fix

parent 8c4fe00d
......@@ -242,7 +242,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdFirst);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -255,38 +254,8 @@ public class SecondKill implements Authorization {
@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", ConfSecondKill.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");
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()));
}
int code = orderResult(ConfSecondKill.skIdFirst,3);
Assert.assertEquals(code, 1, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是代理人限制", null));
}
// 访客被黑名单限制
......@@ -296,7 +265,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdFirst);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -309,38 +277,8 @@ public class SecondKill implements Authorization {
@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", ConfSecondKill.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");
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()));
}
int code = orderResult(ConfSecondKill.skIdFirst,3);
Assert.assertEquals(code, 3, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是黑名单客户", null));
}
/**
......@@ -365,7 +303,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdFirst);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -378,30 +315,7 @@ public class SecondKill implements Authorization {
@Test(description = "正常用户获取下单结果", priority = 20)
public void 正常用户获取下单结果() {
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", ConfSecondKill.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, 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(ConfSecondKill.skIdFirst,1);
}
@Test(description = "正常用户下单0元秒杀商品", priority = 21)
......@@ -409,7 +323,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdThird);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -422,31 +335,7 @@ public class SecondKill implements Authorization {
@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){
sleep(2000);
orderResultRes = network.getResponse(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult);
System.out.println(orderResultRes.body().asString());
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(ConfSecondKill.skIdThird,2);
}
@Test(description = "查询待支付状态", priority = 23)
......@@ -586,7 +475,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdSecond);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -597,30 +485,7 @@ public class SecondKill implements Authorization {
}
// 获取下单结果
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", ConfSecondKill.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(ConfSecondKill.skIdSecond,1);
}
@Test(description = "用户下单无库存秒杀失败", priority = 30)
......@@ -629,7 +494,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdSecond);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -640,38 +504,8 @@ public class SecondKill implements Authorization {
}
// 获取下单结果
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", ConfSecondKill.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");
if (state == 2){
int code = orderResultRes.jsonPath().getInt("data.code");
if (code == 4){
System.out.println("失败原因code="+code);
} else {
Assert.assertEquals(code, 2, 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()));
}
int code = orderResult(ConfSecondKill.skIdSecond,3);
Assert.assertEquals(code, 2, network.message(null, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是库存不足", null));
}
// 秒杀限制
......@@ -723,7 +557,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdSecond);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -733,39 +566,8 @@ public class SecondKill implements Authorization {
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", ConfSecondKill.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");
System.out.println("data: "+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()));
}
int code = orderResult(ConfSecondKill.skIdSecond,3);
Assert.assertEquals(code, 3, network.message(orderPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "失败原因不是被限制", orderRes.body().asString()));
}
......@@ -887,7 +689,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.QualifiedId);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -897,30 +698,7 @@ public class SecondKill implements Authorization {
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", ConfSecondKill.QualifiedId);
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(ConfSecondKill.QualifiedId,1);
}
@Test(description = "管理后台查看秒杀资格商品进度",priority = 46)
......@@ -942,7 +720,6 @@ public class SecondKill implements Authorization {
Map<String, Object> orderPar = new HashMap<>();
orderPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderPar.put("confId", ConfSecondKill.skIdFirst);
orderPar.put("couponsId","");
Response orderRes = network.postResponse(orderPar, BasicConfig.MOBILE_secondKill_goodsOrder);
try {
boolean data = orderRes.jsonPath().getBoolean("data");
......@@ -952,29 +729,7 @@ public class SecondKill implements Authorization {
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", ConfSecondKill.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, 3, 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()));
}
orderResult(ConfSecondKill.skIdFirst,1);
}
@Test(description = "管理后台查看用户秒杀订单",priority = 48)
......@@ -1122,6 +877,44 @@ public class SecondKill implements Authorization {
}
}
public static int orderResult(String goodId,int status) {
Map<String, Object> orderResultPar = new HashMap<>();
orderResultPar.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
orderResultPar.put("confId", goodId);
Response orderResultRes = null;
Object data = null;
int i = 0;
int state = 1;
try {
// 轮训下单接口
while (data == null || state == 1) {
sleep(2000);
orderResultRes = network.getResponse(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult);
data = orderResultRes.jsonPath().getJsonObject("data");
if (data != null) {
state = orderResultRes.jsonPath().getInt("data.state");
}
i++;
if (i == 10) {
Assert.fail(network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "轮训下单结果超过10次", orderResultRes.body().asString()));
}
}
if (status == 1) {
Assert.assertEquals(state, 3, network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "下单未成功", orderResultRes.body().asString()));
} else if (status == 2) {
Assert.assertEquals(state, 4, network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "下单未成功", orderResultRes.body().asString()));
} else{
Assert.assertEquals(state, 2, network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "用户下单未收到限制组限制", orderResultRes.body().asString()));
int code = orderResultRes.jsonPath().getInt("data.code");
return code;
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail(network.message(orderResultPar, BasicConfig.MOBILE_secondKill_goodsOrderResult, "获取数据失败", orderResultRes.body().asString()));
return -1;
}
return -1;
}
}
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