Commit 4f54084d authored by 赵然's avatar 赵然

zr

parent f21d02b6
......@@ -438,6 +438,7 @@ public class ObjectExchange_ExchangeTest extends DuibaTestBase{
//直充类流量兑换
@Test(description = "直充类流量兑换")
public void 流量兑换() throws Exception {
int uid = 4376;
Thread.sleep(2000);
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
......@@ -446,7 +447,7 @@ public class ObjectExchange_ExchangeTest extends DuibaTestBase{
credits = String.valueOf(Integer.valueOf(credits) - 600);
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "3");
Map<String, String> map = authorization.dafuwengLogin(uid);
//Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//流量兑换
response = couponExchangeService.phoneflowExchange(authorization.dafuwengLogin(uid), "51200", "3","13193354550","中国联通","陕西");
......
......@@ -209,7 +209,7 @@ public class Qb_兑换流程测试_ExchangeTest extends DuibaTestBase {
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
//@Test
public void 审核通过测试() throws Exception {
//查询兑换前的开发者账户余额
......@@ -273,7 +273,7 @@ public class Qb_兑换流程测试_ExchangeTest extends DuibaTestBase {
logger.info("校验支付宝扣费订单成功");
}
@Test
//@Test
public void 审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
......
......@@ -279,7 +279,7 @@ public class 商品订单失败测试_ExchangeTest extends DuibaTestBase {
}
@Test
//@Test
public void 支付宝审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
......
package http.cases.ExchangeTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
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.Test;
import java.util.Map;
/**
* Created by lvwenyan on 2018/06/08.
*/
public class 开发者账户余额校验测试_ExchangeTest extends DuibaTestBase {
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private ManagerService managerService;
@Autowired
private MobileService mobileService;
@Autowired
private DsOrderService dsOrderService;
@Autowired
QbExchangeService qbExchangeService;
@Autowired
private AlipayExchangeService alipayExchangeService;
@Autowired
private Authorization authorization;
@Autowired
private DeveloperAccountService developerAccountService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3769;
@Test
public void 商品订单支付宝审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" 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.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
@Test
public void Qb审核通过测试() throws Exception {
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
response.prettyPrint();
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 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 orders_consumer.orders_0616 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 orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
// Assert.assertEquals(remainMoney,remainMoneyNew,"校验开发者账户余额失败");
//校验开发者账户余额变动
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) - 9600) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
@Test
public void Qb审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//qb兑换
int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 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 orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
// Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
//支付宝兑换接口抽离
public String 支付宝兑换订单(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
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