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
b11ff4ea
Commit
b11ff4ea
authored
Dec 19, 2018
by
周松波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
c0956140
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
27 deletions
+96
-27
ContractSignCommon.java
src/test/java/http/cases/SignTest/ContractSignCommon.java
+16
-0
ContractSign_signTest.java
src/test/java/http/cases/SignTest/ContractSign_signTest.java
+57
-26
ContractSignService.java
src/test/java/http/service/Activity/ContractSignService.java
+23
-1
No files found.
src/test/java/http/cases/SignTest/ContractSignCommon.java
View file @
b11ff4ea
...
...
@@ -12,6 +12,7 @@ import http.service.Authorization;
import
http.service.hd.SigninService
;
import
io.restassured.response.Response
;
import
org.apache.commons.lang.StringUtils
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -38,6 +39,21 @@ public class ContractSignCommon extends DuibaTestBase{
String
activityHost
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
public
Response
queryRewardResult
(
String
ContractId
,
int
uid
)
throws
Exception
{
Response
response
=
ContractSignService
.
queryRewardStatus
(
ContractId
,
uid
);;
String
rewardStatus
=
response
.
jsonPath
().
getString
(
"data.rewardStatus"
);
int
num
=
10
;
while
(
rewardStatus
.
equals
(
"0"
)
&&
num
>
0
)
{
response
=
ContractSignService
.
queryRewardStatus
(
ContractId
,
uid
);
rewardStatus
=
response
.
jsonPath
().
getString
(
"data.rewardStatus"
);
if
(
rewardStatus
.
equals
(
"2"
))
{
break
;
}
num
--;
Thread
.
sleep
(
1000
);
}
return
response
;
}
public
Map
<
String
,
String
>
doJoinResult
(
String
activityId
,
String
betAmount
,
int
uid
)
throws
Exception
{
Response
doJoinRes
=
ContractSignService
.
doJoin
(
activityId
,
betAmount
,
uid
);
String
contractId
=
doJoinRes
.
jsonPath
().
getString
(
"data.contractId"
);
...
...
src/test/java/http/cases/SignTest/ContractSign_signTest.java
View file @
b11ff4ea
...
...
@@ -40,9 +40,11 @@ public class ContractSign_signTest extends DuibaTestBase {
ContractSignService
ContractSignService
;
@Autowired
ManagerService
managerService
;
@Autowired
ContractSignCommon
ContractSignCommon
;
@Value
(
"${activity.host}"
)
String
activityHost
;
private
String
period
;
private
String
period
_tomorrow
,
period
;
private
String
issueId
;
// private static DuibaLog logger = DuibaLog.getLogger();
...
...
@@ -102,7 +104,9 @@ public class ContractSign_signTest extends DuibaTestBase {
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
date
=
calendar
.
getTime
();
// 期次号 MMDD格式
period
=
format
.
format
(
date
);
period_tomorrow
=
format
.
format
(
date
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,-
8
);
period
=
format
.
format
(
calendar
.
getTime
());
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid1
);
int
contractCycle
=
homeInfoRes
.
jsonPath
().
getInt
(
"data.contractCycle"
);
Assert
.
assertEquals
(
contractCycle
,
7
,
"周期天数不正确"
);
...
...
@@ -115,10 +119,10 @@ public class ContractSign_signTest extends DuibaTestBase {
int
buyers
=
homeInfoRes
.
jsonPath
().
getInt
(
"data.buyers"
);
Assert
.
assertEquals
(
buyers
,
0
,
"报名人数不正确"
);
String
periodShow
=
homeInfoRes
.
jsonPath
().
getString
(
"data.periodShow"
);
Assert
.
assertEquals
(
periodShow
,
period
,
"活动期次号不正确"
);
Assert
.
assertEquals
(
periodShow
,
period
_tomorrow
,
"活动期次号不正确"
);
}
@Test
(
description
=
"契约签到报名测试, 活动ID=2"
,
priority
=
2
)
@Test
(
description
=
"契约签到报名测试, 活动ID=2"
,
priority
=
2
,
dependsOnMethods
=
{
"签到活动信息"
}
)
public
void
固定额度报名
()
throws
Exception
{
String
actId
=
"2"
;
String
betAmount
=
"1000"
;
...
...
@@ -162,7 +166,7 @@ public class ContractSign_signTest extends DuibaTestBase {
int
buyers_new
=
Integer
.
valueOf
(
homeInfoRes
.
jsonPath
().
getString
(
"data.buyers"
));
Assert
.
assertEquals
(
buyers_new
,
4
,
"报名人数未增加"
);
String
periodShow
=
homeInfoRes
.
jsonPath
().
getString
(
"data.periodShow"
);
Assert
.
assertEquals
(
periodShow
,
period
,
"参与期次号不正确"
);
Assert
.
assertEquals
(
periodShow
,
period
_tomorrow
,
"参与期次号不正确"
);
String
currentPeriod
=
homeInfoRes
.
jsonPath
().
getString
(
"data.currentPeriod"
);
Assert
.
assertEquals
(
currentPeriod
,
"0"
,
"当前期次进度不正确"
);
//0-未报名 1-报名中 2-已报名,打卡未开始 3-未打卡:打卡开始,当天未打卡 4-已打卡:当天已打卡(非最后一天) 5-失败:出现断卡(未报名新一期) 6-成功: 已成功(未报名新一期)
...
...
@@ -173,7 +177,7 @@ public class ContractSign_signTest extends DuibaTestBase {
}
@Test
(
description
=
"活动ID=2, uid1打卡"
,
priority
=
3
)
@Test
(
description
=
"活动ID=2, uid1打卡"
,
priority
=
3
,
dependsOnMethods
=
{
"固定额度报名"
}
)
public
void
固定额度签到打卡
()
throws
Exception
{
String
actId
=
"2"
;
//修改期次,今日为打卡日
...
...
@@ -201,7 +205,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Assert
.
assertEquals
(
status
,
"4"
,
"打卡完成后状态不正确"
);
}
@Test
(
description
=
"活动ID=2,uid2第六天断签"
,
priority
=
4
)
@Test
(
description
=
"活动ID=2,uid2第六天断签"
,
priority
=
4
,
dependsOnMethods
=
{
"固定额度签到打卡"
}
)
public
void
固定额度断签
()
throws
Exception
{
String
actId
=
"2"
;
//当天为周期第一天,周期往前再挪6天
...
...
@@ -226,7 +230,7 @@ public class ContractSign_signTest extends DuibaTestBase {
}
@Test
(
description
=
"uid3 uid4打卡完成,活动ID=2"
,
priority
=
5
)
@Test
(
description
=
"uid3 uid4打卡完成,活动ID=2"
,
priority
=
5
,
dependsOnMethods
=
{
"固定额度断签"
}
)
public
void
固定额度
_
整期打卡完成
()
throws
Exception
{
String
actId
=
"2"
;
//补签前6天
...
...
@@ -249,7 +253,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Assert
.
assertEquals
(
success
,
"true"
,
"uid4打卡失败"
);
logger
.
info
(
"uid4七日打卡成功"
);
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid4
);
homeInfoRes
.
prettyPrint
();
//
homeInfoRes.prettyPrint();
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"6"
,
"完成7日打卡状态不正确"
);
String
hasReward
=
homeInfoRes
.
jsonPath
().
getString
(
"data.hasReward"
);
...
...
@@ -259,7 +263,7 @@ public class ContractSign_signTest extends DuibaTestBase {
}
@Test
(
description
=
"开奖,活动ID=2"
,
priority
=
6
)
@Test
(
description
=
"开奖,活动ID=2"
,
priority
=
6
,
dependsOnMethods
=
{
"固定额度_整期打卡完成"
}
)
public
void
契约开奖
_
固定额度
()
throws
Exception
{
String
actId
=
"2"
;
modifyIssuePeriod
(
issueId
,
-
1
);
...
...
@@ -270,7 +274,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid3
);
//homeInfoRes.prettyPrint();
String
periodShow
=
homeInfoRes
.
jsonPath
().
getString
(
"data.periodShow"
);
Assert
.
assertEquals
(
periodShow
,
period
,
"参与期次号不正确"
);
Assert
.
assertEquals
(
periodShow
,
period
_tomorrow
,
"参与期次号不正确"
);
String
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"6"
,
"当前参与状态不正确"
);
String
hasReward
=
homeInfoRes
.
jsonPath
().
getString
(
"data.hasReward"
);
...
...
@@ -280,28 +284,55 @@ public class ContractSign_signTest extends DuibaTestBase {
String
contractId
=
recordRes
.
jsonPath
().
getString
(
"data.list[0].contractId"
);
String
doneStatus
=
recordRes
.
jsonPath
().
getString
(
"data.list[0].doneStatus"
);
Assert
.
assertEquals
(
doneStatus
,
"WAIT_REWARD"
,
"当前期次完成状态不正确"
);
String
winCount
=
recordRes
.
jsonPath
().
getString
(
"data.list[0].winCount"
);
Assert
.
assertEquals
(
winCount
,
"7000"
,
"瓜分奖励金额不正确"
);
// 领奖
int
winCount
=
recordRes
.
jsonPath
().
getInt
(
"data.list[0].winCount"
);
Assert
.
assertEquals
(
winCount
,
7000
,
"瓜分奖励金额不正确"
);
//领奖前查询领取状态
Response
rewardStatusRes
=
ContractSignService
.
queryRewardStatus
(
contractId
,
uid3
);
int
rewardStatus
=
rewardStatusRes
.
jsonPath
().
getInt
(
"data.rewardStatus"
);
Assert
.
assertEquals
(
rewardStatus
,
0
,
"uid3领取奖励前状态不正确"
);
// uid3领奖
Response
rewardRes
=
ContractSignService
.
getReward
(
contractId
,
uid3
);
String
reward
Status
=
rewardRes
.
jsonPath
().
getString
(
"success"
);
String
rewardAmount
=
rewardRes
.
jsonPath
().
getString
(
"data"
);
Assert
.
assertEquals
(
reward
Status
,
"true"
,
"领取奖励结果不正确"
);
String
reward
Result
=
rewardRes
.
jsonPath
().
getString
(
"success"
);
int
rewardAmount
=
rewardRes
.
jsonPath
().
getInt
(
"data"
);
Assert
.
assertEquals
(
reward
Result
,
"true"
,
"领取奖励结果不正确"
);
Assert
.
assertEquals
(
rewardAmount
,
winCount
,
"领取奖励金额不正确"
);
//再次查询参与记录
recordRes
=
ContractSignService
.
getContracts
(
actId
,
uid3
);
doneStatus
=
recordRes
.
jsonPath
().
getString
(
"data.list[0].doneStatus"
);
Assert
.
assertEquals
(
doneStatus
,
"REWARD"
,
"当前期次完成状态不正确"
);
winCount
=
recordRes
.
jsonPath
().
getString
(
"data.list[0].winCount"
);
Assert
.
assertEquals
(
winCount
,
"7000"
,
"显示领取金额不正确"
);
Response
queryRewardRes
=
ContractSignCommon
.
queryRewardResult
(
contractId
,
uid3
);
rewardStatus
=
queryRewardRes
.
jsonPath
().
getInt
(
"data.rewardStatus"
);
Assert
.
assertEquals
(
rewardStatus
,
2
,
"uid3领取奖励失败"
);
int
winCount2
=
queryRewardRes
.
jsonPath
().
getInt
(
"data.winCount"
);
Assert
.
assertEquals
(
winCount2
,
winCount
,
"uid3 待领取奖励积分不正确"
);
int
betCount
=
queryRewardRes
.
jsonPath
().
getInt
(
"data.betCount"
);
Assert
.
assertEquals
(
betCount
,
14000
,
"参与期次奖池数不正确"
);
int
userBetCount
=
queryRewardRes
.
jsonPath
().
getInt
(
"data.userBetCount"
);
Assert
.
assertEquals
(
userBetCount
,
1000
,
"uid3报名金额显示不正确"
);
int
buyers
=
queryRewardRes
.
jsonPath
().
getInt
(
"data.buyers"
);
Assert
.
assertEquals
(
buyers
,
4
,
"期次报名人数不正确"
);
int
winners
=
queryRewardRes
.
jsonPath
().
getInt
(
"data.winners"
);
Assert
.
assertEquals
(
winners
,
2
,
"期次完成人数不正确"
);
String
issueNo
=
queryRewardRes
.
jsonPath
().
getString
(
"data.issueNo"
);
Assert
.
assertEquals
(
issueNo
,
period
,
"参与期次号不正确"
);
//uid4领奖
recordRes
=
ContractSignService
.
getContracts
(
actId
,
uid4
);
contractId
=
recordRes
.
jsonPath
().
getString
(
"data.list[0].contractId"
);
ContractSignService
.
getReward
(
contractId
,
uid4
);
queryRewardRes
=
ContractSignCommon
.
queryRewardResult
(
contractId
,
uid4
);
rewardStatus
=
queryRewardRes
.
jsonPath
().
getInt
(
"data.rewardStatus"
);
Assert
.
assertEquals
(
rewardStatus
,
2
,
"uid3领取奖励失败"
);
//再次查询参与记录
recordRes
=
ContractSignService
.
getContracts
(
actId
,
uid3
);
doneStatus
=
recordRes
.
jsonPath
().
getString
(
"data.list[0].doneStatus"
);
Assert
.
assertEquals
(
doneStatus
,
"REWARD"
,
"当前期次完成状态不正确"
);
winCount
=
recordRes
.
jsonPath
().
getInt
(
"data.list[0].winCount"
);
Assert
.
assertEquals
(
winCount
,
7000
,
"显示领取金额不正确"
);
}
@Test
(
description
=
"
打卡/收益排行榜,活动ID=2"
,
priority
=
7
)
@Test
(
description
=
"
参与记录,活动ID=2"
,
priority
=
7
,
dependsOnMethods
=
{
"契约开奖_固定额度"
}
)
public
void
参与记录
()
throws
Exception
{
// 查询断签用户参与记录
Response
recordRes
=
ContractSignService
.
getContracts
(
"2"
,
uid2
);
...
...
@@ -335,7 +366,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Assert
.
assertEquals
(
totalProfit
,
7000
,
"累计收益不正确"
);
}
@Test
(
description
=
"打卡/收益排行榜,活动ID=2"
,
priority
=
8
)
@Test
(
description
=
"打卡/收益排行榜,活动ID=2"
,
priority
=
8
,
dependsOnMethods
=
{
"参与记录"
}
)
public
void
排行榜
()
throws
Exception
{
String
actId
=
"2"
;
//查询签到次数排行榜
...
...
@@ -374,7 +405,7 @@ public class ContractSign_signTest extends DuibaTestBase {
}
@Test
(
description
=
"中奖轮播"
,
priority
=
9
)
@Test
(
description
=
"中奖轮播"
,
priority
=
9
,
dependsOnMethods
=
{
"排行榜"
}
)
public
void
中奖轮播
_
固定额度
()
throws
Exception
{
//删除redis key
// Map<String, String> carouselMap = new HashMap<>();
...
...
src/test/java/http/service/Activity/ContractSignService.java
View file @
b11ff4ea
...
...
@@ -205,7 +205,7 @@ public class ContractSignService {
public
Response
getReward
(
String
ContractId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"contractId"
,
ContractId
);
logger
.
info
(
"请求getReward接口,
签到活动
id="
+
ContractId
);
logger
.
info
(
"请求getReward接口,
契约
id="
+
ContractId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/getReward"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/getReward接口请求失败"
);
...
...
@@ -216,4 +216,26 @@ public class ContractSignService {
}
return
response
;
}
/**
* 针对瓜分积分的模式
* @param ContractId
* @param uid
* @return
* @throws Exception
*/
public
Response
queryRewardStatus
(
String
ContractId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"contractId"
,
ContractId
);
logger
.
info
(
"请求queryRewardStatus接口,契约id="
+
ContractId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
get
(
activityHost
+
"/sign/contract/queryRewardStatus"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/queryRewardStatus接口请求失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/sign/contract/queryRewardStatus接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/queryRewardStatus接口失败,返回信息"
+
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