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
86a3ba5f
Commit
86a3ba5f
authored
Feb 22, 2019
by
赵然
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zr' into develop
parents
06f12af5
4b4bd954
Changes
32
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
1939 additions
and
70 deletions
+1939
-70
优惠券测试.java
src/test/java/http/cases/ActivityReconTest/优惠券测试.java
+129
-0
全局红包账户.java
src/test/java/http/cases/ActivityReconTest/全局红包账户.java
+71
-0
出奖订单测试.java
src/test/java/http/cases/ActivityReconTest/出奖订单测试.java
+0
-0
多奖项中奖限制.java
src/test/java/http/cases/ActivityReconTest/多奖项中奖限制.java
+99
-0
奖品发放限制.java
src/test/java/http/cases/ActivityReconTest/奖品发放限制.java
+123
-0
扣库存测试.java
src/test/java/http/cases/ActivityReconTest/扣库存测试.java
+0
-0
抽奖异常测试.java
src/test/java/http/cases/ActivityReconTest/抽奖异常测试.java
+0
-0
新活动工具测试.java
src/test/java/http/cases/ActivityReconTest/新活动工具测试.java
+150
-0
无积分测试.java
src/test/java/http/cases/ActivityReconTest/无积分测试.java
+118
-0
自有_活动中奖限制.java
src/test/java/http/cases/ActivityReconTest/自有_活动中奖限制.java
+77
-0
自有_活动次数测试.java
src/test/java/http/cases/ActivityReconTest/自有_活动次数测试.java
+82
-0
自有_独立活动测试.java
src/test/java/http/cases/ActivityReconTest/自有_独立活动测试.java
+70
-0
自有_自有活动出奖.java
src/test/java/http/cases/ActivityReconTest/自有_自有活动出奖.java
+0
-0
谢谢参与测试.java
src/test/java/http/cases/ActivityReconTest/谢谢参与测试.java
+66
-0
Exchange_ExchangeTest.java
...t/java/http/cases/ExchangeTest/Exchange_ExchangeTest.java
+1
-1
ObjectExchange_ExchangeTest.java
.../http/cases/ExchangeTest/ObjectExchange_ExchangeTest.java
+3
-3
Qb_兑换流程测试_ExchangeTest.java
.../java/http/cases/ExchangeTest/Qb_兑换流程测试_ExchangeTest.java
+1
-1
优惠券_兑换流程测试_ExchangeTest.java
...java/http/cases/ExchangeTest/优惠券_兑换流程测试_ExchangeTest.java
+18
-18
商品订单失败测试_ExchangeTest.java
...t/java/http/cases/ExchangeTest/商品订单失败测试_ExchangeTest.java
+1
-1
实物_兑换异常测试_ExchangeTest.java
.../java/http/cases/ExchangeTest/实物_兑换异常测试_ExchangeTest.java
+5
-5
平台券_兑换流程测试_ExchangeTest.java
...java/http/cases/ExchangeTest/平台券_兑换流程测试_ExchangeTest.java
+6
-6
支付宝_兑换流程测试_ExchangeTest.java
...java/http/cases/ExchangeTest/支付宝_兑换流程测试_ExchangeTest.java
+4
-4
虚拟商品_兑换异常测试_ExchangeTest.java
...ava/http/cases/ExchangeTest/虚拟商品_兑换异常测试_ExchangeTest.java
+2
-2
异常订单测试_ExchangeTest.java
...ava/http/cases/GoodsAndTradeTest/异常订单测试_ExchangeTest.java
+4
-4
抽奖异常测试_DuibaTest.java
...est/java/http/cases/NewActivityTest/抽奖异常测试_DuibaTest.java
+23
-13
ActivityReconService.java
...test/java/http/service/Activity/ActivityReconService.java
+855
-0
NewActivityService.java
src/test/java/http/service/Activity/NewActivityService.java
+19
-0
AlipayExchangeService.java
src/test/java/http/service/app/AlipayExchangeService.java
+1
-1
AppPlatformCouponService.java
src/test/java/http/service/app/AppPlatformCouponService.java
+1
-1
CouponExchangeService.java
src/test/java/http/service/app/CouponExchangeService.java
+6
-6
QbExchangeService.java
src/test/java/http/service/app/QbExchangeService.java
+2
-2
VirtualExchangeService.java
src/test/java/http/service/app/VirtualExchangeService.java
+2
-2
No files found.
src/test/java/http/cases/ActivityReconTest/优惠券测试.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.Config
;
import
base.DuibaLog
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
;
import
org.testng.Assert
;
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.util.Iterator
;
import
java.util.Map
;
/**
* Created by zhaoran on 2019/2/21
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
优惠券测试
extends
AbstractTestNGSpringContextTests
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
ManagerService
managerService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
@DataProvider
public
Iterator
<
Object
[]>
providerMethod
(
Method
method
)
throws
IOException
{
Iterator
<
Object
[]>
result
=
null
;
if
(
method
.
getName
().
equals
(
"优惠券测试"
))
{
result
=
new
ExcelDataProvider
(
"duiba/活动优惠券"
);
}
return
result
;
}
@Test
(
dataProvider
=
"providerMethod"
)
public
void
优惠券测试
(
Map
<
String
,
String
>
data
)
throws
Exception
{
Thread
.
sleep
(
2000
);
logger
.
info
(
"-------------------------------------"
+
data
.
get
(
"casename"
)+
"-------------------------------------"
);
//获取管理员后台优惠券待校验项
Response
ManagerResponse
=
managerService
.
CouponConfig
(
data
.
get
(
"couponId"
));
Response
LinkResponse
=
managerService
.
ShowCoupons
(
data
.
get
(
"couponId"
));
String
acttitle
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"name=\"name\" value=\"(.*?)\">"
,
1
);
String
androidDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"androidurl: '(.*?)',"
,
1
);
String
iOSDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"iosurl: '(.*?)',"
,
1
);
String
actusebtn
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"usebtn: '(.*?)',"
,
1
);
String
actLinkEx
=
"//activity.m.duibatest.com.cn/crecord/recordDetailNew"
;
String
linkUrl
=
MatcherString
.
getString
(
LinkResponse
.
asString
(),
"target=\"_blank\" href=\"(.*?)\">"
,
1
);
//获取管理员后台优惠券库存
String
remind
=
MatcherString
.
getString
(
LinkResponse
.
asString
(),
"option remain=\"(.*?)\""
,
1
);
logger
.
info
(
"抽奖前当前库存:"
+
remind
);
//扣去1库存
remind
=
String
.
valueOf
(
Integer
.
valueOf
(
remind
)-
1
);
//进行接口测试传参
Response
response
=
this
.
新活动工具接口传参
(
data
.
get
(
"activityId"
),
data
.
get
(
"token"
),
data
.
get
(
"device"
));
// response.prettyPrint();
//根据case选择对应的校验项
int
casenum
=
Integer
.
parseInt
(
data
.
get
(
"casenum"
));
switch
(
casenum
){
case
1
:
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.iosDownloadUrl"
),
linkUrl
,
"校验Url失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
),
actusebtn
,
"校验useBtnText失败"
);
logger
.
info
(
"校验链接券码项:openUrl,useBtnText成功"
);
break
;
case
2
:
if
(
data
.
get
(
"device"
).
equals
(
"iOS"
))
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.iosDownloadUrl"
),
iOSDL
,
"校验Url失败"
);
}
else
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.androidDownloadUrl"
),
androidDL
,
"校验Url失败"
);
}
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
),
actusebtn
,
"校验useBtnText失败"
);
logger
.
info
(
"校验商家落地项:openUrl,useBtnText成功"
);
break
;
case
3
:
Assert
.
assertTrue
(
response
.
jsonPath
().
getString
(
"data.lottery.iosDownloadUrl"
).
contains
(
actLinkEx
),
"兑换记录页url与实际url不匹配"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
),
"查看使用方法"
,
"校验useBtnText失败"
);
logger
.
info
(
"校验兑换记录项:openUrl,useBtnText成功"
);
break
;
}
//通用校验项
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.title"
),
acttitle
,
"校验title失败"
);
logger
.
info
(
"校验通用项:title成功"
);
//获取管理员后台优惠券库存
Thread
.
sleep
(
5000
);
Response
LinkResponse2
=
managerService
.
ShowCoupons
(
data
.
get
(
"couponId"
));
String
Newremind
=
MatcherString
.
getString
(
LinkResponse2
.
asString
(),
"option remain=\"(.*?)\""
,
1
);
logger
.
info
(
"抽奖后当前库存:"
+
Newremind
);
//校验比较,抽奖前后优惠券库存
Assert
.
assertEquals
(
Newremind
,
remind
);
logger
.
info
(
"校验抽奖前后库存正确"
);
}
public
Response
新活动工具接口传参
(
String
activityId
,
String
token
,
String
device
)
throws
Exception
{
Response
response
=
activityReconService
.
doJoin2
(
activityId
,
token
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
response
.
prettyPrint
();
String
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
int
i
=
30
;
while
(
i
>
0
&&(
result
.
equals
(
"C000000001"
))){
Thread
.
sleep
(
1000
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
i
--;
response
.
prettyPrint
();
}
return
response
;
}
}
\ No newline at end of file
src/test/java/http/cases/ActivityReconTest/全局红包账户.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.DuibaLog
;
import
base.DuibaTestBase
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.util.Map
;
/**
* Created by zhaoran on 2018/9/21
*/
public
class
全局红包账户
extends
DuibaTestBase
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
ManagerService
managerService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
@Test
public
void
全局红包测试
()
throws
Exception
{
Map
<
String
,
Object
>
selectResult
=
jdbc
.
findSimpleResult
(
"select * from consumer_accounts.tb_consumer_account_0687 where account_id = '100025007_0_0' "
);
int
balance
=
Integer
.
parseInt
(
String
.
valueOf
(
selectResult
.
get
(
"balance_amount"
)));
logger
.
info
(
"账户原有余额为"
+
balance
);
//进行接口测试传参
Response
response
=
this
.
新活动工具接口传参
(
"32696"
,
"7ywbta5"
,
"iOS"
);
// response.prettyPrint();
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.bonusMax"
),
"50"
,
"校验红包最大值失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.bonusMin"
),
"10"
,
"校验红包最小值失败"
);
int
bonus
=
Integer
.
parseInt
(
response
.
jsonPath
().
getString
(
"data.lottery.bonus"
));
logger
.
info
(
"中奖金额为"
+
bonus
);
balance
=
balance
+
bonus
;
logger
.
info
(
"预期余额为"
+
balance
);
selectResult
=
jdbc
.
findSimpleResult
(
"select * from consumer_accounts.tb_consumer_account_0687 where account_id = '100025007_0_0' "
);
int
balanceNew
=
Integer
.
parseInt
(
String
.
valueOf
(
selectResult
.
get
(
"balance_amount"
)));
logger
.
info
(
"实际余额为"
+
balanceNew
);
Assert
.
assertEquals
(
balanceNew
,
balance
,
"全局红包增加账户余额失败"
);
}
public
Response
新活动工具接口传参
(
String
activityId
,
String
token
,
String
device
)
throws
Exception
{
Response
response
=
activityReconService
.
doJoin2
(
activityId
,
token
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
response
.
prettyPrint
();
String
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
int
i
=
30
;
while
(
i
>
0
&&(
result
.
equals
(
"C000000001"
))){
Thread
.
sleep
(
1000
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
i
--;
response
.
prettyPrint
();
}
return
response
;
}
}
\ No newline at end of file
src/test/java/http/cases/ActivityReconTest/出奖订单测试.java
0 → 100644
View file @
86a3ba5f
This diff is collapsed.
Click to expand it.
src/test/java/http/cases/ActivityReconTest/多奖项中奖限制.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.DuibaTestBase
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
http.service.hd.ActivityService
;
import
http.service.hd.CustomHdToolCtrlService
;
import
http.service.hd.DeveloperService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.Test
;
import
utils.RedisUtil
;
/**
* Created by zhaoran on 2018/07/10
*/
public
class
多奖项中奖限制
extends
DuibaTestBase
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
ManagerService
managerService
;
@Autowired
DeveloperService
developerService
;
@Autowired
CustomHdToolCtrlService
customHdToolCtrlService
;
@Autowired
ActivityService
activityService
;
@AfterClass
public
void
after
()
throws
Exception
{
//数据库删除
try
{
//case:[多奖项中奖限制测试_永久]数据处理:删除永久中奖记录
jdbc
.
update
(
"UPDATE ckvtable.tb_kvtable_0687 SET int_value = '0' WHERE vkey = 'activity-centerwinOptionNum_100025007_35869_hdtool25885'"
);
//case:[多奖项中奖限制测试_每日]数据处理:删除每日中奖记录
RedisUtil
.
clearKey
(
"PRIZE_K004_35934_100025007"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
}
}
@Test
public
void
多奖项中奖限制测试
_
永久
()
throws
Exception
{
//第一次抽奖
Response
response
=
this
.
新活动工具接口传参
(
"35869"
,
"adsdas"
,
"iOS"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
)),
"phonebill"
,
"第一次抽奖出奖类型失败"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.title"
)),
"话费"
,
"第一次抽奖出奖title失败"
);
//第二次抽奖
response
=
this
.
新活动工具接口传参
(
"35869"
,
"adsdas"
,
"iOS"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
)),
"lucky"
,
"第二次抽奖出奖类型失败"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
)),
"马上使用"
,
"第二次抽奖出奖文案失败"
);
}
@Test
public
void
多奖项中奖限制测试
_
每日
()
throws
Exception
{
//第一次抽奖
Response
response
=
this
.
新活动工具接口传参
(
"35934"
,
"adsdas"
,
"iOS"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
)),
"phonebill"
,
"第一次抽奖出奖类型失败"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.title"
)),
"话费"
,
"第一次抽奖出奖title失败"
);
//第二次抽奖
response
=
this
.
新活动工具接口传参
(
"35934"
,
"adsdas"
,
"iOS"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
)),
"lucky"
,
"第二次抽奖出奖类型失败"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
)),
"马上使用"
,
"第二次抽奖出奖文案失败"
);
}
public
Response
新活动工具接口传参
(
String
activityId
,
String
token
,
String
device
)
throws
Exception
{
Response
response
=
activityReconService
.
doJoin2
(
activityId
,
token
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
response
.
prettyPrint
();
String
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
int
i
=
8
;
while
(
i
>
0
&&(
result
.
equals
(
"0"
))){
Thread
.
sleep
(
1000
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
i
--;
response
.
prettyPrint
();
}
return
response
;
}
}
\ No newline at end of file
src/test/java/http/cases/ActivityReconTest/奖品发放限制.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.DuibaLog
;
import
base.DuibaTestBase
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
http.service.hd.ActivityService
;
import
http.service.hd.CustomHdToolCtrlService
;
import
http.service.hd.DeveloperService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.Test
;
import
utils.HbaseService
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Locale
;
/**
* Created by zhaoran on 2018/07/10
*/
public
class
奖品发放限制
extends
DuibaTestBase
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
ManagerService
managerService
;
@Autowired
DeveloperService
developerService
;
@Autowired
CustomHdToolCtrlService
customHdToolCtrlService
;
@Autowired
ActivityService
activityService
;
@Autowired
HbaseService
hbaseService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
@AfterClass
public
void
after
()
throws
Exception
{
//数据库删除
try
{
//case:[奖品发放限制测试_永久]数据处理:删除永久中奖记录
jdbc
.
update
(
"UPDATE ckvtable.tb_kvtable_0687 SET int_value = '0' WHERE vkey = 'activity-centerwinOptionNum_100025007_35868_hdtool25884'"
);
//case:[奖品发放限制测试_每日]数据处理:删除每日中奖记录
String
y_m_d
=
getTime2
(
0
);
String
key
=
"k05_PRIZE_K001_"
+
y_m_d
+
"_hdtool25933_100025007"
;
hbaseService
.
deleteHBASEKey2
(
key
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
}
}
@Test
public
void
奖品发放限制测试
_
永久
()
throws
Exception
{
//第一次抽奖
Response
response
=
this
.
新活动工具接口传参
(
"35868"
,
"adsdas"
,
"iOS"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
)),
"phonebill"
,
"第一次抽奖出奖类型失败"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.title"
)),
"话费"
,
"第一次抽奖出奖title失败"
);
//第二次抽奖
response
=
this
.
新活动工具接口传参
(
"35868"
,
"adsdas"
,
"iOS"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
)),
"lucky"
,
"第一次抽奖出奖类型失败"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
)),
"马上使用"
,
"第一次抽奖出奖文案失败"
);
}
@Test
public
void
奖品发放限制测试
_
每日
()
throws
Exception
{
//第一次抽奖
Response
response
=
this
.
新活动工具接口传参
(
"35920"
,
"adsdas"
,
"iOS"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
)),
"phonebill"
,
"第一次抽奖出奖类型失败,请考虑是否activity-access-web发布了master分支所导致"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.title"
)),
"话费"
,
"第一次抽奖出奖title失败"
);
//第二次抽奖
response
=
this
.
新活动工具接口传参
(
"35920"
,
"adsdas"
,
"iOS"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
)),
"lucky"
,
"第一次抽奖出奖类型失败"
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
)),
"马上使用"
,
"第一次抽奖出奖文案失败"
);
}
public
Response
新活动工具接口传参
(
String
activityId
,
String
token
,
String
device
)
throws
Exception
{
Response
response
=
activityReconService
.
doJoin2
(
activityId
,
token
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
response
.
prettyPrint
();
String
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
int
i
=
30
;
while
(
i
>
0
&&(
result
.
equals
(
"C000000001"
))){
Thread
.
sleep
(
1000
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
i
--;
response
.
prettyPrint
();
}
return
response
;
}
public
String
getTime2
(
int
amount
){
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"YYYY-MM-dd"
,
Locale
.
ENGLISH
);
Date
date
=
new
Date
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
amount
);
date
=
calendar
.
getTime
();
// System.out.println(dateFormat.format(date));
String
time
=
dateFormat
.
format
(
date
);
// System.out.println(time);
return
time
;
}
}
\ No newline at end of file
src/test/java/http/cases/ActivityReconTest/扣库存测试.java
0 → 100644
View file @
86a3ba5f
This diff is collapsed.
Click to expand it.
src/test/java/http/cases/ActivityReconTest/抽奖异常测试.java
0 → 100644
View file @
86a3ba5f
This diff is collapsed.
Click to expand it.
src/test/java/http/cases/ActivityReconTest/新活动工具测试.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.DuibaLog
;
import
base.DuibaTestBase
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
http.service.hd.ActivityService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.math.BigDecimal
;
import
java.util.Map
;
/**
* Created by zhaoran on 2018/1/2
*/
public
class
新活动工具测试
extends
DuibaTestBase
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
ManagerService
managerService
;
@Autowired
ActivityService
activityService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
private
static
int
uid
=
4259
;
@Test
public
void
福袋商品测试
()
throws
Exception
{
logger
.
info
(
"-------------------------------------活动中奖福袋商品-------------------------------------"
);
Response
response
=
this
.
新活动工具接口传参
(
uid
,
"18567"
,
"1gffs6mq3"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
),
"lucky"
,
"校验类型失败"
);
Assert
.
assertTrue
(
response
.
jsonPath
().
getString
(
"data.lottery.link"
).
contains
(
"//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"
));
Assert
.
assertTrue
(
response
.
jsonPath
().
getString
(
"data.lottery.iosDownloadUrl"
).
contains
(
"activityId=18567"
));
Assert
.
assertTrue
(
response
.
jsonPath
().
getString
(
"data.lottery.iosDownloadUrl"
).
contains
(
"//activity.tuiatest.cn/activity/redirect"
));
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.id"
),
"11587"
,
"校验id失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.showUse"
),
"true"
,
"校验显示按钮失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
),
"马上使用"
,
"校验useBtnText失败"
);
logger
.
info
(
"校验福袋:link,id,useBtnText成功"
);
}
@Test
public
void
谢谢参与转福袋测试
()
throws
Exception
{
logger
.
info
(
"-------------------------------------活动中奖谢谢参与转福袋-------------------------------------"
);
Response
response
=
this
.
新活动工具接口传参
(
uid
,
"26640"
,
"1gffs6mq3"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.isAppLucky"
),
"true"
,
"校验是否安慰奖失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
),
"lucky"
,
"校验类型失败"
);
Assert
.
assertTrue
(
response
.
jsonPath
().
getString
(
"data.lottery.link"
).
contains
(
"//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"
));
Assert
.
assertTrue
(
response
.
jsonPath
().
getString
(
"data.lottery.iosDownloadUrl"
).
contains
(
"activityId=26640"
));
Assert
.
assertTrue
(
response
.
jsonPath
().
getString
(
"data.lottery.iosDownloadUrl"
).
contains
(
"//activity.tuiatest.cn/activity/redirect"
));
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.showUse"
),
"true"
,
"校验显示按钮失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
),
"马上使用"
,
"校验useBtnText失败"
);
logger
.
info
(
"校验福袋:link,id,useBtnText成功"
);
}
@Test
public
void
免费次数测试
()
throws
Exception
{
Response
response1
=
activityReconService
.
ajaxElement
(
uid
,
"3251"
,
"19114"
);
String
freeLimit
=
String
.
valueOf
(
response1
.
jsonPath
().
getString
(
"data.element.freeLimit"
));
logger
.
info
(
"抽奖前剩余免费抽奖次数:"
+
freeLimit
);
freeLimit
=
String
.
valueOf
(
Integer
.
valueOf
(
freeLimit
)-
1
);
Response
response
=
this
.
新活动工具接口传参
(
uid
,
"19114"
,
"ogw24k6ns"
);
Thread
.
sleep
(
1000
);
Response
response2
=
activityReconService
.
ajaxElement
(
uid
,
"3251"
,
"19114"
);
String
freeLimitNew
=
String
.
valueOf
(
response2
.
jsonPath
().
getString
(
"data.element.freeLimit"
));
logger
.
info
(
"抽奖后剩余免费抽奖次数:"
+
freeLimitNew
);
//校验比较,抽奖前后积分
Assert
.
assertEquals
(
freeLimitNew
,
freeLimit
);
logger
.
info
(
"校验抽奖前后剩余次数正确"
);
}
@Test
public
void
再抽一次测试
()
throws
Exception
{
//查询数据库,当前积分(抽奖扣积分流程校验)
Map
<
String
,
Object
>
mapuser
=
jdbc
.
findSimpleResult
(
"select * from dafuweng.user where id="
+
uid
);
String
credits
=
String
.
valueOf
(
mapuser
.
get
(
"credits"
));
logger
.
info
(
"抽奖前积分:"
+
credits
);
//扣去1积分
credits
=
String
.
valueOf
(
Integer
.
valueOf
(
credits
)-
1
);
//第一次抽奖
Response
response
=
this
.
新活动工具接口传参
(
uid
,
"18580"
,
"m8rhchc"
);
response
.
print
();
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
),
"again"
,
"校验type失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.id"
),
"11608"
,
"校验id失败"
);
//Assert.assertEquals(response.jsonPath().getString("result"), "3", "校验result失败");
logger
.
info
(
"校验:type,id,result成功"
);
//第一次抽奖后查询数据库,获取当前积分
mapuser
=
jdbc
.
findSimpleResult
(
"select * from dafuweng.user where id="
+
uid
);
String
creditsNew
=
String
.
valueOf
(
mapuser
.
get
(
"credits"
));
logger
.
info
(
"第一次抽奖后积分:"
+
creditsNew
);
//校验比较,抽奖前后积分
Assert
.
assertEquals
(
credits
,
creditsNew
);
logger
.
info
(
"校验第一次抽奖前后积分正确"
);
//第二次抽奖
response
=
activityReconService
.
doJoin2
(
uid
,
"18580"
,
"m8rhchc"
,
response
.
jsonPath
().
getString
(
"againTag"
));
response
.
prettyPrint
();
Thread
.
sleep
(
2000
);
//第二次抽奖后查询数据库,获取当前积分
mapuser
=
jdbc
.
findSimpleResult
(
"select * from dafuweng.user where id="
+
uid
);
String
creditsNew2
=
String
.
valueOf
(
mapuser
.
get
(
"credits"
));
logger
.
info
(
"第二次抽奖后积分:"
+
creditsNew2
);
//校验比较,抽奖前后积分
Assert
.
assertEquals
(
creditsNew
,
creditsNew2
);
logger
.
info
(
"校验第二次抽奖前后积分正确"
);
}
public
Response
新活动工具接口传参
(
int
uid
,
String
activityId
,
String
token
)
throws
Exception
{
Response
response
=
activityReconService
.
doJoin2
(
uid
,
activityId
,
token
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
activityReconService
.
getOrderStatus2
(
uid
,
orderId
);
response
.
prettyPrint
();
String
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
int
i
=
30
;
while
(
i
>
0
&&(
result
.
equals
(
"C000000001"
))){
Thread
.
sleep
(
1000
);
response
=
activityReconService
.
getOrderStatus2
(
uid
,
orderId
);
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
i
--;
response
.
prettyPrint
();
}
return
response
;
}
/**
* 提供精确的减法运算。
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public
static
double
sub
(
double
v1
,
double
v2
){
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
return
b1
.
subtract
(
b2
).
doubleValue
();
}
}
\ No newline at end of file
src/test/java/http/cases/ActivityReconTest/无积分测试.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.DuibaLog
;
import
base.DuibaTestBase
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
http.service.Authorization
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by zhaoran on 2018/1/2
*/
public
class
无积分测试
extends
DuibaTestBase
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
ManagerService
managerService
;
@Autowired
Authorization
authorization
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
private
String
url
=
"http://activity.m.duibatest.com.cn"
;
@DataProvider
public
Object
[][]
providerMethod
(
Method
method
){
Object
[][]
result
=
null
;
if
(
method
.
getName
().
equals
(
"参与次数测试"
))
{
result
=
new
Object
[][]{
new
Object
[]{
1
,
"5243"
,
"23105"
,
"永久限制5次,不免费"
},
new
Object
[]{
2
,
"5314"
,
"23314"
,
"无限制,不免费"
},
new
Object
[]{
3
,
"5315"
,
"23315"
,
"无限制,每天免费999"
},
};
}
return
result
;
}
@Test
(
dataProvider
=
"providerMethod"
)
public
void
参与次数测试
(
int
casenum
,
String
hdToolId
,
String
activityId
,
String
casename
)
throws
Exception
{
logger
.
info
(
"-------------------------------------"
+
casename
+
"-------------------------------------"
);
//校验ajax接口关键字段返回
logger
.
info
(
"请求/hdtool/recon/ajaxElement接口"
);
Response
response_ajax
=
this
.
ajaxElement
(
hdToolId
,
activityId
);
Assert
.
assertEquals
(
response_ajax
.
jsonPath
().
getString
(
"data.element.isCreditsTypeOpen"
),
"true"
,
"校验isCreditsTypeOpen失败"
);
logger
.
info
(
"请求/hdtool/recon/doJoin接口"
);
Response
response
=
this
.
doJoin
(
activityId
);
response
.
prettyPrint
();
//根据case选择对应的校验项
switch
(
casenum
){
case
1
:
Assert
.
assertEquals
(
response_ajax
.
jsonPath
().
getString
(
"data.element.status"
),
"4"
,
"校验status失败"
);
logger
.
info
(
"ajax校验项:status成功"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"desc"
),
"没有抽奖次数-限制"
,
"校验message失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"code"
),
"E100202008"
,
"校验status失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"false"
,
"校验success失败"
);
logger
.
info
(
"doJoin校验项:message,status,success成功"
);
break
;
case
2
:
Assert
.
assertEquals
(
response_ajax
.
jsonPath
().
getString
(
"data.element.status"
),
"3"
,
"校验status失败"
);
logger
.
info
(
"ajax校验项:status成功"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"desc"
),
"今日没有抽奖次数-免费"
,
"校验message失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"code"
),
"E100202009"
,
"校验status失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"false"
,
"校验success失败"
);
logger
.
info
(
"doJoin校验项:message,status,success成功"
);
break
;
case
3
:
Assert
.
assertEquals
(
response_ajax
.
jsonPath
().
getString
(
"data.element.status"
),
"5"
,
"校验status失败"
);
logger
.
info
(
"ajax校验项:status成功"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"desc"
),
"OK"
,
"校验needCredits失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"校验success失败"
);
logger
.
info
(
"doJoin校验项:needCredits,success成功"
);
break
;
}
//切换回2720用户
//authorization.dafuwengLogin(2720,true);
}
public
Response
ajaxElement
(
String
hdToolId
,
String
activityId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"duibaId"
,
hdToolId
);
map
.
put
(
"activityId"
,
activityId
);
logger
.
info
(
"请求/hdtool/recon/ajaxElement接口"
);
Response
response_ajax
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
2723
,
true
)).
params
(
map
).
get
(
url
+
"/hdtool/recon/ajaxElement"
);
try
{
Assert
.
assertEquals
(
response_ajax
.
jsonPath
().
getString
(
"success"
),
"true"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/hdtool/recon/ajaxElement接口失败,返回信息:"
+
response_ajax
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/hdtool/recon/ajaxElement接口失败,返回信息:"
+
response_ajax
.
asString
());
}
return
response_ajax
;
}
public
Response
doJoin
(
String
activityId
)
throws
Exception
{
Map
<
String
,
String
>
map2
=
new
HashMap
<>();
map2
.
put
(
"activityId"
,
activityId
);
map2
.
put
(
"token"
,
"1hrja7"
);
logger
.
info
(
"请求/hdtool/ajaxElement接口"
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
2723
)).
params
(
map2
).
post
(
url
+
"/hdtool/recon/doJoin"
);
return
response
;
}
}
\ No newline at end of file
src/test/java/http/cases/ActivityReconTest/自有_活动中奖限制.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.Config
;
import
base.DuibaLog
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
http.service.Activity.SingleLotteryService
;
import
http.service.hd.DeveloperService
;
import
http.service.hd.SigninService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
* Created by zhaoran on 2018/5/19.
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
自有
_
活动中奖限制
extends
AbstractTestNGSpringContextTests
{
@Autowired
SigninService
signinService
;
@Autowired
DeveloperService
developerService
;
@Autowired
ManagerService
managerService
;
@Autowired
ActivityReconService
activityReconService
;
@Autowired
SingleLotteryService
singleLotteryService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
@Test
(
description
=
"自有活动设置中奖限制为1次"
)
public
void
中奖限制
()
throws
Exception
{
//进行接口测试传参
Response
response
=
this
.
自有活动接口传参
(
"21939"
,
"abcde"
,
"iOS"
);
String
type
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
));
if
(
type
.
equals
(
"lucky"
)){
Assert
.
assertTrue
(
response
.
jsonPath
().
getString
(
"data.lottery.link"
).
contains
(
"//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"
));
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.useBtnText"
),
"马上使用"
,
"校验useBtnText失败"
);
logger
.
info
(
"校验中奖限制测试:link,useBtnText成功"
);
logger
.
info
(
"校验中奖限制测试成功,未返回预设必中优惠券信息"
);
}
if
(
type
.
equals
(
"thanks"
)){
logger
.
info
(
"福袋库存不足会降级成谢谢参与!"
);
//福袋库存不足会降级成谢谢参与!
}
if
(
type
.
equals
(
"coupon"
)){
throw
new
Exception
(
"用例失败,不应返回优惠券信息:"
+
response
.
asString
());
}
}
public
Response
自有活动接口传参
(
String
activityId
,
String
token
,
String
device
)
throws
Exception
{
Response
response
=
activityReconService
.
doJoin2
(
activityId
,
token
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
response
.
prettyPrint
();
String
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
int
i
=
8
;
while
(
i
>
0
&&(
result
.
equals
(
"C000000001"
))){
Thread
.
sleep
(
1000
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
,
device
);
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
i
--;
response
.
prettyPrint
();
}
return
response
;
}
}
\ No newline at end of file
src/test/java/http/cases/ActivityReconTest/自有_活动次数测试.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.Config
;
import
base.DuibaLog
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.NewActivityService
;
import
http.service.hd.DeveloperService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
;
import
org.testng.Assert
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
java.lang.reflect.Method
;
/**
* Created by zhaoran on 2018/3/15
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
自有
_
活动次数测试
extends
AbstractTestNGSpringContextTests
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
DeveloperService
developerService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
@DataProvider
public
Object
[][]
providerMethod
(
Method
method
){
Object
[][]
result
=
null
;
if
(
method
.
getName
().
equals
(
"活动次数测试"
))
{
result
=
new
Object
[][]{
new
Object
[]{
1
,
"5"
,
"10"
,
"限制5次,免费10次"
},
new
Object
[]{
2
,
"8"
,
"3"
,
"限制8次,免费3次"
},
new
Object
[]{
3
,
""
,
"6"
,
"无限制次数,免费6次"
},
new
Object
[]{
4
,
"7"
,
""
,
"限制7次,无免费次数"
},
};
}
if
(
method
.
getName
().
equals
(
"活动次数测试2"
))
{
result
=
new
Object
[][]{
new
Object
[]{
1
,
"26248"
,
"限制5次,免费10次"
},
new
Object
[]{
2
,
"26249"
,
"限制8次,免费3次"
},
new
Object
[]{
3
,
"26250"
,
"无限制次数,免费6次"
},
new
Object
[]{
4
,
"21001"
,
"限制7次,无免费次数"
},
};
}
return
result
;
}
@Test
(
dataProvider
=
"providerMethod"
)
public
void
活动次数测试
2
(
int
casenum
,
String
activityId
,
String
casename
)
throws
Exception
{
logger
.
info
(
"-------------------------------------"
+
casename
+
"-------------------------------------"
);
//获取免费次数
Response
response
=
activityReconService
.
ajaxElement
(
""
,
activityId
);
response
.
print
();
switch
(
casenum
){
case
1
:
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"element.freeLimit"
),
"5"
,
"校验freeLimit失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"element.status"
),
"7"
,
"校验显示status失败"
);
break
;
case
2
:
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"element.freeLimit"
),
"3"
,
"校验freeLimit失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"element.status"
),
"7"
,
"校验显示status失败"
);
break
;
case
3
:
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"element.freeLimit"
),
"6"
,
"校验freeLimit失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"element.status"
),
"7"
,
"校验显示status失败"
);
break
;
case
4
:
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"element.freeLimit"
),
"7"
,
"校验freeLimit失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"element.status"
),
"6"
,
"校验显示status失败"
);
break
;
}
logger
.
info
(
"校验ajax接口的游戏次数正常:freeLimit,status"
);
}
}
src/test/java/http/cases/ActivityReconTest/自有_独立活动测试.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.Config
;
import
base.DuibaLog
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
* Created by zhaoran on 2018/1/2
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
自有
_
独立活动测试
extends
AbstractTestNGSpringContextTests
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
ManagerService
managerService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
@Test
(
description
=
"积分模式下的自有独立活动测试"
)
public
void
独立活动测试
()
throws
Exception
{
//校验ajax接口关键字段返回
logger
.
info
(
"请求/hdtool/ajaxElement接口"
);
Response
response_ajax
=
activityReconService
.
ajaxElement
(
""
,
"23316"
);
Assert
.
assertEquals
(
response_ajax
.
jsonPath
().
getString
(
"element.isCreditsTypeOpen"
),
"true"
,
"校验isCreditsTypeOpen失败"
);
Assert
.
assertEquals
(
response_ajax
.
jsonPath
().
getString
(
"element.status"
),
"7"
,
"校验status失败"
);
Assert
.
assertEquals
(
response_ajax
.
jsonPath
().
getString
(
"element.needCredits"
),
"0"
,
"校验status失败"
);
logger
.
info
(
"ajax校验项:isCreditsTypeOpen,status成功"
);
String
freeLimit
=
response_ajax
.
jsonPath
().
getString
(
"element.freeLimit"
);
logger
.
info
(
"抽奖前当日免费次数剩余:"
+
freeLimit
);
freeLimit
=
String
.
valueOf
(
Integer
.
valueOf
(
freeLimit
)-
1
);
logger
.
info
(
"抽奖后预期免费次数剩余:"
+
freeLimit
);
logger
.
info
(
"请求/hdtool/doJoin接口"
);
Response
response
=
activityReconService
.
doJoin2
(
"23316"
,
"ia9a7"
);
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
);
String
result
=
response
.
jsonPath
().
getString
(
"code"
);
int
i
=
30
;
while
(
i
>
0
&&
result
.
equals
(
"C000000001"
)){
Thread
.
sleep
(
1000
);
response
=
activityReconService
.
getOrderStatus2
(
orderId
);
result
=
response
.
jsonPath
().
getString
(
"code"
);
i
--;
}
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.element.isCreditsTypeOpen"
),
"true"
,
"校验isCreditsTypeOpen失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.element.status"
),
"7"
,
"校验status失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.title"
),
"支付宝"
,
"校验title失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
),
"alipay"
,
"校验type失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"校验success失败"
);
logger
.
info
(
"doJoin校验项:isCreditsTypeOpen,status,title,type,success成功"
);
String
freeLimitNew
=
response
.
jsonPath
().
getString
(
"data.element.freeLimit"
);
logger
.
info
(
"抽奖后实际免费次数剩余:"
+
freeLimitNew
);
Assert
.
assertEquals
(
freeLimitNew
,
freeLimit
,
"扣免费次数失败"
);
}
}
\ No newline at end of file
src/test/java/http/cases/ActivityReconTest/自有_自有活动出奖.java
0 → 100644
View file @
86a3ba5f
This diff is collapsed.
Click to expand it.
src/test/java/http/cases/ActivityReconTest/谢谢参与测试.java
0 → 100644
View file @
86a3ba5f
package
http
.
cases
.
ActivityReconTest
;
import
base.DuibaLog
;
import
base.DuibaTestBase
;
import
http.service.Activity.ActivityReconService
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NewActivityService
;
import
http.service.hd.ActivityService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
* Created by zhaoran on 2018/10/25
*/
public
class
谢谢参与测试
extends
DuibaTestBase
{
@Autowired
ActivityReconService
activityReconService
;
@Autowired
ManagerService
managerService
;
@Autowired
ActivityService
activityService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
private
static
Integer
uid
=
3661
;
@Test
public
void
谢谢参与测试
()
throws
Exception
{
logger
.
info
(
"-------------------------------------活动中奖谢谢参与-------------------------------------"
);
Response
response
=
this
.
新活动工具接口传参
(
uid
,
"34514"
,
"1gffs6mq3"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.type"
),
"thanks"
,
"校验类型失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.lottery.id"
).
isEmpty
(),
false
,
"校验id失败"
);
Assert
.
assertNotNull
(
response
.
jsonPath
().
getString
(
"data.lottery.id"
),
"校验id失败"
);
//校验返回字段
Assert
.
assertEquals
(
response
.
asString
().
contains
(
"id"
),
true
,
"校验id失败"
);
logger
.
info
(
"校验type,id成功"
);
}
public
Response
新活动工具接口传参
(
int
uid
,
String
activityId
,
String
token
)
throws
Exception
{
Response
response
=
activityReconService
.
doJoin2
(
uid
,
activityId
,
token
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
activityReconService
.
getOrderStatus2
(
uid
,
orderId
);
response
.
prettyPrint
();
String
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
int
i
=
30
;
while
(
i
>
0
&&(
result
.
equals
(
"C000000001"
))){
Thread
.
sleep
(
1000
);
response
=
activityReconService
.
getOrderStatus2
(
uid
,
orderId
);
result
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"code"
));
i
--;
response
.
prettyPrint
();
}
return
response
;
}
}
\ No newline at end of file
src/test/java/http/cases/ExchangeTest/Exchange_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -69,7 +69,7 @@ public class Exchange_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
uid
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动详情页请求异常"
);
//实物兑换
response
=
couponExchangeService
.
objectExchange
(
map
,
"159143"
,
"2619"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
response
=
couponExchangeService
.
objectExchange
(
map
,
"159143"
,
"2619"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
...
...
src/test/java/http/cases/ExchangeTest/ObjectExchange_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -76,7 +76,7 @@ public class ObjectExchange_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
uid
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动详情页请求异常"
);
//实物兑换
response
=
couponExchangeService
.
objectExchange
(
map
,
"159143"
,
"2619"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
response
=
couponExchangeService
.
objectExchange
(
map
,
"159143"
,
"2619"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
...
...
@@ -287,7 +287,7 @@ public class ObjectExchange_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
uid
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动详情页请求异常"
);
//实物兑换
response
=
couponExchangeService
.
objectExchange
(
map
,
"161100"
,
null
,
"null"
,
"
z9sydmcs
"
,
"null"
);
response
=
couponExchangeService
.
objectExchange
(
map
,
"161100"
,
null
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
...
...
@@ -439,7 +439,7 @@ public class ObjectExchange_ExchangeTest extends CheckTemplet {
}
//直充类流量兑换
@Test
(
description
=
"直充类流量兑换"
)
//
@Test(description = "直充类流量兑换")
public
void
流量兑换
()
throws
Exception
{
int
uid
=
4376
;
Thread
.
sleep
(
2000
);
...
...
src/test/java/http/cases/ExchangeTest/Qb_兑换流程测试_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -151,7 +151,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
message
=
e
.
toString
();
}
logger
.
info
(
message
);
Assert
.
assertTrue
(
message
.
contains
(
"
没有兑换成功
"
));
Assert
.
assertTrue
(
message
.
contains
(
"
已兑完
"
));
Assert
.
assertTrue
(
message
.
contains
(
"\"success\":false"
));
}
...
...
src/test/java/http/cases/ExchangeTest/优惠券_兑换流程测试_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -72,16 +72,16 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Object
[][]
result
=
null
;
if
(
method
.
getName
().
equals
(
"优惠券日期兑换限制测试"
))
{
result
=
new
Object
[][]{
new
Object
[]{
1
,
"171479"
,
"29538"
,
"
69xjl0a
"
,
"优惠券日期兑换限制未开始"
},
//case1
new
Object
[]{
2
,
"171480"
,
"29539"
,
"
z9sydmcs
"
,
"优惠券日期兑换限制进行中"
},
//case2
new
Object
[]{
3
,
"171481"
,
"29540"
,
"
cmixdqn
"
,
"优惠券日期兑换限制已结束"
},
//case2
new
Object
[]{
1
,
"171479"
,
"29538"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券日期兑换限制未开始"
},
//case1
new
Object
[]{
2
,
"171480"
,
"29539"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券日期兑换限制进行中"
},
//case2
new
Object
[]{
3
,
"171481"
,
"29540"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券日期兑换限制已结束"
},
//case2
};
}
if
(
method
.
getName
().
equals
(
"优惠券库存不足测试"
))
{
result
=
new
Object
[][]{
new
Object
[]{
"169775"
,
"29180"
,
"
69xjl0a
"
,
"优惠券商品库存不足测试"
},
//case1
new
Object
[]{
"172163"
,
"29677"
,
"
z9sydmcs
"
,
"优惠券定向库存不足测试"
},
//case2
new
Object
[]{
"174773"
,
"30286"
,
"
qyarwreq
"
,
"优惠券预分配库存不足测试"
},
new
Object
[]{
"169775"
,
"29180"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券商品库存不足测试"
},
//case1
new
Object
[]{
"172163"
,
"29677"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券定向库存不足测试"
},
//case2
new
Object
[]{
"174773"
,
"30286"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券预分配库存不足测试"
},
};
}
...
...
@@ -101,17 +101,17 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
}
if
(
method
.
getName
().
equals
(
"自有优惠券会员等级测试"
)){
result
=
new
Object
[][]{
new
Object
[]{
1
,
"172713"
,
"
pmqy9
"
,
"优惠券会员等级范围测试"
},
//case1
new
Object
[]{
2
,
"172715"
,
"
3bam907y
"
,
"优惠券会员特定等级测试"
},
//case2
new
Object
[]{
1
,
"172713"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券会员等级范围测试"
},
//case1
new
Object
[]{
2
,
"172715"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券会员特定等级测试"
},
//case2
};
}
if
(
method
.
getName
().
equals
(
"优惠券地区兑换限制测试"
)){
result
=
new
Object
[][]{
new
Object
[]{
1
,
"175459"
,
"30434"
,
"
pmqy9
"
,
"优惠券地区黑名单不可兑测试"
},
//case1
new
Object
[]{
2
,
"175603"
,
"30435"
,
"
3bam907y
"
,
"优惠券地区黑名单可兑测试"
},
//case2
new
Object
[]{
3
,
"175604"
,
"30436"
,
"
6dc8ntp
"
,
"优惠券地区白名单可兑测试"
},
//case3
new
Object
[]{
4
,
"175605"
,
"30437"
,
"
tvtgya6
"
,
"优惠券地区白名单不可兑测试"
},
//case4
new
Object
[]{
1
,
"175459"
,
"30434"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券地区黑名单不可兑测试"
},
//case1
new
Object
[]{
2
,
"175603"
,
"30435"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券地区黑名单可兑测试"
},
//case2
new
Object
[]{
3
,
"175604"
,
"30436"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券地区白名单可兑测试"
},
//case3
new
Object
[]{
4
,
"175605"
,
"30437"
,
"
yrJRr7Cddp2YeQd
"
,
"优惠券地区白名单不可兑测试"
},
//case4
};
...
...
@@ -218,7 +218,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
"174928"
);
map
.
put
(
"itemId"
,
"30319"
);
map
.
put
(
"token"
,
"
uvbhjc
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
url
+
"/couponExchange/exchange"
);
response
.
prettyPrint
();
...
...
@@ -385,7 +385,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
"170294"
);
map
.
put
(
"itemId"
,
"29293"
);
map
.
put
(
"token"
,
"
69xjl0a
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
try
{
//优惠券兑换,用户兑换限制次数1次
...
...
@@ -427,7 +427,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
"171478"
);
map
.
put
(
"itemId"
,
"29531"
);
map
.
put
(
"token"
,
"
69xjl0a
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
try
{
//优惠券兑换,用户兑换限制次数1次
...
...
@@ -468,7 +468,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
"170295"
);
map
.
put
(
"itemId"
,
"29294"
);
map
.
put
(
"token"
,
"
69xjl0a
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
try
{
//优惠券兑换,用户兑换限制次数1次
...
...
@@ -562,7 +562,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
"172079"
);
map
.
put
(
"itemId"
,
"29667"
);
map
.
put
(
"token"
,
"
69xjl0a
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
//兑换
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
url
+
"/couponExchange/exchange"
);
...
...
@@ -608,7 +608,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
* @param caseName 用例名称打印
* @throws Exception
*/
@Test
(
dataProvider
=
"providerMethod"
)
//
@Test(dataProvider = "providerMethod")
public
void
优惠券马上使用按钮测试
(
int
caseNum
,
String
appItemId
,
String
itemId
,
String
caseName
)
throws
Exception
{
logger
.
info
(
caseName
);
...
...
src/test/java/http/cases/ExchangeTest/商品订单失败测试_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -139,7 +139,7 @@ public class 商品订单失败测试_ExchangeTest extends CheckTemplet {
//校验订单状态,校验返回库存和积分
Assert
.
assertEquals
(
orderStatus
,
"fail"
,
"校验数据库status失败"
);
Assert
.
assertEquals
(
orderError
,
"审核不通过(
备注:
测试订单审核不通过)"
,
"校验数据库error失败"
);
Assert
.
assertEquals
(
orderError
,
"审核不通过(测试订单审核不通过)"
,
"校验数据库error失败"
);
logger
.
info
(
"校验实物订单审核不通过成功"
);
Assert
.
assertEquals
(
stockNew
,
stock
,
"校验stock失败"
);
...
...
src/test/java/http/cases/ExchangeTest/实物_兑换异常测试_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -54,7 +54,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
3086
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动详情页请求异常"
);
//实物兑换
response
=
couponExchangeService
.
objectExchange
(
map
,
"167141"
,
"28515"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
response
=
couponExchangeService
.
objectExchange
(
map
,
"167141"
,
"28515"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
response
.
prettyPrint
();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
...
...
@@ -91,7 +91,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
uid
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动详情页请求异常"
);
//实物兑换
Response
response1
=
couponExchangeService
.
objectExchange1
(
map
,
"167611"
,
"28633"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
Response
response1
=
couponExchangeService
.
objectExchange1
(
map
,
"167611"
,
"28633"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
response1
.
prettyPrint
();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
...
...
@@ -132,7 +132,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
String
message
=
null
;
String
succcess
=
null
;
try
{
Response
response
=
couponExchangeService
.
objectExchange1
(
authorization
.
dafuwengLogin
(
uid
),
"178880"
,
"31050"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
Response
response
=
couponExchangeService
.
objectExchange1
(
authorization
.
dafuwengLogin
(
uid
),
"178880"
,
"31050"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
message
=
response
.
jsonPath
().
getString
(
"message"
);
}
catch
(
Exception
e
){
...
...
@@ -148,7 +148,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
int
uid
=
3490
;
//第一次兑换
Response
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
"178879"
,
"31049"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
Response
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
"178879"
,
"31049"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
...
...
@@ -167,7 +167,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
//第二次兑换
try
{
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
"178879"
,
"31049"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
response
=
couponExchangeService
.
objectExchange
(
authorization
.
dafuwengLogin
(
uid
),
"178879"
,
"31049"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
...
...
src/test/java/http/cases/ExchangeTest/平台券_兑换流程测试_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -58,13 +58,13 @@ public class 平台券_兑换流程测试_ExchangeTest extends CheckTemplet {
Object
[][]
result
=
null
;
if
(
method
.
getName
().
equals
(
"平台券库存不足测试"
))
{
result
=
new
Object
[][]{
new
Object
[]{
"73734759122009"
,
"
n990y8dac
"
,
"平台券商品库存不足测试"
},
//case1
new
Object
[]{
"73734793724984"
,
"
s4c0zy
"
,
"平台券预分配库存不足测试"
},
//case2
new
Object
[]{
"73734759122009"
,
"
yrJRr7Cddp2YeQd
"
,
"平台券商品库存不足测试"
},
//case1
new
Object
[]{
"73734793724984"
,
"
yrJRr7Cddp2YeQd
"
,
"平台券预分配库存不足测试"
},
//case2
};
}
if
(
method
.
getName
().
equals
(
"平台券预分配库存测试"
)){
result
=
new
Object
[][]{
new
Object
[]{
"73734759122009"
,
"
n990y8dac
"
,
"平台券商品库存不足测试"
},
//case1
new
Object
[]{
"73734759122009"
,
"
yrJRr7Cddp2YeQd
"
,
"平台券商品库存不足测试"
},
//case1
};
}
...
...
@@ -158,7 +158,7 @@ public class 平台券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"pcgId"
,
"73725292586909"
);
map
.
put
(
"token"
,
"
dnsog
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
//获取按钮状态
Response
detailResponse
=
appPlatformCouponService
.
platformDetail
(
3086
,
true
,
"73725292586909"
);
...
...
@@ -243,7 +243,7 @@ public class 平台券_兑换流程测试_ExchangeTest extends CheckTemplet {
//每日限额用完,无法再次兑换
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"pcgId"
,
"74735076603359"
);
map
.
put
(
"token"
,
"
dnsog
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
//获取按钮状态
Response
detailResponse
=
appPlatformCouponService
.
platformDetail
(
uid
,
"74735076603359"
);
...
...
@@ -282,7 +282,7 @@ public class 平台券_兑换流程测试_ExchangeTest extends CheckTemplet {
//用户限制次数用完,无法兑换
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"pcgId"
,
"74371944595109"
);
map
.
put
(
"token"
,
"
dnsog
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
//获取按钮状态
Response
detailResponse
=
appPlatformCouponService
.
platformDetail
(
uid
,
"74371944595109"
);
...
...
src/test/java/http/cases/ExchangeTest/支付宝_兑换流程测试_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -203,7 +203,7 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
map
.
put
(
"realname"
,
"沙箱环境"
);
map
.
put
(
"degreeId"
,
"10"
);
map
.
put
(
"itemId"
,
"55"
);
map
.
put
(
"token"
,
"
fw7qga0
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
dafuwengLogin
(
3490
)).
params
(
map
).
post
(
url
+
"/alipayExchange/exchange"
);
response
.
prettyPrint
();
...
...
@@ -213,7 +213,7 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
logger
.
info
(
"兑换后的开发者账户余额:"
+
remainMoneyNew
);
Assert
.
assertEquals
(
exchangeText
,
"已兑完"
,
"校验马上兑换按钮状态失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"message"
),
"
对不起,没有兑换成功,请挑选其他吧(2)
"
,
"校验message失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"message"
),
"
已兑完
"
,
"校验message失败"
);
Assert
.
assertEquals
(
remainMoneyNew
,
remainMoney
,
"校验开发者账户余额失败"
);
logger
.
info
(
"校验支付宝商品余额不足成功"
);
...
...
@@ -250,7 +250,7 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
map
.
put
(
"realname"
,
"沙箱环境"
);
map
.
put
(
"degreeId"
,
"1"
);
map
.
put
(
"itemId"
,
"55"
);
map
.
put
(
"token"
,
"
fw7qga0
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
//会员符合条件,兑换
Response
successResponse
=
this
.
支付宝兑换
(
3574
,
"peeulk6392@sandbox.com"
,
"沙箱环境"
,
"1"
);
...
...
@@ -282,7 +282,7 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
map
.
put
(
"realname"
,
realName
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"itemId"
,
"55"
);
map
.
put
(
"token"
,
"
fw7qga0
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
try
{
//支付宝兑换
...
...
src/test/java/http/cases/ExchangeTest/虚拟商品_兑换异常测试_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -242,7 +242,7 @@ public class 虚拟商品_兑换异常测试_ExchangeTest extends CheckTemplet {
}
}
@Test
(
description
=
"虚拟商品自定义兑换按钮文案马上使用按钮"
)
//
@Test(description = "虚拟商品自定义兑换按钮文案马上使用按钮")
public
void
虚拟商品自定义兑换按钮文案马上使用按钮
()
throws
Exception
{
logger
.
info
(
"虚拟商品马上使用按钮验证开始"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
...
...
@@ -419,7 +419,7 @@ public class 虚拟商品_兑换异常测试_ExchangeTest extends CheckTemplet {
}
@Test
(
description
=
"自动化】虚拟商品日期兑换时间进行中"
)
//
@Test(description = "自动化】虚拟商品日期兑换时间进行中")
public
void
虚拟商品日期兑换时间进行中
()
throws
Exception
{
logger
.
info
(
"【自动化】虚拟商品日期兑换时间进行中开始验证"
);
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
...
...
src/test/java/http/cases/GoodsAndTradeTest/异常订单测试_ExchangeTest.java
View file @
86a3ba5f
...
...
@@ -56,7 +56,7 @@ public class 异常订单测试_ExchangeTest extends DuibaTestBase {
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
uid
,
true
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动详情页请求异常"
);
//实物兑换
Response
response1
=
couponExchangeService
.
objectExchange1
(
map
,
"167611"
,
"28633"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
Response
response1
=
couponExchangeService
.
objectExchange1
(
map
,
"167611"
,
"28633"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
response1
.
prettyPrint
();
String
message2
=
response1
.
jsonPath
().
getString
(
"message"
);
...
...
@@ -71,7 +71,7 @@ public class 异常订单测试_ExchangeTest extends DuibaTestBase {
Map
<
String
,
String
>
map
=
authorization
.
dafuwengLogin
(
4819
);
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动详情页请求异常"
);
//实物兑换
Response
response2
=
couponExchangeService
.
objectExchange2
(
map
,
"179139"
,
"null"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
Response
response2
=
couponExchangeService
.
objectExchange2
(
map
,
"179139"
,
"null"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
response2
.
prettyPrint
();
String
message3
=
response2
.
jsonPath
().
getString
(
"message"
);
...
...
@@ -91,7 +91,7 @@ public class 异常订单测试_ExchangeTest extends DuibaTestBase {
// response.prettyPrint();
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动详情页请求异常"
);
//实物兑换
Response
response2
=
couponExchangeService
.
objectExchange2
(
userCookies
,
"179139"
,
"null"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
Response
response2
=
couponExchangeService
.
objectExchange2
(
userCookies
,
"179139"
,
"null"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
response2
.
prettyPrint
();
String
message3
=
response2
.
jsonPath
().
getString
(
"message"
);
...
...
@@ -110,7 +110,7 @@ public class 异常订单测试_ExchangeTest extends DuibaTestBase {
public
void
run
()
{
logger
.
info
(
"开始执行 "
);
try
{
Response
response2
=
couponExchangeService
.
objectExchange2
(
userCookies
,
"179139"
,
"null"
,
"null"
,
"
z9sydmcs
"
,
"null"
);
Response
response2
=
couponExchangeService
.
objectExchange2
(
userCookies
,
"179139"
,
"null"
,
"null"
,
"
yrJRr7Cddp2YeQd
"
,
"null"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
src/test/java/http/cases/NewActivityTest/抽奖异常测试_DuibaTest.java
View file @
86a3ba5f
...
...
@@ -149,23 +149,33 @@ public class 抽奖异常测试_DuibaTest extends DuibaTestBase {
@Test
(
dataProvider
=
"providerMethod"
)
public
void
未登录抽奖测试
(
Map
<
String
,
String
>
data
)
throws
Exception
{
logger
.
info
(
"-------------------------------------"
+
data
.
get
(
"casename"
)+
"-------------------------------------"
);
//获取未登录场景cookie
Response
responses
=
authorization
.
autoLogin
();
//进行接口测试传参
Map
<
String
,
String
>
map
=
responses
.
getCookies
();
logger
.
info
(
"cookies:"
+
map
.
toString
());
if
(
responses
.
getDetailedCookies
()==
null
)
logger
.
info
(
"cookies = = null"
);
Response
response
=
newActivityService
.
doJoinMap
(
map
,
data
.
get
(
"token"
),
data
.
get
(
"activityId"
));
// Response response = newActivityService.doJoin(responses.getDetailedCookies(),data.get("token"),data.get("activityId"));
response
.
prettyPrint
();
String
success
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"success"
));
//根据case选择校验项
if
(
success
.
equals
(
"false"
)){
if
(
data
.
get
(
"activityId"
).
equals
(
"18587"
)){
//获取未登录场景cookie
Response
responses
=
authorization
.
autoLogin
();
//进行接口测试传参
Map
<
String
,
String
>
map
=
responses
.
getCookies
();
logger
.
info
(
"cookies:"
+
map
.
toString
());
if
(
responses
.
getDetailedCookies
()==
null
)
logger
.
info
(
"cookies = = null"
);
Response
response
=
newActivityService
.
doJoinMap
(
map
,
data
.
get
(
"token"
),
data
.
get
(
"activityId"
));
response
.
prettyPrint
();
String
success
=
String
.
valueOf
(
response
.
jsonPath
().
getString
(
"success"
));
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"message"
),
"请先登录"
,
"校验message失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"status"
),
"18"
,
"校验status失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"status"
),
"18"
,
"校验status失败"
);
logger
.
info
(
"未登录状态下无免费次数抽奖校验:message,status成功"
);
}
if
(
success
.
equals
(
"true"
)){
if
(
data
.
get
(
"activityId"
).
equals
(
"18586"
)){
//获取未登录场景cookie
Response
responses
=
newActivityService
.
indexOpenbs
(
"18586"
);
//进行接口测试传参
Map
<
String
,
String
>
map
=
responses
.
getCookies
();
logger
.
info
(
"cookies:"
+
map
.
toString
());
if
(
responses
.
getDetailedCookies
()==
null
)
logger
.
info
(
"cookies = = null"
);
Response
response
=
newActivityService
.
doJoinMap
(
map
,
data
.
get
(
"token"
),
data
.
get
(
"activityId"
));
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
response
=
newActivityService
.
getOrderStatus
(
responses
.
getDetailedCookies
(),
orderId
);
response
.
prettyPrint
();
...
...
src/test/java/http/service/Activity/ActivityReconService.java
0 → 100644
View file @
86a3ba5f
This diff is collapsed.
Click to expand it.
src/test/java/http/service/Activity/NewActivityService.java
View file @
86a3ba5f
...
...
@@ -423,6 +423,25 @@ public class NewActivityService {
}
return
response
;
}
//openbs访问活动首页
public
Response
indexOpenbs
(
String
atcId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
atcId
);
map
.
put
(
"appKey"
,
"2wGQc3MZaQsqYFWcX4gguya5PnnS"
);
map
.
put
(
"openBs"
,
"openbs"
);
logger
.
info
(
"请求/hdtool/index接口,id="
+
atcId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
2720
)).
params
(
map
).
post
(
url
+
"/hdtool/index"
);
try
{
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"活动页打开异常"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/hdtool/index接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/hdtool/index接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
//访问答题活动首页接口
public
Response
index_dt
(
String
atcId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
...
...
src/test/java/http/service/app/AlipayExchangeService.java
View file @
86a3ba5f
...
...
@@ -35,7 +35,7 @@ public class AlipayExchangeService {
map
.
put
(
"realname"
,
realname
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"itemId"
,
"55"
);
map
.
put
(
"token"
,
"
fw7qga0
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
logger
.
info
(
"请求/alipayExchange/exchange接口"
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
url
);
...
...
src/test/java/http/service/app/AppPlatformCouponService.java
View file @
86a3ba5f
...
...
@@ -45,7 +45,7 @@ public class AppPlatformCouponService {
public
Response
takeOrder
(
int
uid
,
String
pcgId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"pcgId"
,
pcgId
);
map
.
put
(
"token"
,
"
dnsog
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
logger
.
info
(
"请求/platformCoupon/takeOrder接口"
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
"http://"
+
goodsHost
+
"/platformCoupon/takeOrder"
);
...
...
src/test/java/http/service/app/CouponExchangeService.java
View file @
86a3ba5f
...
...
@@ -122,7 +122,7 @@ public class CouponExchangeService {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
appItemId
);
map
.
put
(
"itemId"
,
itemId
);
map
.
put
(
"token"
,
"
ds6tla07c
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
map
.
put
(
"degreeId"
,
"1"
);
map
.
put
(
"phone"
,
"18012341234"
);
map
.
put
(
"phoneCatName"
,
"中国电信"
);
...
...
@@ -148,7 +148,7 @@ public class CouponExchangeService {
public
Response
phonebillExchange
(
Map
cookies
,
String
degreeId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"token"
,
"
ds6tla07c
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"phone"
,
"18012341234"
);
map
.
put
(
"phoneCatName"
,
"中国电信"
);
...
...
@@ -174,7 +174,7 @@ public class CouponExchangeService {
public
Response
phoneflowExchange
(
Map
cookies
,
String
degreeId
,
String
itemId
,
String
phone
,
String
phoneCatName
,
String
phoneProvince
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"itemId"
,
itemId
);
map
.
put
(
"token"
,
"
cmixdqn
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"phone"
,
phone
);
map
.
put
(
"phoneCatName"
,
phoneCatName
);
...
...
@@ -224,7 +224,7 @@ public class CouponExchangeService {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
appItemId
);
map
.
put
(
"itemId"
,
itemId
);
map
.
put
(
"token"
,
"
xt7czv3c4
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
map
.
put
(
"addrName"
,
"胡梦新"
);
map
.
put
(
"addrPhone"
,
"18258853242"
);
map
.
put
(
"addrProvince"
,
"浙江省"
);
...
...
@@ -250,7 +250,7 @@ public class CouponExchangeService {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
appItemId
);
map
.
put
(
"itemId"
,
itemId
);
map
.
put
(
"token"
,
"
xt7czv3c4
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
map
.
put
(
"addrName"
,
"胡梦新"
);
map
.
put
(
"addrPhone"
,
"18258853242"
);
map
.
put
(
"addrProvince"
,
"浙江省"
);
...
...
@@ -279,7 +279,7 @@ public class CouponExchangeService {
map
.
put
(
"realname"
,
"沙箱环境"
);
map
.
put
(
"degreeId"
,
"1"
);
map
.
put
(
"itemId"
,
itemId
);
map
.
put
(
"token"
,
"
jnwwwv
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
logger
.
info
(
"请求/alipayExchange/exchange接口"
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
"http://"
+
goodsHost
+
"/alipayExchange/exchange"
);
...
...
src/test/java/http/service/app/QbExchangeService.java
View file @
86a3ba5f
...
...
@@ -30,7 +30,7 @@ public class QbExchangeService {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"qq"
,
qq
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"token"
,
"
0nmfgduh8
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
Response
response
=
given
().
params
(
map
).
cookies
(
cookies
).
post
(
activityHost
+
"/qbExchange/exchange"
);
...
...
@@ -53,7 +53,7 @@ public class QbExchangeService {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"qq"
,
qq
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"token"
,
"
0nmfgduh8
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
Response
response
=
given
().
params
(
map
).
cookies
(
cookies
).
post
(
activityHost
+
"/qbExchange/exchange"
);
String
message
=
response
.
jsonPath
().
getString
(
"data.message"
);
...
...
src/test/java/http/service/app/VirtualExchangeService.java
View file @
86a3ba5f
...
...
@@ -25,7 +25,7 @@ public class VirtualExchangeService {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
appItemId
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"token"
,
"
xz9eyi
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
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
...
...
@@ -48,7 +48,7 @@ public class VirtualExchangeService {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appItemId"
,
appItemId
);
map
.
put
(
"degreeId"
,
degreeId
);
map
.
put
(
"token"
,
"
xz9eyi
"
);
map
.
put
(
"token"
,
"
yrJRr7Cddp2YeQd
"
);
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
...
...
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