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
c73bf836
Commit
c73bf836
authored
Nov 16, 2018
by
赵然
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of gitlab2.dui88.com:mabo/test-platform into develop
parents
0acd24e4
4ea97b43
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
555 additions
and
1 deletion
+555
-1
优惠券_兑换异常测试_ExchangeTest.java
...java/http/cases/ExchangeTest/优惠券_兑换异常测试_ExchangeTest.java
+2
-1
虚拟商品_兑换异常测试_ExchangeTest.java
...ava/http/cases/ExchangeTest/虚拟商品_兑换异常测试_ExchangeTest.java
+531
-0
VirtualExchangeService.java
src/test/java/http/service/app/VirtualExchangeService.java
+22
-0
No files found.
src/test/java/http/cases/ExchangeTest/优惠券_兑换
流程测试pyl
_ExchangeTest.java
→
src/test/java/http/cases/ExchangeTest/优惠券_兑换
异常测试
_ExchangeTest.java
View file @
c73bf836
...
...
@@ -23,7 +23,8 @@ import static io.restassured.RestAssured.given;
* Created by panyuli on 2018/07/06.
*/
public
class
优惠券
_
兑换流程测试
pyl_ExchangeTest
extends
CheckTemplet
{
public
class
优惠券
_
兑换异常测试
_ExchangeTest
extends
CheckTemplet
{
@Autowired
private
MobileService
mobileService
;
...
...
src/test/java/http/cases/ExchangeTest/虚拟商品_兑换异常测试_ExchangeTest.java
0 → 100644
View file @
c73bf836
package
http
.
cases
.
ExchangeTest
;
import
base.DuibaLog
;
import
base.DuibaTestBase
;
import
com.alibaba.fastjson.JSONObject
;
import
http.service.Activity.ManagerService
;
import
http.service.Authorization
;
import
http.service.app.CrecordService
;
import
http.service.app.MobileService
;
import
http.service.app.VirtualExchangeService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
utils.MatcherString
;
import
java.util.Map
;
/**
* Created by panyuli on 2018/6/11.
*/
public
class
虚拟商品
_
兑换异常测试
_ExchangeTest
extends
CheckTemplet
{
@Autowired
private
MobileService
mobileService
;
@Autowired
private
Authorization
authorization
;
@Autowired
ManagerService
managerService
;
@Autowired
VirtualExchangeService
virtualExchangeService
;
@Autowired
CrecordService
crecordService
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
//指定用户
private
static
int
uid
=
4502
;
//实物兑换积分不足
@Test
(
description
=
"自有虚拟商品积分不足"
)
public
void
自有虚拟商品积分不足
()
throws
Exception
{
logger
.
info
(
"自有虚拟商品积分不足"
);
int
uid
=
3086
;
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"185534"
);
response
.
prettyPrint
();
Assert
.
assertEquals
(
response
.
asString
().
contains
(
"不足,去赚"
),
true
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange2
(
authorization
.
dafuwengLogin
(
uid
),
"185534"
,
"121"
);
response
.
prettyPrint
();
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
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
--;
}
Assert
.
assertEquals
(
message
.
trim
(),
"兑换失败,用户积分余额不足"
,
"校验自有虚拟商品积分不足"
);
logger
.
info
(
"校验积分不足验证成功"
);
}
@Test
(
description
=
"自有虚拟商品库存不足"
)
public
void
自有虚拟商品库存不足
()
throws
Exception
{
logger
.
info
(
"自有虚拟商品库存不足"
);
//活动详情页
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"185535"
);
response
.
prettyPrint
();
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"exchangeText"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"已兑完"
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
response
=
virtualExchangeService
.
exchange2
(
authorization
.
dafuwengLogin
(
uid
),
"185535"
,
"123"
);
response
.
prettyPrint
();
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
String
message
=
response
.
jsonPath
().
getString
(
"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
--;
}
// message.
logger
.
info
(
"message"
+
message
);
Assert
.
assertEquals
(
message
,
"今日已兑完,明天再来哦(14)"
,
"页面数据message返回错误"
);
logger
.
info
(
"自有虚拟商品库存不足完成"
);
}
// @Test(description = "虚拟商品用户每日兑换限制测试只能兑换一次" )
public
void
自有虚拟商品用户每日兑换限制测试只能兑换一次
()
throws
Exception
{
try
{
logger
.
info
(
"虚拟商品用户每日兑换限制测试只能兑换一次"
);
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"185684"
);
response
.
prettyPrint
();
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"exchangeText"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"马上兑换"
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange2
(
authorization
.
dafuwengLogin
(
uid
),
"185684"
,
"123"
);
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
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
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
logger
.
info
(
"exchangeText"
+
exchangeText
);
Assert
.
assertEquals
(
resultResponse
.
asString
().
contains
(
"兑换成功"
),
true
,
"兑换数据页面数据返回错误"
);
//按钮层校验
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"185684"
);
response
.
prettyPrint
();
Thread
.
sleep
(
3000
);
//exchangeText = MatcherString.getString(response.asString(), "\"exchangeStatusText\":\"(.*?)\",", 1);
//logger.info("exchangeText" + exchangeText);
Assert
.
assertEquals
(
response
.
asString
().
contains
(
"今日已兑换"
),
true
,
"页面数据返回错误"
);
Assert
.
assertEquals
(
exchangeText
,
"今日已兑换"
,
"页面数据返回错误"
);
// 第二次兑换接口层校验
response
=
virtualExchangeService
.
exchange
(
authorization
.
dafuwengLogin
(
uid
),
"185684"
,
"123"
);
response
.
prettyPrint
();
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
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
.
prettyPrint
();
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"message"
),
"今日已兑换"
,
"接口数据返回数据返回错误"
);
logger
.
info
(
"虚拟商品用户每日兑换限制测试只能兑换一次 成功"
);
}
catch
(
Exception
e
)
{
e
.
toString
();
}
finally
{
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record_only WHERE app_item_id = '185684'"
);
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record WHERE app_item_id = '185684'"
);
}
}
//@Test(description = "虚拟商品用户永久兑换")
public
void
自有虚拟商品用户永久一次兑换
OK
()
throws
Exception
{
try
{
logger
.
info
(
"自有虚拟商品用户永久一次兑换"
);
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"185738"
);
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
uid
,
true
);
response
.
prettyPrint
();
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
logger
.
info
(
"exchangeText:"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"\"马上兑换\""
,
"页面数据返回错误"
);
// Assert.assertEquals(response.asString().contains("马上兑换"),true,"页面数据返回错误");
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange
(
authorization
.
dafuwengLogin
(
uid
),
"185738"
,
"123"
);
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
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
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
logger
.
info
(
"exchangeText"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"兑换成功"
,
"页面数据返回错误"
);
//Assert.assertEquals(resultResponse.asString().contains("兑换成功"),true,"兑换数据页面数据返回错误");
// 第二次兑换 按钮层校验
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"185684"
);
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
logger
.
info
(
"exchangeTex第二次:"
+
exchangeText
);
response
.
prettyPrint
();
Assert
.
assertEquals
(
exchangeText
,
"\"今日已兑换\""
,
"页面数据返回错误"
);
// 第二次兑换接口层校验
response
=
virtualExchangeService
.
exchange
(
authorization
.
dafuwengLogin
(
uid
),
"185684"
,
"123"
);
response
.
prettyPrint
();
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
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
.
prettyPrint
();
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"message"
).
contains
(
"今日已兑换"
),
true
,
"接口数据返回数据返回错误"
);
logger
.
info
(
"虚拟商品用户永久兑换 成功"
);
String
error
=
"error"
;
}
catch
(
Exception
e
)
{
e
.
toString
();
logger
.
info
(
e
.
toString
());
Assert
.
assertEquals
(
e
.
toString
().
contains
(
"今日已兑换"
),
true
,
"接口数据返回数据返回错误"
);
}
finally
{
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record_only WHERE app_item_id = '185738'"
);
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record WHERE app_item_id = '185738'"
);
}
}
@Test
(
description
=
"虚拟商品自定义兑换按钮文案马上使用按钮"
)
public
void
虚拟商品自定义兑换按钮文案马上使用按钮
()
throws
Exception
{
logger
.
info
(
"虚拟商品马上使用按钮验证开始"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"186447"
);
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
response
.
prettyPrint
();
logger
.
info
(
"exchangeText:"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"\"马上使用\""
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange2
(
authorization
.
dafuwengLogin
(
uid
),
"186447"
,
"123"
);
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
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
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
resultResponse
.
prettyPrint
();
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
//异步接口,直到兑换成功
int
n
=
10
;
while
(
n
>
0
&&
"处理中"
.
equals
(
exchangeText
))
{
Thread
.
sleep
(
1000
);
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
resultResponse
.
prettyPrint
();
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
n
--;
}
logger
.
info
(
"exchangeText"
+
exchangeText
);
Assert
.
assertEquals
(
resultResponse
.
asString
().
contains
(
"兑换成功"
),
true
,
"兑换数据页面数据返回错误"
);
logger
.
info
(
"虚拟商品马上使用按钮验证结束"
);
}
@Test
(
description
=
"【自动化】虚拟商品日期兑换时间未到"
)
public
void
虚拟商品日期兑换时间未到
()
throws
Exception
{
try
{
logger
.
info
(
"【自动化】虚拟商品日期兑换时间未到开始验证"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"186617"
);
response
.
prettyPrint
();
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
logger
.
info
(
"exchangeText:"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"\"即将开始\""
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange
(
authorization
.
dafuwengLogin
(
uid
),
"186617"
,
"123"
);
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
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
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
logger
.
info
(
"exchangeText"
+
exchangeText
);
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
logger
.
info
(
"message"
+
message
);
Assert
.
assertEquals
(
message
,(
"请在限定时间内兑换哦(13)"
),
"接口数据返回数据返回错误"
);
logger
.
info
(
"【自动化】虚拟商品日期兑换时间未到开始结束"
);
}
catch
(
Exception
e
)
{
e
.
toString
();
logger
.
info
(
e
.
toString
());
}
}
@Test
(
description
=
"【自动化】虚拟商品日期兑换时间已经结束"
)
public
void
虚拟商品日期兑换时间已经结束
()
throws
Exception
{
try
{
logger
.
info
(
"【自动化】虚拟商品日期兑换时间已经结束验证"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"186619"
);
response
.
prettyPrint
();
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
logger
.
info
(
"exchangeText:"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"\"已结束\""
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange2
(
authorization
.
dafuwengLogin
(
uid
),
"186617"
,
"123"
);
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
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
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
logger
.
info
(
"exchangeText"
+
exchangeText
);
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
logger
.
info
(
"message"
+
message
);
Assert
.
assertEquals
(
message
,(
"请在限定时间内兑换哦(13)"
),
"接口数据返回数据返回错误"
);
logger
.
info
(
"【自动化】虚拟商品日期兑换时间已经结束验证完成"
);
}
catch
(
Exception
e
)
{
e
.
toString
();
logger
.
info
(
e
.
toString
());
}
}
@Test
(
description
=
"【自动化】虚拟商品兑换需输入账号-未输入账号-验证"
)
public
void
虚拟商品兑换需要输入账号未输入账号信息验证
()
throws
Exception
{
try
{
logger
.
info
(
"【自动化】虚拟商品兑换需要输入账号-未输入账号-验证"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"186620"
);
response
.
prettyPrint
();
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
logger
.
info
(
"exchangeText(马上兑换):"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"\"马上兑换\""
,
"页面数据返回错误"
);
Assert
.
assertEquals
(
response
.
asString
().
contains
(
"充值账号"
),
true
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange2
(
authorization
.
dafuwengLogin
(
uid
),
"186620"
,
"123"
);
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
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
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
logger
.
info
(
"exchangeText"
+
exchangeText
);
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
logger
.
info
(
"message"
+
message
);
Assert
.
assertEquals
(
message
,(
"请输入账号"
),
"接口数据返回数据返回错误"
);
logger
.
info
(
"自动化】虚拟商品兑换需要输入账号-未输入账号-完成"
);
}
catch
(
Exception
e
)
{
e
.
toString
();
logger
.
info
(
e
.
toString
());
}
}
@Test
(
description
=
"自动化】虚拟商品日期兑换时间进行中"
)
public
void
虚拟商品日期兑换时间进行中
()
throws
Exception
{
logger
.
info
(
"【自动化】虚拟商品日期兑换时间进行中开始验证"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"186618"
);
response
.
prettyPrint
();
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
logger
.
info
(
"exchangeText:"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"\"马上兑换\""
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange2
(
authorization
.
dafuwengLogin
(
uid
),
"186618"
,
"123"
);
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
String
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
logger
.
info
(
"message"
+
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
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
resultResponse
.
prettyPrint
();
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
//异步接口,直到兑换成功
int
n
=
10
;
while
(
n
>
0
&&
"处理中"
.
equals
(
exchangeText
))
{
Thread
.
sleep
(
1000
);
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
resultResponse
.
prettyPrint
();
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
n
--;
}
logger
.
info
(
"exchangeText"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"兑换成功"
,
"页面数据返回错误"
);
logger
.
info
(
"【自动化】虚拟商品日期兑换时间进行中开始结束"
);
}
// @Test(description = "【自动化】虚拟商品兑换需输入账号-已输入账号,兑换验证-验证")
public
void
虚拟商品兑换需要输入账号已输入账号兑换验证信息验证
()
throws
Exception
{
try
{
logger
.
info
(
"虚拟商品兑换需要输入账号已输入账号兑换验证信息验证"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"186620"
);
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
uid
,
true
);
response
.
prettyPrint
();
//,"exchangeText":"马上兑换",
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
logger
.
info
(
"exchangeText(马上兑换):"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"\"马上兑换\""
,
"页面数据返回错误"
);
Assert
.
assertEquals
(
response
.
asString
().
contains
(
"充值账号"
),
true
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange
(
authorization
.
dafuwengLogin
(
uid
),
"186620"
,
"123"
);
//获取orderId
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
logger
.
info
(
"orderid:"
+
orderId
);
response
=
mobileService
.
orderAmbStatusQuery
(
uid
,
orderId
);
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
resultResponse
=
crecordService
.
recordDetailNew
(
orderId
,
uid
);
exchangeText
=
MatcherString
.
getString
(
resultResponse
.
asString
(),
"\"exchangeStatusText\":\"(.*?)\","
,
1
);
logger
.
info
(
"exchangeText"
+
exchangeText
);
}
catch
(
Exception
e
)
{
e
.
toString
();
logger
.
info
(
e
.
toString
());
logger
.
info
(
"【自动化】虚拟商品日期兑换时间已经结束验证完成"
);
}
}
@Test
(
description
=
"自动下架时间,下架后无法兑换"
)
public
void
自动下架时间下架后无法兑换
()
throws
Exception
{
logger
.
info
(
"自动下架时间,下架后无法兑换开始"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
//商品详情页面
Response
response
=
mobileService
.
appItemDetail
(
authorization
.
dafuwengLogin
(
uid
),
"186459"
);
response
.
prettyPrint
();
String
exchangeText
=
MatcherString
.
getString
(
response
.
asString
(),
"\"exchangeText\":(.*?),"
,
1
);
logger
.
info
(
"exchangeText:"
+
exchangeText
);
Assert
.
assertEquals
(
exchangeText
,
"\"已下架\""
,
"页面数据返回错误"
);
logger
.
info
(
"校验 页面数据文本信息 成功"
);
//自有虚拟商品兑换
response
=
virtualExchangeService
.
exchange2
(
authorization
.
dafuwengLogin
(
uid
),
"186459"
,
"123"
);
String
message
=
response
.
jsonPath
().
getString
(
"message"
);
logger
.
info
(
"message"
+
message
);
Assert
.
assertEquals
(
message
,(
"商品已下架,挑选其他吧(8)"
),
"接口数据返回数据返回错误"
);
logger
.
info
(
"自动下架时间下架后无法兑换()完成"
);
}
}
src/test/java/http/service/app/VirtualExchangeService.java
View file @
c73bf836
...
...
@@ -42,4 +42,26 @@ public class VirtualExchangeService {
return
response
;
}
public
Response
exchange2
(
Map
cookies
,
String
appItemId
,
String
degreeId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
appItemId
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"token"
,
"xz9eyi"
);
logger
.
info
(
"请求/virtualExchange/exchange接口"
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
cookies
).
params
(
map
).
post
(
"http://"
+
goodsHost
+
"/virtualExchange/exchange"
);
//couponExchange
try
{
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"/objectExchange/exchange接口返回异常"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/objectExchange/exchange接口返回异常,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/objectExchange/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