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
efcd6009
Commit
efcd6009
authored
Mar 26, 2019
by
马博
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
7806a43e
b6edaaaa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
391 additions
and
4 deletions
+391
-4
Database.java
src/test/java/http/cases/ExchangeTest/Database.java
+2
-0
兑吧新实物_兑换流程测试_ExchangeTest.java
...va/http/cases/ExchangeTest/兑吧新实物_兑换流程测试_ExchangeTest.java
+344
-4
gawService.java
src/test/java/http/service/app/gawService.java
+45
-0
No files found.
src/test/java/http/cases/ExchangeTest/Database.java
View file @
efcd6009
...
...
@@ -14,4 +14,6 @@ public class Database {
public
static
String
orders7
=
"orders_0211"
;
public
static
String
orders8
=
"orders_0090"
;
public
static
String
orders9
=
"orders_0203"
;
public
static
String
orders10
=
"orders_0411"
;
}
src/test/java/http/cases/ExchangeTest/兑吧新实物_兑换流程测试_ExchangeTest.java
View file @
efcd6009
...
...
@@ -42,17 +42,30 @@ public class 兑吧新实物_兑换流程测试_ExchangeTest extends CheckTemple
@Autowired
Authorization
authorization
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
int
uid
=
6866
;
@DataProvider
public
Object
[][]
providerMethod
(
Method
method
)
{
Object
[][]
result
=
null
;
if
(
method
.
getName
().
equals
(
"日期兑换限制测试"
))
{
result
=
new
Object
[][]{
new
Object
[]{
1
,
"193805"
,
"32506"
,
"兑吧新实物日期兑换限制未开始"
},
//case1
new
Object
[]{
2
,
"193806"
,
"32507"
,
"兑吧新实物日期兑换限制进行中"
},
//case2
new
Object
[]{
3
,
"193807"
,
"32508"
,
"兑吧新实物日期兑换限制已结束"
},
//case3
};
}
return
result
;
}
@Test
(
description
=
"兑吧新实物每人限购每日限制"
)
@Test
(
description
=
"兑吧新实物每人限购每日"
)
public
void
每人限购每日限制测试
()
throws
Exception
{
String
appItemId
=
"192950"
;
String
itemId
=
"32439"
;
String
message
=
""
;
try
{
//第一次兑换
Response
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
String
orderId
=
response
.
jsonPath
().
getString
(
"data.orderId"
);
...
...
@@ -60,7 +73,16 @@ public class 兑吧新实物_兑换流程测试_ExchangeTest extends CheckTemple
response
=
tawService
.
orderStatus
(
orderId
,
uid
);
response
.
prettyPrint
();
String
status
=
response
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"wait_delivery"
);
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
--;
}
Assert
.
assertEquals
(
status
,
"wait_delivery"
,
"校验轮询结果status失败"
);
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
...
...
@@ -81,7 +103,7 @@ public class 兑吧新实物_兑换流程测试_ExchangeTest extends CheckTemple
Assert
.
assertTrue
(
message
.
contains
(
"\"success\":false"
),
"校验success失败"
);
Assert
.
assertEquals
(
exchangeText
,
"今日已达兑换上限"
,
"校验兑换按钮失败"
);
logger
.
info
(
"校验实物
用户每日限制消费
成功"
);
logger
.
info
(
"校验实物
每人限购每日限制
成功"
);
}
catch
(
Exception
e
){
...
...
@@ -96,6 +118,324 @@ public class 兑吧新实物_兑换流程测试_ExchangeTest extends CheckTemple
}
@Test
(
description
=
"兑吧新实物每人限购永久"
)
public
void
每人限购永久限制测试
()
throws
Exception
{
String
appItemId
=
"193756"
;
String
itemId
=
"32500"
;
String
message
=
""
;
try
{
//第一次兑换
Response
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
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
--;
}
Assert
.
assertEquals
(
status
,
"wait_delivery"
,
"校验轮询结果status失败"
);
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"商品兑换按钮:"
+
exchangeText
);
//第二次兑换
Thread
.
sleep
(
3000
);
try
{
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
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
+
"'"
);
}
}
@Test
(
description
=
"兑吧新实物每人限购周期"
)
public
void
每人限购周期限制测试
()
throws
Exception
{
String
appItemId
=
"193757"
;
String
itemId
=
"32501"
;
String
message
=
""
;
try
{
//第一次兑换
Response
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
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
--;
}
Assert
.
assertEquals
(
status
,
"wait_delivery"
,
"校验轮询结果status失败"
);
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"商品兑换按钮:"
+
exchangeText
);
//第二次兑换
Thread
.
sleep
(
3000
);
try
{
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
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
+
"'"
);
}
}
@Test
(
description
=
"兑吧新实物每日限量"
)
public
void
每日限量测试
()
throws
Exception
{
String
appItemId
=
"193801"
;
String
itemId
=
"32505"
;
String
message
=
""
;
try
{
//第一次兑换
Response
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
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
--;
}
Assert
.
assertEquals
(
status
,
"wait_delivery"
,
"校验轮询结果status失败"
);
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"商品兑换按钮:"
+
exchangeText
);
//第二次兑换
Thread
.
sleep
(
3000
);
try
{
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
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 goods.tb_everyday_limit WHERE item_id = '"
+
itemId
+
"'"
);
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test
(
dataProvider
=
"providerMethod"
)
public
void
日期兑换限制测试
(
int
caseNum
,
String
appItemId
,
String
itemId
,
String
caseName
)
throws
Exception
{
String
message
=
""
;
logger
.
info
(
caseName
);
//兑换
try
{
Response
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
message
);
//获取按钮状态
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"商品兑换按钮:"
+
exchangeText
);
switch
(
caseNum
){
case
1
:
Assert
.
assertTrue
(
message
.
contains
(
"限2021-04-01至2021-04-08日期内兑换"
),
"校验message失败"
);
Assert
.
assertEquals
(
exchangeText
,
"限2021-04-01至2021-04-08日期内兑换"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验实物日期兑换限制未开始成功"
);
break
;
case
2
:
Assert
.
assertTrue
(
message
.
contains
(
""
),
"校验message失败"
);
Assert
.
assertEquals
(
exchangeText
,
"马上兑换"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验实物日期兑换限制进行中成功"
);
break
;
case
3
:
Assert
.
assertTrue
(
message
.
contains
(
"限2019-03-20至2019-03-20日期内兑换"
),
"校验日期兑换限制失败"
);
Assert
.
assertEquals
(
exchangeText
,
"限2019-03-20至2019-03-20日期内兑换"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验实物日期兑换限制已结束成功"
);
break
;
}
}
@Test
(
description
=
"兑吧新实物会员等级限制"
)
public
void
会员等级测试
()
throws
Exception
{
String
appItemId
=
"193808"
;
String
itemId
=
"32509"
;
String
message
=
""
;
//会员等级无法兑换
try
{
Response
response
=
gawService
.
objectExchange
(
uid
,
appItemId
,
itemId
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
message
);
//会员等级可兑换,vip=5
Response
response
=
gawService
.
objectExchange
(
authorization
.
generateSignAutoLogin
(
"vc2HvzM439YBQiB6LVy4uxC4uWm"
,
7001
),
appItemId
,
itemId
,
"16"
);
response
.
prettyPrint
();
Assert
.
assertTrue
(
message
.
contains
(
"未达到会员等级要求"
),
"校验message失败"
);
Assert
.
assertTrue
(
message
.
contains
(
"\"success\":false"
),
"校验success失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"校验兑换结果失败"
);
logger
.
info
(
"校验实物会员等级成功"
);
}
@Test
(
description
=
"兑吧新实物可售库存不足"
)
public
void
可售库存不足测试
()
throws
Exception
{
String
appItemId
=
"193840"
;
String
itemId
=
"32511"
;
String
skuId
=
"37"
;
String
message
=
""
;
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
//无库存兑换
try
{
Response
response
=
gawService
.
objectExchange
(
cookies
,
appItemId
,
itemId
,
skuId
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
message
);
Assert
.
assertTrue
(
message
.
contains
(
"商品售罄"
),
"校验message失败"
);
Assert
.
assertTrue
(
message
.
contains
(
"\"success\":false"
),
"校验message失败"
);
logger
.
info
(
"校验兑吧新实物可售库存不足成功"
);
}
@Test
(
description
=
"兑吧新实物SKU库存不足"
)
public
void
SKU
库存不足测试
()
throws
Exception
{
String
appItemId
=
"193839"
;
String
itemId
=
"32510"
;
String
skuId
=
"34"
;
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
Response
response
=
gawService
.
objectExchange
(
cookies
,
appItemId
,
itemId
,
skuId
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data.orderId"
);
logger
.
info
(
"订单号:"
+
orderId
);
Map
<
String
,
Object
>
mapOrder
=
jdbc
.
findSimpleResult
(
"SELECT * FROM "
+
Database
.
orders_consumer
+
"."
+
Database
.
orders10
+
" WHERE id = "
+
orderId
);
String
flowWork
=
String
.
valueOf
(
mapOrder
.
get
(
"flowwork_stage"
));
String
status
=
String
.
valueOf
(
mapOrder
.
get
(
"status"
));
logger
.
info
(
"数据库订单节点:"
+
flowWork
);
Assert
.
assertEquals
(
status
,
"create"
,
"校验订单status失败"
);
Assert
.
assertEquals
(
flowWork
,
"Create-tofail"
,
"校验订单节点flowwork失败"
);
logger
.
info
(
"校验兑吧新实物SKU库存不足成功"
);
}
...
...
src/test/java/http/service/app/gawService.java
View file @
efcd6009
...
...
@@ -120,4 +120,49 @@ public class gawService {
}
//sku兑换
public
Response
objectExchange
(
Map
cookies
,
String
appItemId
,
String
itemId
,
String
skuId
)
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
mapList
=
new
HashMap
<>();
List
<
Map
>
list
=
new
ArrayList
<>();
mapList
.
put
(
"itemId"
,
itemId
);
mapList
.
put
(
"skuId"
,
skuId
);
mapList
.
put
(
"appItemId"
,
appItemId
);
mapList
.
put
(
"credits"
,
"100"
);
mapList
.
put
(
"price"
,
0
);
list
.
add
(
mapList
);
map
.
put
(
"remark"
,
""
);
//买家留言
map
.
put
(
"degreeId"
,
""
);
map
.
put
(
"actualPrice"
,
"0"
);
//总金额
map
.
put
(
"actualCredits"
,
"100"
);
//总积分
map
.
put
(
"itemParam"
,
list
.
toArray
());
map
.
put
(
"payType"
,
"3"
);
map
.
put
(
"expressPrice"
,
"0"
);
map
.
put
(
"validate"
,
""
);
map
.
put
(
"token"
,
"yrJRr7Cddp2YeQd"
);
JSONObject
jsonParam
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
map
));
logger
.
info
(
"请求实物兑换接口:"
+
"/gaw/objectExchange/create"
);
Response
response
=
given
().
contentType
(
"application/json; charset=UTF-8"
).
cookies
(
cookies
).
body
(
jsonParam
).
post
(
"http://"
+
goodsHost
+
"/gaw/objectExchange/create"
);
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
// response.prettyPrint();
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/gaw/objectExchange/create接口返回异常,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/gaw/objectExchange/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