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

lv

parent 942e7cc8
......@@ -9,6 +9,10 @@ import http.service.app.CrecordService;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DappConfigService;
import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
......@@ -17,7 +21,7 @@ import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
import utils.RedisUtil;
/**
* Created by yeqinqin on 2018/6/11.
......@@ -38,12 +42,44 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
VirtualExchangeService virtualExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
DappConfigService dappConfigService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3770;
@BeforeClass
public void before(){
try{
//设置支出上限
dappConfigService.doSubmitBudget(authorization.hdLoginCommonNew("15822222222"),"22475","10","","1000");
dappConfigService.doSubmitBudget(authorization.hdLoginCommonNew("15811111111"),"22474","","10","1000");
}catch (Exception e){
System.out.println(e);
}
}
@AfterClass
public void after(){
try{
//清除支出上限
dappConfigService.doSubmitBudget(authorization.hdLoginCommonNew("15822222222"),"22475","","","1000");
dappConfigService.doSubmitBudget(authorization.hdLoginCommonNew("15811111111"),"22474","","","1000");
}catch (Exception e){
System.out.println(e);
}
}
//实物兑换积分不足
@Test(description = "实物兑换积分不足")
public void 积分不足() throws Exception {
......@@ -126,11 +162,9 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"31050");
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("~~~"+exchangeText);
Assert.assertTrue(exchangeText.contains("已兑完"));
String message=null;
String succcess = null;
Assert.assertTrue(exchangeText.contains("已兑完"),"校验商品兑换按钮失败");
String message = null;
try{
Response response = couponExchangeService.objectExchange1(authorization.dafuwengLogin(uid), "178880", "31050", "null", "yrJRr7Cddp2YeQd", "null");
......@@ -139,10 +173,12 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("没有兑换成功"));
Assert.assertTrue(message.contains("已兑完"),"校验message 失败");
logger.info("校验付费实物开发者余额不足成功");
}
// @Test
public void 每日兑换限制() throws Exception {
int uid = 3490;
......@@ -179,13 +215,16 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
//@Test
@Test
public void 每日支出上限测试() throws Exception{
int uid = 6550;
int uid = 6552;
String appItemId = "191771";
String itemId = "32368";
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "191769", "32368", "null", "1w8i52", "null");
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId,itemId, "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
......@@ -202,23 +241,79 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
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), "178879", "31049", "null", "z9sydmcs", "null");
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, itemId, "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
}catch (Exception e){
// message = e.toString();
message = e.toString();
}
// logger.info(message);
// Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
logger.info(message);
Assert.assertTrue(message.contains("已兑完"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今天已兑完","校验商品兑换按钮失败");
logger.info("校验付费实物每日支出上限成功");
}
@Test
public void 每月支出上限测试() throws Exception{
int uid = 6551;
String appItemId = "191769";
String itemId = "32368";
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId,itemId, "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--;
}
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("校验付费实物每月支出上限成功");
}
......
package http.service.hd;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/3/11
*/
@Service
public class DappConfigService {
private DuibaLog logger = DuibaLog.getLogger();
@Value("${hdserver.host}")
private String hdserverHost;
public Response doSubmitBudget(Map cookies, String appId, String dayBudget, String mongthBudget,String auditPricePerConsumer) throws Exception{
Map<String,String> map = new HashMap();
map.put("appId",appId);
map.put("dayBudget",dayBudget);
map.put("monthBudget",mongthBudget);
map.put("auditPricePerConsumer",auditPricePerConsumer);
Response response = given().cookies(cookies).params(map).post("http://"+hdserverHost+"/DappConfig/doSubmitBudget");
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("保存预算接口失败,返回信息:" + response.asString());
}catch(Error er){
throw new Exception("保存预算接口失败,返回信息:" + response.asString());
}
return response;
}
}
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