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
72ab0dc1
Commit
72ab0dc1
authored
Nov 08, 2018
by
周松波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
ec463e6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
78 deletions
+78
-78
ContractSign_signTest.java
src/test/java/http/cases/SignTest/ContractSign_signTest.java
+77
-77
ContractSignService.java
src/test/java/http/service/Activity/ContractSignService.java
+1
-1
No files found.
src/test/java/http/cases/SignTest/ContractSign_signTest.java
View file @
72ab0dc1
...
...
@@ -4,6 +4,8 @@ import base.DuibaLog;
import
base.DuibaTestBase
;
import
base.MysqlConnPool
;
import
base.MysqlUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.ContractSignService
;
import
http.service.Authorization
;
...
...
@@ -23,6 +25,7 @@ import java.text.SimpleDateFormat;
import
java.util.*
;
import
static
io
.
restassured
.
RestAssured
.
given
;
import
static
io
.
restassured
.
RestAssured
.
post
;
/**
* Created by songbo on 2018/9/5.
...
...
@@ -39,7 +42,8 @@ public class ContractSign_signTest extends DuibaTestBase {
ManagerService
managerService
;
@Value
(
"${activity.host}"
)
String
activityHost
;
String
period
;
private
String
period
;
private
String
issueId
;
// private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
...
...
@@ -60,9 +64,8 @@ public class ContractSign_signTest extends DuibaTestBase {
// }
//
@Test(description = "截止报名测试, 活动ID=3", priority = 10)
@Test
(
description
=
"截止报名测试, 活动ID=3"
,
priority
=
10
)
public
void
截止报名测试
()
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
"3"
);
map
.
put
(
"betAmount"
,
"1000"
);
...
...
@@ -111,7 +114,7 @@ public class ContractSign_signTest extends DuibaTestBase {
// 报名
Map
<
String
,
String
>
map
=
this
.
doJoinResult
(
actId
,
betAmount
,
uid1
);
issueId
=
map
.
get
(
"issueId"
);
//int totalCount = Integer.valueOf(map.get("totalCount"));
//int buyers = Integer.valueOf(map.get("buyers"));
String
doneStatusDesc
=
map
.
get
(
"doneStatusDesc"
);
...
...
@@ -151,7 +154,7 @@ public class ContractSign_signTest extends DuibaTestBase {
public
void
签到打卡
()
throws
Exception
{
String
actId
=
"2"
;
//修改期次,今日为打卡日
modifyIssuePeriod
(
actId
,
uid1
,-
1
);
modifyIssuePeriod
(
issueId
,-
1
);
Date
now
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"MMdd"
);
String
today
=
sdf
.
format
(
now
);
...
...
@@ -179,11 +182,11 @@ public class ContractSign_signTest extends DuibaTestBase {
public
void
契约签到断签
()
throws
Exception
{
String
actID
=
"2"
;
//当天为周期第一天,周期往前再挪6天
modifyIssuePeriod
(
actID
,
uid2
,-
6
);
modifyIssuePeriod
(
issueId
,-
6
);
//补签前5天,第六天不签
this
.
contractResign
(
actID
,
uid2
,
7
,
true
);
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actID
,
uid2
);
homeInfoRes
.
prettyPrint
();
//
homeInfoRes.prettyPrint();
String
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"5"
,
"当前签到状态不正确"
);
Date
now
=
new
Date
();
...
...
@@ -199,33 +202,34 @@ public class ContractSign_signTest extends DuibaTestBase {
@Test
(
description
=
"uid3 uid4打卡完成,活动ID=2"
,
priority
=
4
)
public
void
契约签到整期打卡完成
()
throws
Exception
{
//当前为打卡第6天,周期往期挪一天
String
actID
=
"2"
;
modifyIssuePeriod
(
actID
,
uid3
,
-
1
);
String
actId
=
"2"
;
//补签前6天
this
.
contractResign
(
actI
D
,
uid3
,
7
,
false
);
this
.
contractResign
(
actI
D
,
uid4
,
7
,
false
);
this
.
contractResign
(
actI
d
,
uid3
,
7
,
false
);
this
.
contractResign
(
actI
d
,
uid4
,
7
,
false
);
//今日打卡
Response
signRes
=
ContractSignService
.
doSign
(
"2"
,
uid3
);
String
success
=
signRes
.
jsonPath
().
getString
(
"success"
);
String
status
=
signRes
.
jsonPath
().
getString
(
"status"
);
Assert
.
assertEquals
(
success
,
"true"
,
"uid3打卡失败"
);
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid3
);
String
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"6"
,
"完成7日打卡状态不正确"
);
logger
.
info
(
"uid3七日打卡成功"
);
signRes
=
ContractSignService
.
doSign
(
"2"
,
uid4
);
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid3
);
success
=
signRes
.
jsonPath
().
getString
(
"success"
);
status
=
signRes
.
jsonPath
().
getString
(
"
status"
);
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.
status"
);
Assert
.
assertEquals
(
success
,
"true"
,
"uid4打卡失败"
);
Assert
.
assertEquals
(
status
,
"6"
,
"完成7日打卡状态不正确"
);
logger
.
info
(
"uid4七日打卡成功"
);
}
//
@Test(description = "开奖,活动ID=2",priority = 5)
@Test
(
description
=
"开奖,活动ID=2"
,
priority
=
5
)
public
void
契约开奖
()
throws
Exception
{
modifyIssuePeriod
(
issueId
,
-
1
);
//修改redis的打卡日期键值
String
actId
=
"2"
;
Response
res
=
ContractSignService
.
getContracts
(
actId
,
uid2
);
String
issueId
=
res
.
jsonPath
().
getString
(
"data.list[0].issueId"
);
Date
now
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yy-MM-dd"
);
String
today
=
sdf
.
format
(
now
);
...
...
@@ -244,11 +248,11 @@ public class ContractSign_signTest extends DuibaTestBase {
// 查询下期是否开始
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid3
);
homeInfoRes
.
prettyPrint
();
//
homeInfoRes.prettyPrint();
String
periodShow
=
homeInfoRes
.
jsonPath
().
getString
(
"data.periodShow"
);
Assert
.
assertEquals
(
periodShow
,
period
,
"参与期次号不正确"
);
String
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"
0
"
,
"当前参与状态不正确"
);
Assert
.
assertEquals
(
status
,
"
6
"
,
"当前参与状态不正确"
);
// 查询中奖信息
Response
recordRes
=
ContractSignService
.
getContracts
(
actId
,
uid3
);
String
contractId
=
recordRes
.
jsonPath
().
getString
(
"data.list[0].contractId"
);
...
...
@@ -314,29 +318,33 @@ public class ContractSign_signTest extends DuibaTestBase {
}
private
void
modifyJoinTime
(
String
actId
,
String
date
,
String
startTime
,
String
endTime
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"title"
,
"自动化_报名截止时间"
);
map
.
put
(
"betCount"
,
"1000"
);
map
.
put
(
"bonusType"
,
"0"
);
map
.
put
(
"betType"
,
"2"
);
map
.
put
(
"bankerBonus"
,
"10000"
);
map
.
put
(
"ruleDesc:"
,
"<p>bao ming 截止时间</p>"
);
map
.
put
(
"contractCycle"
,
"7"
);
map
.
put
(
"joinTimeLimit"
,
"false"
);
map
.
put
(
"fakeLimit"
,
"false"
);
map
.
put
(
"rankPeriod"
,
"1"
);
map
.
put
(
"joinTimeStart"
,
startTime
);
map
.
put
(
"joinTimeEnd"
,
endTime
);
map
.
put
(
"joinDeadLine"
,
date
);
map
.
put
(
"actId"
,
actId
);
map
.
put
(
"openStatus"
,
"true"
);
map
.
put
(
"gradientAmountList"
,
""
);
map
.
put
(
"freeJoinLimit"
,
"0"
);
map
.
put
(
"enableAmpifyCard"
,
"false"
);
map
.
put
(
"openType"
,
"0"
);
logger
.
info
(
"请求save接口"
);
Response
response
=
given
().
contentType
(
"application/json"
).
cookies
(
authorization
.
ssoLogin
()).
params
(
map
).
post
(
"https://mng.duibatest.com.cn/newmanager/signContract/save"
);
String
jsonBody
=
String
.
format
(
"{"
+
"\"title\":\"自动化_报名截止时间\","
+
"\"betCount\":1000,"
+
"\"betType\":2,"
+
"\"openType\":0,"
+
"\"rangeList\":[],"
+
"\"enableAmpifyCard\":false,"
+
"\"bonusType\":0,"
+
"\"bankerBonus\":10000,"
+
"\"ruleDesc\":null,"
+
"\"contractCycle\":7,"
+
"\"joinTimeLimit\":false,"
+
"\"fakeLimit\":false,"
+
"\"rankPeriod\":1,"
+
"\"mockValue\":0,"
+
"\"joinTimeStart\": \"%s\","
+
"\"joinTimeEnd\": \"%s\","
+
"\"joinDeadLine\": \"%s\","
+
"\"actId\":%s,"
+
"\"openStatus\":true,"
+
"\"gradientAmountList\":\"\","
+
"\"freeJoinLimit\":0,"
+
"\"fakeRatio\":0"
+
"}"
,
startTime
,
endTime
,
date
,
actId
);
System
.
out
.
println
(
jsonBody
);
Response
response
=
given
().
contentType
(
"application/json;charset=UTF-8"
).
cookies
(
authorization
.
ssoLogin
()).
body
(
jsonBody
).
post
(
"https://mng.duibatest.com.cn/newmanager/signContract/save"
);
response
.
prettyPrint
();
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/signContract/save接口失败"
);
}
catch
(
Exception
e
)
{
...
...
@@ -346,45 +354,37 @@ public class ContractSign_signTest extends DuibaTestBase {
}
}
private
void
modifyIssuePeriod
(
String
actId
,
int
uid
,
int
num
)
throws
Exception
{
Response
res
=
ContractSignService
.
getContracts
(
actId
,
uid
);
// 接口返回的第一条信息为最近参与的记录
String
issueId
=
res
.
jsonPath
().
getString
(
"data.list[0].issueId"
);
String
doneStatus
=
res
.
jsonPath
().
getString
(
"data.list[0].doneStatus"
);
if
(
StringUtils
.
isNotBlank
(
issueId
)
&&
doneStatus
.
equals
(
"DOING"
))
{
String
sql
=
"select start_time,end_time from credits_sign.tb_sign_contract_issue where id="
+
issueId
;
Map
<
String
,
Object
>
result
=
jdbc
.
findSimpleResult
(
sql
);
String
issueStartTime
=
result
.
get
(
"start_time"
).
toString
();
String
issueEndTime
=
result
.
get
(
"end_time"
).
toString
();
private
void
modifyIssuePeriod
(
String
issueId
,
int
num
)
throws
Exception
{
String
sql
=
"select start_time,end_time from credits_sign.tb_sign_contract_issue where id="
+
issueId
;
Map
<
String
,
Object
>
result
=
jdbc
.
findSimpleResult
(
sql
);
String
issueStartTime
=
result
.
get
(
"start_time"
).
toString
();
String
issueEndTime
=
result
.
get
(
"end_time"
).
toString
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
//SimpleDateFormat sdf2 = new SimpleDateFormat("MM-dd");
try
{
Date
startDate
=
sdf
.
parse
(
issueStartTime
);
Date
endDate
=
sdf
.
parse
(
issueEndTime
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
startDate
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
num
);
String
startTime
=
sdf
.
format
(
calendar
.
getTime
());
calendar
.
setTime
(
endDate
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
num
);
String
endTime
=
sdf
.
format
(
calendar
.
getTime
());
String
sql2
=
"update credits_sign.tb_sign_contract_issue set start_time='"
+
startTime
+
"', end_time='"
+
endTime
+
"' where id="
+
issueId
;
try
{
jdbc
.
update
(
sql2
);
}
catch
(
SQLException
e
)
{
logger
.
info
(
"数据库更新异常"
);
}
}
catch
(
ParseException
px
)
{
px
.
printStackTrace
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
//SimpleDateFormat sdf2 = new SimpleDateFormat("MM-dd");
try
{
Date
startDate
=
sdf
.
parse
(
issueStartTime
);
Date
endDate
=
sdf
.
parse
(
issueEndTime
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
startDate
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
num
);
String
startTime
=
sdf
.
format
(
calendar
.
getTime
());
calendar
.
setTime
(
endDate
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
num
);
String
endTime
=
sdf
.
format
(
calendar
.
getTime
());
String
sql2
=
"update credits_sign.tb_sign_contract_issue set start_time='"
+
startTime
+
"', end_time='"
+
endTime
+
"' where id="
+
issueId
;
try
{
jdbc
.
update
(
sql2
);
}
catch
(
SQLException
e
)
{
logger
.
info
(
"数据库更新异常"
);
}
}
else
{
throw
new
Exception
(
"用户没有正在参与的期次"
);
}
catch
(
ParseException
px
)
{
px
.
printStackTrace
(
);
}
}
/**
...
...
src/test/java/http/service/Activity/ContractSignService.java
View file @
72ab0dc1
...
...
@@ -204,7 +204,7 @@ public class ContractSignService {
public
Response
getReward
(
String
ContractId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"
activity
Id"
,
ContractId
);
map
.
put
(
"
contract
Id"
,
ContractId
);
logger
.
info
(
"请求getReward接口,签到活动id="
+
ContractId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/getReward"
);
try
{
...
...
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