Commit c4a65b3d authored by 赵然's avatar 赵然

zr

parent 4f54084d
......@@ -304,7 +304,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends DuibaTestBase {
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
//@Test(dataProvider = "providerMethod")
public void 优惠券审核通过测试(int caseNum, String appItemId, String itemId, String caseName) throws Exception{
logger.info(caseName);
......
......@@ -10,8 +10,10 @@ import http.service.hd.DsOrderService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
/**
......@@ -42,6 +44,17 @@ public class 开发者账户余额校验测试_ExchangeTest extends DuibaTestBas
//指定用户
private static int uid = 3769;
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("优惠券审核通过测试")) {
result = new Object[][]{
new Object[]{1,"169698", "29156", "兑吧优惠券审核通过测试"}, //case1
new Object[]{2,"172178", "", "自有优惠券审核通过测试"}, //case2
};
}
return result;
}
@Test
public void 商品订单支付宝审核不通过测试() throws Exception{
......@@ -231,6 +244,86 @@ public class 开发者账户余额校验测试_ExchangeTest extends DuibaTestBas
logger.info("校验支付宝审核订单失败返还金额成功");
}
/**
* @param caseNum 用例id
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券审核通过测试(int caseNum, String appItemId, String itemId, String caseName) throws Exception{
int uid = 3768;
logger.info(caseName);
//查询兑换前的开发者余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
//优惠券兑换
String orderId = this.优惠券兑换订单(appItemId,itemId,uid);
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
switch (caseNum){
case 1:
//查询兑换后的开发者余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者余额:" + remainMoney);
Assert.assertEquals(status,"success","订单状态校验失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验兑吧优惠券审核通过扣费成功");
break;
case 2:
Assert.assertEquals(status,"success","订单状态校验失败");
logger.info("校验自有优惠券审核通过成功");
}
}
//支付宝兑换接口抽离
public String 支付宝兑换订单(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
......@@ -251,4 +344,24 @@ public class 开发者账户余额校验测试_ExchangeTest extends DuibaTestBas
}
return orderId;
}
public String 优惠券兑换订单(String appItemId,String itemId,int uid) throws Exception {
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),appItemId,itemId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
}
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