Commit 52c8c1b6 authored by 赵然's avatar 赵然

zr

parent 1426ee1a
package http.cases.WalletTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.SeedRedPacketService;
import http.service.Activity.WalletAccountService;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.HbaseService;
import utils.PublicMethod;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by mabo on 2018/8/15
*/
public class 账户异常提现 extends DuibaTestBase{
@Value("${activity.host}")
String activityHost;
@Autowired
SeedRedPacketService seedRedPacketService;
@Autowired
WalletAccountService walletAccountService;
@Autowired
Authorization authorization;
@Autowired
HbaseService hbaseService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4459;
private static String consumerId = "100098000";
private static String orderId;
@AfterClass
public void afterclass() {
try {
//修改红包提现用户登录天数
String y_m = getTime2(0);
String key = "k01_AAWH_K003_"+y_m+"_"+consumerId;
hbaseService.updateHBASEKey(key,"","1");
// Thread.sleep(300000);
// 修改账户过期时间,确保账户余额不会过期清零
// jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(0)+"' where account_id = '"+consumerId+"_6_0'");
} catch (Exception e) {
logger.info("数据后面置操作异常");
}
}
@Test
public void 红包账户余额不足() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0976 where account_id = '"+consumerId+"_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
//账户支付宝提现
logger.info("请求doTakePrize");
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/walletAccount/doTakePrize");
Assert.assertEquals(response.jsonPath().getString("success"),"false","/walletAccount/doTakePrize接口失败");
Assert.assertEquals(response.jsonPath().getString("message"),"账户余额不足","/walletAccount/doTakePrize接口失败");
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0976 where account_id = '"+consumerId+"_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
logger.info("用户账户余额校验成功");
}
// 获取时间方法
public String getTime(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date)+" 08:00:00";
// System.out.println(time);
return time;
}
public String getTime2(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date);
// System.out.println(time);
return time;
}
}
......@@ -11,17 +11,19 @@ import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.HbaseService;
import utils.PublicMethod;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by mabo on 2018/8/15
* Created by 赵然 on 2018/11/06
*/
public class 账户正常提现 extends DuibaTestBase{
@Value("${activity.host}")
......@@ -46,7 +48,6 @@ public class 账户正常提现 extends DuibaTestBase{
String y_m = getTime2(0);
String key = "k01_AAWH_K003_"+y_m+"_"+consumerId;
hbaseService.updateHBASEKey(key,"","1");
// Thread.sleep(300000);
//修改账户过期时间,确保账户余额不会过期清零
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(0)+"' where account_id = '"+consumerId+"_6_0'");
......@@ -55,8 +56,61 @@ public class 账户正常提现 extends DuibaTestBase{
}
}
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("a_提现失败_账户错误")) {
result = new Object[][]{
new Object[]{1, "fail_account@sandbox.com", "沙箱环境"}, //case1
new Object[]{2, "peeulk6392@sandbox.com", "错误环境"}, //case2
};
}
return result;
}
/**
* @param alipay 支付宝提现账号
* @param realname 支付宝提现姓名
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void a_提现失败_账户错误(int caseNum,String alipay,String realname) throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
//账户支付宝提现
Map cookies = authorization.dafuwengLogin(uid);
Response response = this.账户提现失败(cookies,alipay,realname);
String success = response.jsonPath().getString("success");
String orderStatus = response.jsonPath().getString("orderStatus");
String message = response.jsonPath().getString("message");
Assert.assertEquals(success,"false","success状态失败");
Assert.assertEquals(orderStatus,"-1","orderStatus状态失败");
switch (caseNum){
case 1:
Assert.assertEquals(message,"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在","message校验失败");
break;
case 2:
Assert.assertEquals(message,"40004:Business Failed_PAYEE_USER_INFO_ERROR:收款用户姓名或其它信息不一致","message校验失败");
break;
}
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
logger.info("用户账户余额校验成功");
}
@Test
public void a_正常提现() throws Exception {
public void b_正常提现() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
......@@ -77,7 +131,7 @@ public class 账户正常提现 extends DuibaTestBase{
}
@Test
public void b_余额明细校验() throws Exception {
public void c_余额明细校验() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_account_log.tb_consumer_accounts_log where biz_id ="+orderId);
String change_money = String.valueOf(selectResult.get("change_money"));
......@@ -112,7 +166,7 @@ public class 账户正常提现 extends DuibaTestBase{
}
@Test
public void c_提现失败_登录次数不足() throws Exception {
public void d_提现失败_登录次数不足() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
......@@ -137,7 +191,7 @@ public class 账户正常提现 extends DuibaTestBase{
logger.info("用户账户余额校验成功");
}
public void 账户提现(Map cookies,String alipay,String realname) throws Exception {
public Response 账户提现(Map cookies,String alipay,String realname) throws Exception {
Response response = walletAccountService.doTakePrize(cookies,alipay,realname);
response.prettyPrint();
......@@ -153,8 +207,27 @@ public class 账户正常提现 extends DuibaTestBase{
i--;
response.prettyPrint();
}
return response;
}
public Response 账户提现失败(Map cookies,String alipay,String realname) throws Exception {
Response response = walletAccountService.doTakePrize(cookies,alipay,realname);
response.prettyPrint();
orderId = response.jsonPath().getString("orderId");
response = walletAccountService.getOrderStatus2(cookies,orderId);
response.prettyPrint();
String orderStatus = String.valueOf(response.jsonPath().getString("orderStatus"));
int i= 30;
while(i>0&&(orderStatus.equals("0"))){
Thread.sleep(1000);
response = walletAccountService.getOrderStatus2(cookies,orderId);
orderStatus = String.valueOf(response.jsonPath().getString("orderStatus"));
i--;
response.prettyPrint();
}
return response;
}
// 获取时间方法
public String getTime(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
......
......@@ -100,6 +100,16 @@ public class WalletAccountService {
}
public Response getOrderStatus2(Map cookies,String orderId) throws Exception {
logger.info("请求getOrderStatus");
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().cookies(cookies).params(map).post(activityHost+"/walletAccount/getOrderStatus");
return response;
}
/**
* 红包账户提现记录
* @param cookies
......
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