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

lv

parent 26409458
......@@ -13,6 +13,7 @@ import http.service.hd.DappConfigService;
import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
......@@ -20,13 +21,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
import utils.RedisUtil;
/**
* Created by yeqinqin on 2018/6/11.
*/
public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
public class 实物_兑换流程测试_ExchangeTest extends CheckTemplet {
@Autowired
private MobileService mobileService;
......@@ -80,6 +82,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
//实物兑换积分不足
@Test(description = "实物兑换积分不足")
public void 积分不足() throws Exception {
......@@ -179,42 +182,6 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
// @Test
public void 每日兑换限制() throws Exception {
int uid = 3490;
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//第二次兑换
try{
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
}catch (Exception e){
// message = e.toString();
}
// logger.info(message);
// Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 每日支出上限测试() throws Exception{
......@@ -315,6 +282,123 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
@Test
public void 用户每日限制消费测试() throws Exception {
String appItemId = "191772";
String itemId = "31049";
try{
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, itemId, "null", "yrJRr7Cddp2YeQd", "null");
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, itemId, "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("今日已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
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
public void 用户永久限制消费测试() throws Exception {
String appItemId = "191773";
String itemId = "32369";
try{
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, itemId, "null", "yrJRr7Cddp2YeQd", "null");
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, itemId, "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
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+"'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '"+itemId+"'");
}
}
......
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