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
4fc5441d
Commit
4fc5441d
authored
Dec 07, 2018
by
panyuli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pyl' into develop
parents
32447c32
76da1ac6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
170 additions
and
0 deletions
+170
-0
Qb_兑换限制测试_ExchangeTest.java
.../java/http/cases/ExchangeTest/Qb_兑换限制测试_ExchangeTest.java
+146
-0
QbExchangeService.java
src/test/java/http/service/app/QbExchangeService.java
+24
-0
No files found.
src/test/java/http/cases/ExchangeTest/Qb_兑换限制测试_ExchangeTest.java
0 → 100644
View file @
4fc5441d
package
http
.
cases
.
ExchangeTest
;
import
base.DuibaLog
;
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.BeforeClass
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
utils.ExcelDataProvider
;
import
utils.MatcherString
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.sql.SQLException
;
import
java.util.Iterator
;
import
java.util.Map
;
/**
* Created by mabo on 2018/9/13
*/
public
class
Qb_
兑换限制测试
_ExchangeTest
extends
CheckTemplet
{
@Autowired
private
MobileService
mobileService
;
@Autowired
private
Authorization
authorization
;
@Autowired
private
CouponExchangeService
couponExchangeService
;
@Autowired
private
CrecordService
crecordService
;
@Autowired
ManagerService
managerService
;
@Autowired
VirtualExchangeService
virtualExchangeService
;
@Autowired
QbExchangeService
qbExchangeService
;
@Autowired
DeveloperAccountService
developerAccountService
;
@Autowired
DsOrderService
dsOrderService
;
@Autowired
SupplierExchangeTemplateService
supplierExchangeTemplateService
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
@BeforeMethod
public
void
beforeMethod
()
throws
SQLException
{
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'"
);
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '2'"
);
}
@DataProvider
public
Iterator
<
Object
[]>
providerMethodQb
(
Method
method
)
throws
IOException
{
Iterator
<
Object
[]>
result
=
null
;
result
=
new
ExcelDataProvider
(
"duiba/qb兑换"
);
return
result
;
}
@Test
(
description
=
"每限日兑换制同一个用户使用同一个QQ号"
)
public
void
每限日兑换制同一个用户兑换同一个
qq
()
throws
Exception
{
logger
.
info
(
"Q币每限日兑换制同一个用户兑换同一个qq开始"
);
int
uid
=
4932
;
//第一次兑换
Response
response
=
qbExchangeService
.
doTakePrize
(
authorization
.
dafuwengLogin
(
uid
),
"1234345554"
,
"1"
);
String
orderId
=
(
String
)
response
.
jsonPath
().
get
(
"orderId"
);
response
=
mobileService
.
orderStatusQuery
(
authorization
.
dafuwengLogin
(
uid
),
orderId
);
String
message
=
response
.
jsonPath
().
getString
(
"message"
);
int
i
=
10
;
while
(!
message
.
equals
(
"兑换提交成功!待处理"
)&&
i
>
0
){
Thread
.
sleep
(
1000
);
response
=
mobileService
.
orderStatusQuery
(
authorization
.
dafuwengLogin
(
uid
),
orderId
);
message
=
response
.
jsonPath
().
getString
(
"message"
);
i
--;
}
//第二次兑换
response
=
qbExchangeService
.
doTakePrize1
(
authorization
.
dafuwengLogin
(
uid
),
"1234345554"
,
"1"
);
message
=
response
.
jsonPath
().
getString
(
"message"
);
logger
.
info
(
message
);
Assert
.
assertTrue
(
message
.
contains
(
"已兑完"
));
logger
.
info
(
"Q币每限日兑换制同一个用户兑换同一个qq成功"
);
}
@Test
(
description
=
"每限日兑换制同一个用户使用不同一个QQ号"
)
public
void
每限日兑换制同一个用户使用不同一个
QQ
号
()
throws
Exception
{
logger
.
info
(
"每限日兑换制同一个用户使用不同一个QQ号开始"
);
int
uid
=
4933
;
//第一次兑换
Response
response
=
qbExchangeService
.
doTakePrize
(
authorization
.
dafuwengLogin
(
uid
),
"1234345554"
,
"1"
);
String
orderId
=
(
String
)
response
.
jsonPath
().
get
(
"orderId"
);
response
=
mobileService
.
orderStatusQuery
(
authorization
.
dafuwengLogin
(
uid
),
orderId
);
String
message
=
response
.
jsonPath
().
getString
(
"message"
);
int
i
=
10
;
while
(!
message
.
equals
(
"兑换提交成功!待处理"
)&&
i
>
0
){
Thread
.
sleep
(
1000
);
response
=
mobileService
.
orderStatusQuery
(
authorization
.
dafuwengLogin
(
uid
),
orderId
);
message
=
response
.
jsonPath
().
getString
(
"message"
);
i
--;
}
//第二次兑换
response
=
qbExchangeService
.
doTakePrize1
(
authorization
.
dafuwengLogin
(
uid
),
"12343455541"
,
"1"
);
response
.
prettyPrint
();
message
=
response
.
jsonPath
().
getString
(
"message"
);
logger
.
info
(
message
);
Assert
.
assertTrue
(
message
.
contains
(
"已兑完"
));
// Assert.assertTrue(message.contains("\"success\":false"));
logger
.
info
(
"每限日兑换制同一个用户使用不同一个QQ号成功"
);
}
@Test
(
description
=
"每限日兑换制不同一个用户使用同一个QQ号"
)
public
void
每限日兑换制不同一个用户使用同一个
QQ
号
()
throws
Exception
{
logger
.
info
(
"每限日兑换制不同一个用户使用同一个QQ号开始"
);
int
uid
=
4934
;
//第一次兑换
Response
response
=
qbExchangeService
.
doTakePrize
(
authorization
.
dafuwengLogin
(
uid
),
"123434555412"
,
"1"
);
String
orderId
=
(
String
)
response
.
jsonPath
().
get
(
"orderId"
);
response
=
mobileService
.
orderStatusQuery
(
authorization
.
dafuwengLogin
(
uid
),
orderId
);
String
message
=
response
.
jsonPath
().
getString
(
"message"
);
int
i
=
10
;
while
(!
message
.
equals
(
"兑换提交成功!待处理"
)&&
i
>
0
){
Thread
.
sleep
(
1000
);
response
=
mobileService
.
orderStatusQuery
(
authorization
.
dafuwengLogin
(
uid
),
orderId
);
message
=
response
.
jsonPath
().
getString
(
"message"
);
i
--;
}
//第二次兑换
//不同的用户,同一个 qq好
int
uid1
=
4935
;
response
=
qbExchangeService
.
doTakePrize1
(
authorization
.
dafuwengLogin
(
uid1
),
"123434555412"
,
"1"
);
response
.
prettyPrint
();
message
=
response
.
jsonPath
().
getString
(
"message"
);
logger
.
info
(
message
);
Assert
.
assertTrue
(
message
.
contains
(
"抱歉,该QQ号已达到每天充值上限,请换一个QQ号吧。"
));
logger
.
info
(
"每限日兑换制不同一个用户使用同一个QQ号成功"
);
}
}
src/test/java/http/service/app/QbExchangeService.java
View file @
4fc5441d
...
@@ -33,6 +33,7 @@ public class QbExchangeService {
...
@@ -33,6 +33,7 @@ public class QbExchangeService {
map
.
put
(
"token"
,
"0nmfgduh8"
);
map
.
put
(
"token"
,
"0nmfgduh8"
);
Response
response
=
given
().
params
(
map
).
cookies
(
cookies
).
post
(
activityHost
+
"/qbExchange/exchange"
);
Response
response
=
given
().
params
(
map
).
cookies
(
cookies
).
post
(
activityHost
+
"/qbExchange/exchange"
);
try
{
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/qbExchange/exchange接口失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/qbExchange/exchange接口失败"
);
...
@@ -45,4 +46,27 @@ public class QbExchangeService {
...
@@ -45,4 +46,27 @@ public class QbExchangeService {
return
response
;
return
response
;
}
}
public
Response
doTakePrize1
(
Map
cookies
,
String
qq
,
String
degreeId
)
throws
Exception
{
logger
.
info
(
"请求/qbExchange/exchange"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"qq"
,
qq
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"token"
,
"0nmfgduh8"
);
Response
response
=
given
().
params
(
map
).
cookies
(
cookies
).
post
(
activityHost
+
"/qbExchange/exchange"
);
String
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
logger
.
info
(
message
);
try
{
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"/objectExchange/exchange接口返回异常"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/qbExchange/exchange接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/qbExchange/exchange接口失败,返回信息:"
+
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