Commit bfe69838 authored by 吕雯燕's avatar 吕雯燕

lv

parent e579132d
...@@ -263,7 +263,6 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -263,7 +263,6 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
map.put("itemId",itemId); map.put("itemId",itemId);
map.put("token",token); map.put("token",token);
//优惠券兑换 //优惠券兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange"); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint(); response.prettyPrint();
...@@ -400,8 +399,8 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -400,8 +399,8 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
//获取按钮状态 //获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29293"); Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29293");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("兑换按钮:"+ exchangeText);
Assert.assertEquals(response.jsonPath().getString("message"),"已达兑换次数上限","校验用户兑换限制失败"); Assert.assertEquals(response.jsonPath().getString("message"),"已达兑换次数上限","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验马上兑换按钮状态失败"); Assert.assertEquals(exchangeText,"已达兑换次数上限","校验马上兑换按钮状态失败");
...@@ -424,16 +423,18 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -424,16 +423,18 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
@Test @Test
public void 优惠券用户每日兑换限制测试() throws Exception{ public void 优惠券用户每日兑换限制测试() throws Exception{
String appItemId = "191781";
String itemId = "32377";
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("appItemId","171478"); map.put("appItemId",appItemId);
map.put("itemId","29531"); map.put("itemId",itemId);
map.put("token","yrJRr7Cddp2YeQd"); map.put("token","yrJRr7Cddp2YeQd");
try{ try{
//优惠券兑换,用户兑换限制次数1次 //优惠券兑换,用户兑换限制次数1次
Response response = this.优惠券兑换("171478","29531", uid); Response response = this.优惠券兑换(appItemId,itemId, uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败"); Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换 //再次兑换
Thread.sleep(3000); Thread.sleep(3000);
...@@ -441,13 +442,13 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -441,13 +442,13 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
response.prettyPrint(); response.prettyPrint();
//获取按钮状态 //获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29531"); Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("兑换按钮:"+ exchangeText);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已达兑换上限","校验用户兑换限制失败"); Assert.assertEquals(response.jsonPath().getString("message"),"今日已达兑换上限","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验马上兑换按钮状态失败"); Assert.assertEquals(exchangeText,"今日已达兑换上限","校验马上兑换按钮状态失败");
logger.info("校验优惠券用户每兑换限制成功"); logger.info("校验优惠券用户每兑换限制成功");
}catch (Exception e){ }catch (Exception e){
...@@ -455,12 +456,53 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -455,12 +456,53 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
}finally { }finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '29531'"); jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
} }
} }
@Test
public void 优惠券用户批次兑换限制测试() throws Exception{
String appItemId = "191782";
String itemId = "32378";
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token","yrJRr7Cddp2YeQd");
try{
//优惠券兑换,用户兑换限制次数1次
Response response = this.优惠券兑换(appItemId,itemId, uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("兑换按钮:"+ exchangeText);
Assert.assertEquals(response.jsonPath().getString("message"),"已达兑换次数上限","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验马上兑换按钮状态失败");
logger.info("校验优惠券用户批次兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
}
}
@Test @Test
public void 优惠券每日兑换上限测试() throws Exception{ public void 优惠券每日兑换上限测试() throws Exception{
...@@ -474,7 +516,6 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -474,7 +516,6 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
//优惠券兑换,用户兑换限制次数1次 //优惠券兑换,用户兑换限制次数1次
Response response= this.优惠券兑换("170295","29294", uid); Response response= this.优惠券兑换("170295","29294", uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败"); Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换 //再次兑换
Thread.sleep(3000); Thread.sleep(3000);
...@@ -483,8 +524,8 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -483,8 +524,8 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
//获取按钮状态 //获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29294"); Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29294");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("兑换按钮:" + exchangeText);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验每日兑换上限失败"); Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验每日兑换上限失败");
...@@ -719,6 +760,33 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -719,6 +760,33 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
} }
@Test
public void 会员等级测试()throws Exception{
String appItemId = "191778";
String itemId = "32374";
String message = "";
//会员等级无法兑换
try{
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, itemId, "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//会员等级可兑换,vip=5
Response response = couponExchangeService.objectExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,itemId,"null","yrJRr7Cddp2YeQd","null");
response.prettyPrint();
Assert.assertTrue(message.contains("会员等级不符,请挑选其他吧(15)"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验实物会员等级成功");
}
/** /**
* @param caseNum 用例编号 * @param caseNum 用例编号
......
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