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
052ec99e
Commit
052ec99e
authored
May 23, 2019
by
吕雯燕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv
parent
474374c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
190 additions
and
1 deletion
+190
-1
新支付宝_兑换流程测试_ExchangeTest.java
...ava/http/cases/ExchangeTest/新支付宝_兑换流程测试_ExchangeTest.java
+148
-1
gawService.java
src/test/java/http/service/app/gawService.java
+42
-0
No files found.
src/test/java/http/cases/ExchangeTest/新支付宝_兑换流程测试_ExchangeTest.java
View file @
052ec99e
...
...
@@ -5,10 +5,12 @@ import base.DuibaBases;
import
base.DuibaTestBase
;
import
http.service.Authorization
;
import
http.service.Manager.ADeveloperService
;
import
http.service.app.AlipayExchangeService
;
import
http.service.app.gawService
;
import
http.service.app.tawService
;
import
http.service.app.MobileService
;
import
http.service.hd.DeveloperAccountService
;
import
http.service.hd.DsOrderService
;
import
org.apache.http.auth.AUTH
;
import
utils.MatcherString
;
import
base.DuibaLog
;
import
io.restassured.response.Response
;
...
...
@@ -20,6 +22,9 @@ import org.testng.annotations.Test;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Date
;
import
java.util.Calendar
;
import
java.text.SimpleDateFormat
;
import
static
io
.
restassured
.
RestAssured
.
given
;
...
...
@@ -29,6 +34,148 @@ import static io.restassured.RestAssured.given;
public
class
新支付宝
_
兑换流程测试
_ExchangeTest
extends
CheckTemplet
{
@Autowired
gawService
gawService
;
@Autowired
Authorization
authorization
;
@Autowired
tawService
tawService
;
@Autowired
MobileService
mobileService
;
@Test
(
description
=
"1元支付宝用户兑换限制永久1次"
)
public
void
支付宝用户永久兑换限制测试
()
throws
Exception
{
int
uid
=
7262
;
String
actualCredits
=
"100"
;
String
degreeId
=
"1"
;
String
appItemId
=
"195996"
;
String
credits
=
"100"
;
String
message
=
""
;
try
{
//支付宝兑换
Response
response
=
this
.
支付宝兑换
(
uid
,
actualCredits
,
degreeId
,
appItemId
,
credits
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.payCreditsStatus"
),
"1"
,
"校验兑换失败"
);
logger
.
info
(
"用户成功兑换一次"
);
//再次兑换
Thread
.
sleep
(
3000
);
try
{
response
=
gawService
.
alipayExchange
(
uid
,
actualCredits
,
degreeId
,
appItemId
,
credits
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
message
);
//获取按钮状态
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
"55"
);
String
btnText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"1\":\\{\"btnText\":\"(.*?)\","
,
1
);
logger
.
info
(
"再次兑换按钮:"
+
btnText
);
Assert
.
assertTrue
(
message
.
contains
(
"\"desc\":\"已兑完\""
),
"校验用户兑换限制失败"
);
Assert
.
assertEquals
(
btnText
,
"已兑换"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验支付宝1元用户永久兑换限制成功"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
finally
{
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = 55 AND consumer_id = 100147103"
);
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record WHERE item_id = 55 AND consumer_id = 100147103"
);
}
}
@Test
(
description
=
"2元支付宝用户兑换限制每天1次"
)
public
void
支付宝用户每天兑换限制测试
()
throws
Exception
{
int
uid
=
7270
;
String
actualCredits
=
"200"
;
String
degreeId
=
"2"
;
String
appItemId
=
"195996"
;
String
credits
=
"200"
;
String
message
=
""
;
try
{
//支付宝兑换
Response
response
=
this
.
支付宝兑换
(
uid
,
actualCredits
,
degreeId
,
appItemId
,
credits
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.payCreditsStatus"
),
"1"
,
"校验兑换失败"
);
logger
.
info
(
"用户成功兑换一次"
);
//再次兑换
Thread
.
sleep
(
3000
);
try
{
response
=
gawService
.
alipayExchange
(
uid
,
actualCredits
,
degreeId
,
appItemId
,
credits
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
message
);
//获取按钮状态
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
"55"
);
String
btnText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"2\":\\{\"btnText\":\"(.*?)\","
,
1
);
logger
.
info
(
"再次兑换按钮:"
+
btnText
);
Assert
.
assertTrue
(
message
.
contains
(
"\"desc\":\"已兑完\""
),
"校验用户兑换限制失败"
);
Assert
.
assertEquals
(
btnText
,
"今日已兑换"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验支付宝2元用户每天兑换限制成功"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
finally
{
//获取当前日期时间,再减一天
Date
date
=
new
Date
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
1
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
logger
.
info
(
"当前时间-1天:"
+
dateFormat
.
format
(
calendar
.
getTime
()));
//更新表记录,修改记录为前一天
String
sql
=
"UPDATE credits_dev.consumer_limit_record SET gmt_create = '"
+
dateFormat
.
format
(
calendar
.
getTime
())
+
"' WHERE item_id = 55 and consumer_id = 100147117 ORDER BY id DESC LIMIT 1"
;
jdbc
.
update
(
sql
);
}
}
public
Response
支付宝兑换
(
int
uid
,
String
actualCredits
,
String
degreeId
,
String
appItemId
,
String
credits
)
throws
Exception
{
Response
response
=
gawService
.
alipayExchange
(
uid
,
actualCredits
,
degreeId
,
appItemId
,
credits
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data.orderId"
);
//查看兑换结果
response
=
tawService
.
orderStatus
(
orderId
,
uid
);
response
.
prettyPrint
();
String
status
=
response
.
jsonPath
().
getString
(
"data.status"
);
//异步接口
int
i
=
10
;
while
(
i
>
0
&&
status
.
equals
(
"processing"
))
{
Thread
.
sleep
(
1000
);
response
=
tawService
.
orderStatus
(
orderId
,
uid
);
response
.
prettyPrint
();
status
=
response
.
jsonPath
().
getString
(
"data.status"
);
i
--;
}
return
response
;
}
...
...
src/test/java/http/service/app/gawService.java
View file @
052ec99e
...
...
@@ -17,6 +17,7 @@ import java.util.List;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
import
static
io
.
restassured
.
RestAssured
.
post
;
@Service
public
class
gawService
{
...
...
@@ -345,6 +346,47 @@ public class gawService {
}
//新支付宝兑换接口
public
Response
alipayExchange
(
int
uid
,
String
actualCredits
,
String
degreeId
,
String
appItemId
,
String
credits
)
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
mapList
=
new
HashMap
<>();
List
<
Map
>
list
=
new
ArrayList
<>();
mapList
.
put
(
"appItemId"
,
appItemId
);
mapList
.
put
(
"credits"
,
credits
);
list
.
add
(
mapList
);
map
.
put
(
"actualCredits"
,
actualCredits
);
//总积分
map
.
put
(
"actualPrice"
,
"0"
);
map
.
put
(
"alipay"
,
"15858196010"
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"realname"
,
"测试"
);
map
.
put
(
"remark"
,
""
);
map
.
put
(
"token"
,
"yrJRr7Cddp2YeQd"
);
map
.
put
(
"validate"
,
""
);
map
.
put
(
"itemParam"
,
list
.
toArray
());
JSONObject
jsonParam
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
map
));
logger
.
info
(
"请求支付宝兑换接口:"
+
"/gaw/alipayExchange/create"
);
Response
response
=
given
().
contentType
(
"application/json; charset=UTF-8"
).
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
body
(
jsonParam
).
post
(
"http://"
+
goodsHost
+
"/gaw/alipayExchange/create"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/gaw/alipayExchange/create接口返回异常,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/gaw/alipayExchange/create接口返回异常,返回信息:"
+
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