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
991f23ed
Commit
991f23ed
authored
Nov 06, 2018
by
赵然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zr
parent
5bd9f3d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
241 additions
and
16 deletions
+241
-16
账户正常提现.java
src/test/java/http/cases/WalletTest/账户正常提现.java
+116
-12
WalletAccountService.java
...test/java/http/service/Activity/WalletAccountService.java
+30
-4
HbaseService.java
src/test/java/utils/HbaseService.java
+48
-0
PublicMethod.java
src/test/java/utils/PublicMethod.java
+47
-0
No files found.
src/test/java/http/cases/WalletTest/账户正常提现.java
View file @
991f23ed
...
...
@@ -7,59 +7,141 @@ import http.service.Authorization;
import
base.DuibaLog
;
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.Test
;
import
utils.HbaseService
;
import
utils.PublicMethod
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Locale
;
import
java.util.Map
;
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
=
4244
;
private
static
String
consumerId
=
"100092758"
;
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
{
//修改账户过期时间,确保账户余额不会过期清零
jdbc
.
update
(
"update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"
+
getTime
(
0
)+
"' where account_id = '100092758_6_0'"
);
public
void
a_
正常提现
()
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
);
balance
=
balance
+
1
;
balance
=
balance
-
1
;
//账户支付宝提现
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
this
.
账户提现
(
cookies
,
"peeulk6392@sandbox.com"
,
"沙箱环境"
);
Thread
.
sleep
(
2000
);
//获取新账户余额
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
b_
余额明细校验
()
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
,
"提现"
,
"数据库业务描述校验失败"
);
Assert
.
assertEquals
(
balance
,
balanceNew
,
"全局红包增加账户余额失败"
);
//获取订单创建时间
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
(
"订单列表提现记录校验成功"
);
}
@Test
public
void
c_
提现失败
_
登录次数不足
()
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
);
//账户支付宝提现
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_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
(
"用户账户余额校验成功"
);
}
public
void
账户提现
(
Map
cookies
,
String
alipay
,
String
realname
)
throws
Exception
{
Response
response
=
walletAccountService
.
doTakePrize
(
cookies
,
alipay
,
realname
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
response
=
walletAccountService
.
getOrderStatus
(
cookies
,
orderId
);
response
.
prettyPrint
();
String
orderStatus
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"orderStatus"
));
...
...
@@ -85,6 +167,28 @@ public class 账户正常提现 extends DuibaTestBase{
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/WalletAccountService.java
View file @
991f23ed
...
...
@@ -58,9 +58,9 @@ public class WalletAccountService {
public
Response
doTakePrize
(
Map
cookies
,
String
alipay
,
String
realname
)
throws
Exception
{
logger
.
info
(
"请求doTakePrize"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"alipay"
,
"peeulk6392@sandbox.com"
);
map
.
put
(
"realname"
,
"沙箱环境"
);
Response
response
=
given
().
co
okies
(
cookies
).
ge
t
(
activityHost
+
"/walletAccount/doTakePrize"
);
map
.
put
(
"alipay"
,
alipay
);
map
.
put
(
"realname"
,
realname
);
Response
response
=
given
().
co
ntentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
cookies
).
params
(
map
).
pos
t
(
activityHost
+
"/walletAccount/doTakePrize"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/walletAccount/doTakePrize接口失败"
);
...
...
@@ -86,7 +86,7 @@ public class WalletAccountService {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"orderId"
,
orderId
);
Response
response
=
given
().
cookies
(
cookies
).
ge
t
(
activityHost
+
"/walletAccount/getOrderStatus"
);
Response
response
=
given
().
cookies
(
cookies
).
params
(
map
).
pos
t
(
activityHost
+
"/walletAccount/getOrderStatus"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/walletAccount/getOrderStatus接口失败"
);
...
...
@@ -99,4 +99,30 @@ public class WalletAccountService {
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
;
}
}
src/test/java/utils/HbaseService.java
View file @
991f23ed
...
...
@@ -12,6 +12,7 @@ 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
;
...
...
@@ -48,6 +49,18 @@ public class HbaseService {
}
public
Response
getHBASEKey2
(
String
key
)
{
String
url
=
activtyHost
+
"/aaw/hb/get"
;
Map
<
String
,
Object
>
parm
=
new
HashMap
<>();
parm
.
put
(
"key"
,
key
);
Response
response
=
given
().
params
(
parm
).
get
(
url
);
return
response
;
}
public
void
deleteHBASEKey
(
String
key
)
{
...
...
@@ -63,5 +76,40 @@ public class HbaseService {
}
public
Response
deleteHBASEKey2
(
String
key
)
throws
Exception
{
String
url
=
activtyHost
+
"/aaw/hb/delete"
;
Map
<
String
,
Object
>
parm
=
new
HashMap
<>();
parm
.
put
(
"key"
,
key
);
Response
response
=
given
().
params
(
parm
).
get
(
url
);
// response.prettyPrint();
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data"
),
"删除完毕"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/aaw/hb/delete接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/aaw/hb/delete接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
void
updateHBASEKey
(
String
key
,
String
svalue
,
String
lvalue
)
{
String
url
=
activtyHost
+
"/aaw/hb/update"
;
Map
<
String
,
Object
>
parm
=
new
HashMap
<>();
parm
.
put
(
"key"
,
key
);
if
(!
svalue
.
equals
(
""
))
{
parm
.
put
(
"svalue"
,
svalue
);
}
if
(!
lvalue
.
equals
(
""
))
{
parm
.
put
(
"lvalue"
,
lvalue
);
}
Response
response
=
given
().
params
(
parm
).
get
(
url
);
// response.prettyPrint();
// return response;
}
}
\ No newline at end of file
src/test/java/utils/PublicMethod.java
View file @
991f23ed
package
utils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Locale
;
/**
* Created by zhaoran on 2018/4/10.
...
...
@@ -18,4 +21,48 @@ public class PublicMethod {
String
date
=
df
.
format
(
new
Date
());
// new Date()为获取当前系统时间,也可使用当前时间戳
return
date
;
}
/**
* 将时间转换为时间戳
*/
public
static
String
dateToStamp
(
String
s
)
throws
ParseException
{
String
res
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
date
=
simpleDateFormat
.
parse
(
s
);
long
ts
=
date
.
getTime
();
res
=
String
.
valueOf
(
ts
);
return
res
;
}
/**
* 将时间戳转换为时间
*/
public
static
String
stampToDate
(
String
s
){
String
res
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
long
lt
=
new
Long
(
s
);
Date
date
=
new
Date
(
lt
);
res
=
simpleDateFormat
.
format
(
date
);
return
res
;
}
/**
* Date类型向前向后滚动固定时长
*
* @param date
* 调整前的时间对象
* @param i
* 需要滚动哪一个字段,写法: 年->Calendar.YEAR 月->Calendar.MONTH
* 日->Calendar.DATE 时->Calendar.HOUR_OF_DAY(24小时制)
* 分->Calendar.MINUTE 秒->Calendar.SECOND 毫秒->Calendar.MILLISECOND
* @param d
* 滚动多少,向前(以前)就用负数,向后(未来)就用正数
*/
public
static
Date
DateRoll
(
Date
date
,
int
i
,
int
d
){
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
i
,
d
);
date
=
calendar
.
getTime
();
return
date
;
}
}
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