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
e579132d
Commit
e579132d
authored
Mar 12, 2019
by
吕雯燕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv
parent
26409458
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
121 additions
and
37 deletions
+121
-37
实物_兑换流程测试_ExchangeTest.java
.../java/http/cases/ExchangeTest/实物_兑换流程测试_ExchangeTest.java
+121
-37
No files found.
src/test/java/http/cases/ExchangeTest/实物_兑换
异常
测试_ExchangeTest.java
→
src/test/java/http/cases/ExchangeTest/实物_兑换
流程
测试_ExchangeTest.java
View file @
e579132d
...
...
@@ -13,6 +13,7 @@ import http.service.hd.DappConfigService;
import
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.DataProvider
;
import
utils.MatcherString
;
import
base.DuibaLog
;
import
io.restassured.response.Response
;
...
...
@@ -20,13 +21,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
import
utils.RedisUtil
;
/**
* Created by yeqinqin on 2018/6/11.
*/
public
class
实物
_
兑换
异常
测试
_ExchangeTest
extends
CheckTemplet
{
public
class
实物
_
兑换
流程
测试
_ExchangeTest
extends
CheckTemplet
{
@Autowired
private
MobileService
mobileService
;
...
...
@@ -80,6 +82,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
//实物兑换积分不足
@Test
(
description
=
"实物兑换积分不足"
)
public
void
积分不足
()
throws
Exception
{
...
...
@@ -179,42 +182,6 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
// @Test
public
void
每日兑换限制
()
throws
Exception
{
int
uid
=
3490
;
//第一次兑换
Response
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
"178879"
,
"31049"
,
"null"
,
"yrJRr7Cddp2YeQd"
,
"null"
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
//获取兑换结果
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
response
.
prettyPrint
();
String
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
int
i
=
10
;
//异步接口,直到兑换成功
while
(
i
>
0
&&
"兑换正在处理中..."
.
equals
(
message
))
{
Thread
.
sleep
(
1000
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
response
.
prettyPrint
();
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
i
--;
}
//第二次兑换
try
{
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
"178879"
,
"31049"
,
"null"
,
"yrJRr7Cddp2YeQd"
,
"null"
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
// message = e.toString();
}
// logger.info(message);
// Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public
void
每日支出上限测试
()
throws
Exception
{
...
...
@@ -315,6 +282,123 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
@Test
public
void
用户每日限制消费测试
()
throws
Exception
{
String
appItemId
=
"191772"
;
String
itemId
=
"31049"
;
try
{
//第一次兑换
Response
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
appItemId
,
itemId
,
"null"
,
"yrJRr7Cddp2YeQd"
,
"null"
);
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
//获取兑换结果
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
response
.
prettyPrint
();
String
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
int
i
=
10
;
//异步接口,直到兑换成功
while
(
i
>
0
&&
"兑换正在处理中..."
.
equals
(
message
))
{
Thread
.
sleep
(
1000
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
response
.
prettyPrint
();
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
i
--;
}
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"商品兑换按钮:"
+
exchangeText
);
//第二次兑换
Thread
.
sleep
(
3000
);
try
{
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
appItemId
,
itemId
,
"null"
,
"yrJRr7Cddp2YeQd"
,
"null"
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
message
);
Assert
.
assertTrue
(
message
.
contains
(
"今日已达兑换上限"
),
"校验message失败"
);
Assert
.
assertTrue
(
message
.
contains
(
"\"success\":false"
),
"校验success失败"
);
Assert
.
assertEquals
(
exchangeText
,
"今日已达兑换上限"
,
"校验兑换按钮失败"
);
logger
.
info
(
"校验实物每日限制消费成功"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
finally
{
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"
+
itemId
+
"'"
);
}
}
@Test
public
void
用户永久限制消费测试
()
throws
Exception
{
String
appItemId
=
"191773"
;
String
itemId
=
"32369"
;
try
{
//第一次兑换
Response
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
appItemId
,
itemId
,
"null"
,
"yrJRr7Cddp2YeQd"
,
"null"
);
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
//获取兑换结果
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
response
.
prettyPrint
();
String
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
int
i
=
10
;
//异步接口,直到兑换成功
while
(
i
>
0
&&
"兑换正在处理中..."
.
equals
(
message
))
{
Thread
.
sleep
(
1000
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
response
.
prettyPrint
();
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
i
--;
}
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"商品兑换按钮:"
+
exchangeText
);
//第二次兑换
Thread
.
sleep
(
3000
);
try
{
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
appItemId
,
itemId
,
"null"
,
"yrJRr7Cddp2YeQd"
,
"null"
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
message
);
Assert
.
assertTrue
(
message
.
contains
(
"已达兑换次数上限"
),
"校验message失败"
);
Assert
.
assertTrue
(
message
.
contains
(
"\"success\":false"
),
"校验success失败"
);
Assert
.
assertEquals
(
exchangeText
,
"已达兑换次数上限"
,
"校验兑换按钮失败"
);
logger
.
info
(
"校验实物每日限制消费成功"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
finally
{
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"
+
itemId
+
"'"
);
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '"
+
itemId
+
"'"
);
}
}
...
...
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