Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马博
test-platform
Commits
347695d5
Commit
347695d5
authored
Mar 29, 2019
by
赵然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zr
parent
3d0f5d38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
420 additions
and
0 deletions
+420
-0
总帐户账户正常提现.java
src/test/java/http/cases/WalletTest/总帐户账户正常提现.java
+252
-0
GlobalRewardService.java
src/test/java/http/service/Activity/GlobalRewardService.java
+168
-0
No files found.
src/test/java/http/cases/WalletTest/总帐户账户正常提现.java
0 → 100644
View file @
347695d5
package
http
.
cases
.
WalletTest
;
import
base.DuibaLog
;
import
base.DuibaTestBase
;
import
http.service.Activity.GlobalRewardService
;
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.BeforeClass
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
utils.HbaseService
;
import
java.lang.reflect.Method
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by 赵然 on 2019/03/29
*/
public
class
总帐户账户正常提现
extends
DuibaTestBase
{
@Value
(
"${activity.host}"
)
String
activityHost
;
@Autowired
SeedRedPacketService
seedRedPacketService
;
@Autowired
WalletAccountService
walletAccountService
;
@Autowired
GlobalRewardService
globalRewardService
;
@Autowired
Authorization
authorization
;
@Autowired
HbaseService
hbaseService
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
//指定用户
private
static
int
uid
=
7112
;
private
static
String
consumerId
=
"100145034"
;
private
static
String
orderId
;
@BeforeClass
public
void
beforeclass
()
{
try
{
//重置账户金额2000
walletAccountService
.
updateConsumerAccount
(
consumerId
,
"6"
,
"2000"
);
//清空提现记录
jdbc
.
update
(
"DELETE FROM consumer_account_log.tb_consumer_accounts_log where account_id = '"
+
consumerId
+
"_6_0'"
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"数据后面置操作异常"
);
}
}
@DataProvider
public
Object
[][]
providerMethod
(
Method
method
)
{
Object
[][]
result
=
null
;
if
(
method
.
getName
().
equals
(
"b_提现失败_账户错误"
))
{
result
=
new
Object
[][]{
//new Object[]{1, "fail_account@sandbox.com", "沙箱环境"}, //case1
new
Object
[]{
2
,
"peeulk6392@sandbox.com"
,
"错误环境"
},
//case2
};
}
return
result
;
}
@Test
public
void
a_
提现失败
_
金额不对
()
throws
Exception
{
//获取原账户余额
Map
<
String
,
Object
>
selectResult
=
jdbc
.
findSimpleResult
(
"select * from consumer_accounts.tb_consumer_account_0906 where account_id = '100145034_6_0' "
);
int
balance
=
Integer
.
parseInt
(
String
.
valueOf
(
selectResult
.
get
(
"balance_amount"
)));
logger
.
info
(
"账户原有余额为"
+
balance
);
//账户支付宝提现
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
Response
response
=
this
.
账户提现失败
(
cookies
,
"1"
,
"peeulk6392@sandbox.com"
,
"沙箱环境"
);
response
.
print
();
String
success
=
response
.
jsonPath
().
getString
(
"success"
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
message
=
response
.
jsonPath
().
getString
(
"desc"
);
Assert
.
assertEquals
(
success
,
"false"
,
"success状态失败"
);
Assert
.
assertEquals
(
code
,
"100000"
,
"错误码失败"
);
Assert
.
assertEquals
(
message
,
"最低提现金额20元"
,
"message失败"
);
//获取新账户余额
selectResult
=
jdbc
.
findSimpleResult
(
"select * from consumer_accounts.tb_consumer_account_0906 where account_id = '100145034_6_0' "
);
int
balanceNew
=
Integer
.
parseInt
(
String
.
valueOf
(
selectResult
.
get
(
"balance_amount"
)));
logger
.
info
(
"账户新余额为"
+
balanceNew
);
Assert
.
assertEquals
(
balanceNew
,
balance
,
"全局红包增加账户余额失败"
);
logger
.
info
(
"用户账户余额校验成功"
);
}
/**
* @param account 支付宝提现账号
* @param username 支付宝提现姓名
* @throws Exception
*/
@Test
(
dataProvider
=
"providerMethod"
)
public
void
b_
提现失败
_
账户错误
(
int
caseNum
,
String
account
,
String
username
)
throws
Exception
{
//获取原账户余额
Map
<
String
,
Object
>
selectResult
=
jdbc
.
findSimpleResult
(
"select * from consumer_accounts.tb_consumer_account_0906 where account_id = '100145034_6_0' "
);
int
balance
=
Integer
.
parseInt
(
String
.
valueOf
(
selectResult
.
get
(
"balance_amount"
)));
logger
.
info
(
"账户原有余额为"
+
balance
);
//账户支付宝提现
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
Response
response
=
this
.
账户提现失败
(
cookies
,
"2000"
,
account
,
username
);
response
.
print
();
Thread
.
sleep
(
5000
);
Map
<
String
,
Object
>
accountlog
=
jdbc
.
findSimpleResult
(
"select * from consumer_account_log.tb_consumer_accounts_log where account_id = '100145034_6_0' and action_type = '1'"
);
switch
(
caseNum
){
case
1
:
Assert
.
assertEquals
(
accountlog
.
get
(
"memo"
),
"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在"
,
"message校验失败"
);
break
;
case
2
:
Assert
.
assertEquals
(
accountlog
.
get
(
"memo"
),
"40004:Business Failed_PAYEE_USER_INFO_ERROR:支付宝账号和姓名不匹配,请确认姓名是否正确"
,
"message校验失败"
);
break
;
}
//获取新账户余额
selectResult
=
jdbc
.
findSimpleResult
(
"select * from consumer_accounts.tb_consumer_account_0906 where account_id = '100145034_6_0' "
);
int
balanceNew
=
Integer
.
parseInt
(
String
.
valueOf
(
selectResult
.
get
(
"balance_amount"
)));
logger
.
info
(
"账户新余额为"
+
balanceNew
);
Assert
.
assertEquals
(
balanceNew
,
balance
,
"全局红包增加账户余额失败"
);
logger
.
info
(
"用户账户余额校验成功"
);
}
@Test
public
void
c_
正常提现
()
throws
Exception
{
//获取原账户余额
Map
<
String
,
Object
>
selectResult
=
jdbc
.
findSimpleResult
(
"select * from consumer_accounts.tb_consumer_account_0906 where account_id = '100145034_6_0' "
);
int
balance
=
Integer
.
parseInt
(
String
.
valueOf
(
selectResult
.
get
(
"balance_amount"
)));
logger
.
info
(
"账户原有余额为"
+
balance
);
balance
=
balance
-
20
;
//账户支付宝提现
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
this
.
账户提现
(
cookies
,
"2000"
,
"peeulk6392@sandbox.com"
,
"沙箱环境"
);
Thread
.
sleep
(
2000
);
//获取新账户余额
selectResult
=
jdbc
.
findSimpleResult
(
"select * from consumer_accounts.tb_consumer_account_0906 where account_id = '100145034_6_0' "
);
int
balanceNew
=
Integer
.
parseInt
(
String
.
valueOf
(
selectResult
.
get
(
"balance_amount"
)));
logger
.
info
(
"账户新余额为"
+
balanceNew
);
Assert
.
assertEquals
(
balanceNew
,
balance
,
"全局红包增加账户余额失败"
);
logger
.
info
(
"用户账户余额校验成功"
);
}
//@Test
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"
));
String
action_type
=
String
.
valueOf
(
selectResult
.
get
(
"action_type"
));
String
sub_type
=
String
.
valueOf
(
selectResult
.
get
(
"sub_type"
));
String
biz_description
=
String
.
valueOf
(
selectResult
.
get
(
"biz_description"
));
Assert
.
assertEquals
(
change_money
,
"1"
,
"数据库扣款金额校验失败"
);
Assert
.
assertEquals
(
action_type
,
"0"
,
"数据库账户动作校验失败"
);
Assert
.
assertEquals
(
sub_type
,
"0"
,
"数据库日志类型校验失败"
);
Assert
.
assertEquals
(
biz_description
,
"提现"
,
"数据库业务描述校验失败"
);
//获取订单创建时间
// String gmt_create = String.valueOf(selectResult.get("gmt_create"));
// SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Date date = fmt.parse(gmt_create); //将从数据库读出来的 timestamp 类型的时间转换为java的Date类型
//String gmt_create_data = fmt.format(date); //将这个时间格式化,转换为String类型
// String gmt_create_data = getTime3(date,-14);
// logger.info("数据库订单创建时间为:"+gmt_create_data);
//获取最新的提现记录
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
Response
response
=
walletAccountService
.
walletDetail
(
cookies
);
// String gmtCreate = response.jsonPath().getString("data[0].gmtCreate");
String
money
=
response
.
jsonPath
().
getString
(
"data[0].money"
);
String
subType
=
response
.
jsonPath
().
getString
(
"data[0].subType"
);
Assert
.
assertEquals
(
money
,
"0.01"
,
"扣款金额校验失败"
);
Assert
.
assertEquals
(
subType
,
"0"
,
"日志类型校验失败"
);
//Assert.assertEquals( PublicMethod.stampToDate(gmtCreate),gmt_create_data,"订单生成时间校验失败");
logger
.
info
(
"订单列表提现记录校验成功"
);
}
public
Response
账户提现
(
Map
cookies
,
String
amount
,
String
account
,
String
username
)
throws
Exception
{
Response
response
=
globalRewardService
.
withdraw
(
cookies
,
amount
,
account
,
username
);
response
.
prettyPrint
();
return
response
;
}
public
Response
账户提现失败
(
Map
cookies
,
String
amount
,
String
account
,
String
username
)
throws
Exception
{
logger
.
info
(
"请求withdraw"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"amount"
,
amount
);
map
.
put
(
"account"
,
account
);
map
.
put
(
"username"
,
username
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
cookies
).
params
(
map
).
post
(
activityHost
+
"/globalReward/withdraw"
);
return
response
;
}
// 获取时间方法
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
;
}
public
String
getTime3
(
Date
date
,
int
amount
){
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
ENGLISH
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
HOUR_OF_DAY
,
amount
);
date
=
calendar
.
getTime
();
String
time
=
dateFormat
.
format
(
date
);
return
time
;
}
}
src/test/java/http/service/Activity/GlobalRewardService.java
0 → 100644
View file @
347695d5
package
http
.
service
.
Activity
;
import
base.DuibaLog
;
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.springframework.stereotype.Service
;
import
org.testng.Assert
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by zhaoran on 2019/03/29
*/
@Service
public
class
GlobalRewardService
{
@Autowired
Authorization
authorization
;
@Value
(
"${activity.host}"
)
String
activityHost
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
/**
* 获取红包账户
* @param cookies
* @return
* @throws Exception
*/
public
Response
getWalletAccount
(
Map
cookies
)
throws
Exception
{
logger
.
info
(
"请求getWalletAccount"
);
Response
response
=
given
().
cookies
(
cookies
).
get
(
activityHost
+
"/walletAccount/getWalletAccount"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/walletAccount/getWalletAccount接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/walletAccount/getWalletAccount接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/walletAccount/getWalletAccount接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
/**
* 红包账户提现
* @param cookies
* @param amount
* @param account
* @param username
* @return
* @throws Exception
*/
public
Response
withdraw
(
Map
cookies
,
String
amount
,
String
account
,
String
username
)
throws
Exception
{
logger
.
info
(
"请求withdraw"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"amount"
,
amount
);
map
.
put
(
"account"
,
account
);
map
.
put
(
"username"
,
username
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
cookies
).
params
(
map
).
post
(
activityHost
+
"/globalReward/withdraw"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/walletAccount/doTakePrize接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/globalReward/withdraw接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/globalReward/withdraw接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
/**
* 红包账户提现
* @param cookies
* @param orderId
* @return
* @throws Exception
*/
public
Response
getOrderStatus
(
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"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/walletAccount/getOrderStatus接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/walletAccount/getOrderStatus接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/walletAccount/getOrderStatus接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
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
* @return
* @throws Exception
*/
public
Response
walletDetail
(
Map
cookies
)
throws
Exception
{
logger
.
info
(
"请求walletDetail"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"pageNo"
,
"1"
);
map
.
put
(
"pageSize"
,
"12"
);
Response
response
=
given
().
cookies
(
cookies
).
params
(
map
).
get
(
activityHost
+
"/walletAccount/walletDetail"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/walletAccount/walletDetail接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/walletAccount/walletDetail接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/walletAccount/walletDetail接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
/**
* 红包账户修改钱包账户余额后门
* @param consumerId
* @param accountType
* @param balanceAmount
* @return
* @throws Exception
*/
public
void
updateConsumerAccount
(
String
consumerId
,
String
accountType
,
String
balanceAmount
)
throws
Exception
{
logger
.
info
(
"请求修改钱包账户余额后门:updateConsumerAccount"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"consumerId"
,
consumerId
);
map
.
put
(
"accountType"
,
accountType
);
map
.
put
(
"balanceAmount"
,
balanceAmount
);
Response
response
=
given
().
params
(
map
).
get
(
activityHost
+
"/aaw/automated/updateConsumerAccount"
);
// try{
// Assert.assertEquals(response.jsonPath().getString("success"),"true","/walletAccount/walletDetail接口失败");
//
// }catch(Exception e){
// throw new Exception("/aaw/automated/updateConsumerAccount接口失败,返回信息:"+response.asString());
// }catch(Error er){
// throw new Exception("/aaw/automated/updateConsumerAccount接口失败,返回信息:"+response.asString());
//
// }
//return response;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment