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

lv

parent cef646ff
......@@ -2,6 +2,7 @@ package http.cases.ExchangeTest;
import base.DuibaBase;
import base.DuibaBases;
import com.sun.jna.platform.win32.OaIdl;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.MobileService;
......@@ -10,6 +11,7 @@ import http.service.app.tawService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DappConfigService;
import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter;
import org.codehaus.jackson.annotate.JsonTypeInfo;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
......@@ -459,6 +461,48 @@ public class 兑吧卡密_兑换流程测试_ExchangeTest extends CheckTemplet {
}
@Test(description = "兑吧卡密跳转按钮")
public void 马上使用跳转() throws Exception{
String appItemId = "194957";
String itemId = "32603";
String skuId = "94";
Map cookies = authorization.dafuwengLogin(uid);
//优惠券兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
//优惠券订单结果页
Thread.sleep(3000);
Response detailResponse = tawService.detailItems(orderId,uid);
detailResponse.prettyPrint();
String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText");
String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
String credits = detailResponse.jsonPath().getString("data[0].credits");
Assert.assertEquals(useButtonText,"去使用","校验去使用按钮失败");
Assert.assertEquals(iosDownloadUrl,"http://www.iqiyi.com","校验按钮链接失败");
Assert.assertEquals(credits,"100","校验积分失败");
logger.info("校验兑吧卡密去使用跳转按钮成功");
}
}
......@@ -59,16 +59,25 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
Object[][] result = null;
if (method.getName().equals("日期兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "194281",78,"实物日期兑换限制未开始测试"}, //case1
new Object[]{2, "194282",79,"实物日期兑换限制进行中测试"}, //case2
new Object[]{3, "194283",80,"实物日期兑换限制已结束"}, //case3
new Object[]{1, "194281",78,"优惠券日期兑换限制未开始测试"}, //case1
new Object[]{2, "194282",79,"优惠券日期兑换限制进行中测试"}, //case2
new Object[]{3, "194283",80,"优惠券日期兑换限制已结束"}, //case3
};
}
if (method.getName().equals("库存不足测试")) {
result = new Object[][]{
new Object[]{"193847", "实物库存不足测试"}, //case1
new Object[]{"193847", "优惠券库存不足测试"}, //case1
};
}
if (method.getName().equals("优惠券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1,"194961",96, "普通券马上使用按钮测试"}, //case1
new Object[]{2,"194962", 97, "链接券马上使用按钮测试"}, //case2
new Object[]{3,"194963", 98, "重复券马上使用按钮测试"}, //case2
};
}
return result;
}
@Test
......@@ -210,7 +219,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(uid,orderId);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
......@@ -435,4 +444,73 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param skuId skuId
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券马上使用按钮测试(int caseNum, String appItemId, int skuId, String caseName)throws Exception{
int uid = 7028;
logger.info(caseName);
//优惠券兑换
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid),appItemId,skuId);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//优惠券订单结果页
Thread.sleep(3000);
Response detailResponse = tawService.detailItems(orderId,uid);
String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText");
String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
String credits = detailResponse.jsonPath().getString("data[0].credits");
logger.info("跳转链接:"+ iosDownloadUrl);
switch (caseNum){
case 1:
Assert.assertEquals(useButtonText,"去使用","校验按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://www.duiba.com.cn","校验按钮跳转链接失败");
Assert.assertEquals(credits,"100","校验积分失败");
logger.info("校验普通券码跳转按钮成功");
break;
case 2:
Assert.assertEquals(useButtonText,"去使用","校验按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://www.iqiyi.com","校验按钮跳转链接失败");
Assert.assertEquals(credits,"100","校验积分失败");
logger.info("校验链接券跳转按钮成功");
break;
case 3:
Assert.assertEquals(useButtonText,"去使用","校验按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://www.baidu.com","校验按钮跳转链接失败");
Assert.assertEquals(credits,"100","校验积分失败");
logger.info("校验重复券跳转按钮成功");
break;
}
}
}
......@@ -476,4 +476,9 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
}
}
......@@ -8,6 +8,8 @@ import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import http.service.hd.DappConfigService;
import http.service.hd.DeveloperAccountService;
import http.service.app.CrecordService;
import http.service.app.tawService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
......@@ -41,6 +43,10 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
DeveloperAccountService developerAccountService;
@Autowired
DappConfigService dappConfigService;
@Autowired
CrecordService crecordService;
@Autowired
tawService tawService;
private int uid = 7000;
private String consumerId = "100144141";
......@@ -78,6 +84,13 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
new Object[]{"193826", "实物库存不足测试"}, //case1
};
}
if (method.getName().equals("优惠券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1,"194958", "自有优惠券普通跳转链接测试"}, //case1
new Object[]{2,"194959", "自有优惠券链接券跳转测试"}, //case2
};
}
return result;
}
@Test
......@@ -443,4 +456,79 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券马上使用按钮测试(int caseNum, String appItemId, String caseName)throws Exception{
logger.info(caseName);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//优惠券兑换结果页
Response resultResponse = crecordService.recordDetail(orderId,uid);
// resultResponse.prettyPrint();
String btnText = MatcherString.getString(resultResponse.asString(),"\"btnText\":\"(.*?)\",",1);
String actualPay = MatcherString.getString(resultResponse.asString(),"\"actualPay\":\"(.*?)\",",1);
String androidDownloadUrl = MatcherString.getString(resultResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
logger.info("跳转链接:" + androidDownloadUrl);
//优惠券兑换记录页
Thread.sleep(3000);
Response detailResponse = tawService.detailItems(orderId,uid);
// detailResponse.prettyPrint();
String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText");
String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
switch (caseNum){
case 1:
Assert.assertEquals(btnText,"马上前往","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"1积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=http%3A%2F%2Fwww.baidu.com&dpm=2239.25.1.0&dcm=102.194958.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"http://www.iqiyi.com","校验兑换记录页按钮跳转链接失败");
logger.info("校验自有优惠券普通券码跳转按钮成功");
break;
case 2:
Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"1积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fhj.vc%2F2fzK&dpm=2239.25.1.0&dcm=102.194959.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://hj.vc/2fzK","校验兑换记录页按钮跳转链接失败");
logger.info("校验自有优惠券链接券跳转按钮功");
break;
}
}
}
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