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
be0a8962
Commit
be0a8962
authored
Oct 15, 2018
by
马博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
486e9366
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
641 additions
and
18 deletions
+641
-18
pom.xml
pom.xml
+8
-0
Postman.java
src/test/java/common/Postman.java
+4
-13
RetryToRunCase.java
src/test/java/common/RetryToRunCase.java
+2
-1
TestReport.java
src/test/java/common/TestReport.java
+3
-3
ContractSign_signTest.java
src/test/java/http/cases/SignTest/ContractSign_signTest.java
+404
-0
Signin_signTest.java
src/test/java/http/cases/SignTest/Signin_signTest.java
+1
-1
ContractSignService.java
src/test/java/http/service/Activity/ContractSignService.java
+219
-0
No files found.
pom.xml
View file @
be0a8962
...
@@ -159,6 +159,12 @@
...
@@ -159,6 +159,12 @@
<artifactId>
jsoup
</artifactId>
<artifactId>
jsoup
</artifactId>
<version>
1.10.2
</version>
<version>
1.10.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.6
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
@@ -207,6 +213,7 @@
...
@@ -207,6 +213,7 @@
<noticePerson>
false
</noticePerson>
<noticePerson>
false
</noticePerson>
<sendPlatform>
false
</sendPlatform>
<sendPlatform>
false
</sendPlatform>
<run>
${run}
</run>
<run>
${run}
</run>
<maxRetryCount>
0
</maxRetryCount>
</systemPropertyVariables>
</systemPropertyVariables>
</configuration>
</configuration>
...
@@ -281,6 +288,7 @@
...
@@ -281,6 +288,7 @@
<properties>
<properties>
<run>
**/*_signTest.java
</run>
<run>
**/*_signTest.java
</run>
<threadCount>
1
</threadCount>
<threadCount>
1
</threadCount>
<!--<maxRetryCount>0</maxRetryCount>-->
</properties>
</properties>
<!--公司仓库地址-->
<!--公司仓库地址-->
...
...
src/test/java/common/Postman.java
View file @
be0a8962
...
@@ -22,7 +22,7 @@ public class Postman {
...
@@ -22,7 +22,7 @@ public class Postman {
static
String
dingdingUrl
=
"https://shark.dui88.com/test/integration"
;
static
String
dingdingUrl
=
"https://shark.dui88.com/test/integration"
;
static
String
testPlatformUrl
=
"http://101.37.27.82:8080/insert"
;
static
String
testPlatformUrl
=
"http://101.37.27.82:8080/insert"
;
//dingdingUrl="http://www.json.cn/";
//dingdingUrl="http://www.json.cn/";
private
Logger
logger
=
LogManager
.
getLogger
(
Postman
.
class
);
private
static
Logger
logger
=
LogManager
.
getLogger
(
Postman
.
class
);
public
static
void
send2Dingding
(
Map
result
){
public
static
void
send2Dingding
(
Map
result
){
System
.
out
.
println
(
"Dingding:"
+
result
);
System
.
out
.
println
(
"Dingding:"
+
result
);
RestAssuredConfig
config
=
RestAssured
.
config
();
RestAssuredConfig
config
=
RestAssured
.
config
();
...
@@ -31,20 +31,14 @@ public class Postman {
...
@@ -31,20 +31,14 @@ public class Postman {
.
setParam
(
CoreConnectionPNames
.
CONNECTION_TIMEOUT
,
150000
)
// Remote host connection time
.
setParam
(
CoreConnectionPNames
.
CONNECTION_TIMEOUT
,
150000
)
// Remote host connection time
.
setParam
(
CoreConnectionPNames
.
SO_TIMEOUT
,
150000
)
;
// Remote host response time
.
setParam
(
CoreConnectionPNames
.
SO_TIMEOUT
,
150000
)
;
// Remote host response time
Response
response
=
given
().
relaxedHTTPSValidation
().
contentType
(
ContentType
.
JSON
).
body
(
result
).
post
(
dingdingUrl
);
Response
response
=
given
().
relaxedHTTPSValidation
().
contentType
(
ContentType
.
JSON
).
body
(
result
).
post
(
dingdingUrl
);
System
.
out
.
println
(
"--------DingdingTest--------:"
);
logger
.
info
(
"钉钉响应数据:"
+
response
.
asString
());
response
.
prettyPrint
();
System
.
out
.
println
(
"--------DingdingTest1--------:"
);
Boolean
bl
=
response
.
jsonPath
().
getString
(
"success"
).
equals
(
"false"
);
Boolean
bl
=
response
.
jsonPath
().
getString
(
"success"
).
equals
(
"false"
);
if
(
bl
){
if
(
bl
){
String
[]
name
=
DingdingResult
.
name
;
String
[]
name
=
DingdingResult
.
name
;
result
.
put
(
"names"
,
name
);
result
.
put
(
"names"
,
name
);
response
=
given
().
contentType
(
ContentType
.
JSON
).
body
(
result
).
post
(
dingdingUrl
);
response
=
given
().
contentType
(
ContentType
.
JSON
).
body
(
result
).
post
(
dingdingUrl
);
System
.
out
.
println
(
"--------DingdingTest2--------:"
);
logger
.
info
(
"钉钉重试响应数据:"
+
response
.
asString
());
response
.
prettyPrint
();
System
.
out
.
println
(
"--------DingdingTest2--------:"
);
}
}
...
@@ -52,10 +46,7 @@ public class Postman {
...
@@ -52,10 +46,7 @@ public class Postman {
public
static
void
sendTestPlatform
(
Map
result
){
public
static
void
sendTestPlatform
(
Map
result
){
Response
response
=
given
().
contentType
(
ContentType
.
JSON
).
body
(
result
).
post
(
testPlatformUrl
);
Response
response
=
given
().
contentType
(
ContentType
.
JSON
).
body
(
result
).
post
(
testPlatformUrl
);
System
.
out
.
println
(
"--------testPlatform--------:"
);
logger
.
info
(
"自动化数据收集平台响应数据:"
+
response
.
asString
());
response
.
prettyPrint
();
System
.
out
.
println
(
"--------testPlatform--------:"
);
}
}
public
static
Boolean
getName
(){
public
static
Boolean
getName
(){
Calendar
c
=
Calendar
.
getInstance
();
Calendar
c
=
Calendar
.
getInstance
();
...
...
src/test/java/common/RetryToRunCase.java
View file @
be0a8962
...
@@ -8,8 +8,9 @@ import org.testng.ITestResult;
...
@@ -8,8 +8,9 @@ import org.testng.ITestResult;
*/
*/
public
class
RetryToRunCase
implements
IRetryAnalyzer
{
public
class
RetryToRunCase
implements
IRetryAnalyzer
{
private
int
retryCount
=
0
;
private
int
retryCount
=
0
;
private
int
maxRetryCount
=
0
;
// retry a failed test 2 additional times
private
int
maxRetryCount
=
Integer
.
valueOf
(
System
.
getProperty
(
"maxRetryCount"
))
;
// retry a failed test 2 additional times
public
boolean
retry
(
ITestResult
result
)
{
public
boolean
retry
(
ITestResult
result
)
{
System
.
out
.
println
(
"~~~~~~~~~~~~~~~~~maxRetryCount~~~~~~~~~~~~~~~~~~~~~~~:"
+
maxRetryCount
);
if
(
retryCount
<
maxRetryCount
)
{
if
(
retryCount
<
maxRetryCount
)
{
retryCount
++;
retryCount
++;
return
true
;
return
true
;
...
...
src/test/java/common/TestReport.java
View file @
be0a8962
...
@@ -63,8 +63,8 @@ public class TestReport implements IReporter{
...
@@ -63,8 +63,8 @@ public class TestReport implements IReporter{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
map
.
put
(
"failCase"
,
failCase
);
map
.
put
(
"failCase"
,
failCase
);
logger
.
in
fo
(
"gson.toJson(ddResult)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
);
// logger.in
fo("gson.toJson(ddResult)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
logger
.
info
(
"
钉钉通知
:"
+
gson
.
toJson
(
map
));
logger
.
info
(
"
测试结果通知信息
:"
+
gson
.
toJson
(
map
));
//发送运行结果到自动化数据收集平台
//发送运行结果到自动化数据收集平台
if
(
sendPlatform
)
if
(
sendPlatform
)
Postman
.
sendTestPlatform
(
map
);
Postman
.
sendTestPlatform
(
map
);
...
@@ -73,7 +73,7 @@ public class TestReport implements IReporter{
...
@@ -73,7 +73,7 @@ public class TestReport implements IReporter{
if
(!
noticePerson
){
if
(!
noticePerson
){
map
.
put
(
"names"
,
new
ArrayList
<>());
map
.
put
(
"names"
,
new
ArrayList
<>());
}
}
logger
.
info
(
"noticeDD:"
+
noticeDD
);
//
logger.info("noticeDD:"+noticeDD);
Postman
.
send2Dingding
(
map
);
Postman
.
send2Dingding
(
map
);
}
}
...
...
src/test/java/http/cases/SignTest/ContractSign_signTest.java
0 → 100644
View file @
be0a8962
package
http
.
cases
.
SignTest
;
import
common.DuibaLog
;
import
common.DuibaTestBase
;
import
common.MysqlConnPool
;
import
common.MysqlUtils
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.ContractSignService
;
import
http.service.Authorization
;
import
http.service.hd.SigninService
;
import
io.restassured.response.Response
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
java.sql.SQLException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by songbo on 2018/9/5.
*/
public
class
ContractSign_signTest
extends
DuibaTestBase
{
@Autowired
SigninService
signinService
;
@Autowired
Authorization
authorization
;
@Autowired
ContractSignService
ContractSignService
;
@Autowired
ManagerService
managerService
;
@Value
(
"${activity.host}"
)
String
activityHost
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
//指定用户
private
static
int
uid1
=
3743
;
//100085126
private
static
int
uid2
=
3719
;
//100085018
private
static
int
uid3
=
3720
;
//100085019
private
static
int
uid4
=
3721
;
//100085020
@BeforeClass
public
void
beforeclass
()
{
this
.
clearIssue
(
"100085126"
,
"2"
,
jdbc
);
}
// @AfterClass
// public void afterclass() {
// jdbc.releaseConn();
// }
@Test
(
description
=
"截止报名测试, 活动ID=3"
,
priority
=
10
)
public
void
截止报名测试
()
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
"3"
);
map
.
put
(
"betAmount"
,
"1000"
);
Response
doJoinRes
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid1
,
true
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/doJoin"
);
String
code
=
doJoinRes
.
jsonPath
().
getString
(
"code"
);
String
success
=
doJoinRes
.
jsonPath
().
getString
(
"success"
);
Assert
.
assertEquals
(
success
,
"false"
,
"报名成功状态不正确"
);
Assert
.
assertEquals
(
code
,
"200001"
,
"报名失败的错误码不正确"
);
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
"3"
,
uid1
);
String
suspend
=
homeInfoRes
.
jsonPath
().
getString
(
"data.suspend"
);
Assert
.
assertEquals
(
suspend
,
"true"
,
"活动报名截止状态不正确"
);
// 清除报名截止时间
modifyJoinTime
(
"3"
,
""
,
"00:00"
,
"00:00"
);
String
queryDeadLine
=
"select * from credits_sign.tb_sign_contract where id = 3"
;
Map
<
String
,
Object
>
result
=
jdbc
.
findSimpleResult
(
queryDeadLine
);
String
deadLine
=
result
.
get
(
"join_dead_line"
).
toString
();
Assert
.
assertEquals
(
deadLine
,
""
,
"清除报名截止时间失败"
);
//重新设置报名截止时间
modifyJoinTime
(
"3"
,
"2018-01-01 00:00"
,
"00:00"
,
"00:00"
);
result
=
jdbc
.
findSimpleResult
(
queryDeadLine
);
deadLine
=
result
.
get
(
"join_dead_line"
).
toString
();
Assert
.
assertEquals
(
deadLine
,
"2018-01-01 14:00:00.0"
,
"设置报名截止时间失败"
);
}
@Test
(
description
=
"契约签到报名测试, 活动ID=2"
,
priority
=
1
)
public
void
契约签到报名
()
throws
Exception
{
String
actId
=
"2"
;
String
betAmount
=
"1000"
;
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
format2
=
new
SimpleDateFormat
(
"MMdd"
);
Date
date
=
new
Date
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
date
=
calendar
.
getTime
();
// 期次开始的时间 yyyy-MM-dd格式
String
startTime
=
format
.
format
(
date
);
// 期次号 MMDD格式
String
period
=
format2
.
format
(
date
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
6
);
date
=
calendar
.
getTime
();
// 期次结束时间
String
endTime
=
format
.
format
(
date
);
// 报名
Map
<
String
,
String
>
map
=
this
.
doJoinResult
(
actId
,
betAmount
,
uid1
);
//int totalCount = Integer.valueOf(map.get("totalCount"));
//int buyers = Integer.valueOf(map.get("buyers"));
String
doneStatusDesc
=
map
.
get
(
"doneStatusDesc"
);
Assert
.
assertEquals
(
map
.
get
(
"doneStatus"
),
"DOING"
,
String
.
format
(
"%d join failed, %s"
,
uid1
,
doneStatusDesc
));
Assert
.
assertEquals
(
map
.
get
(
"betCount"
),
betAmount
,
"Returned a wrong betCount"
);
Assert
.
assertEquals
(
map
.
get
(
"cycle"
),
"7"
,
"returned a wrong cycle day"
);
Assert
.
assertEquals
(
map
.
get
(
"startTime"
),
startTime
,
"the start time of the period is wrong"
);
Assert
.
assertEquals
(
map
.
get
(
"endTime"
),
endTime
,
"the end time of the period is wrong"
);
map
=
this
.
doJoinResult
(
actId
,
betAmount
,
uid2
);
Assert
.
assertEquals
(
map
.
get
(
"doneStatus"
),
"DOING"
,
String
.
format
(
"%d join failed, %s"
,
uid2
,
doneStatusDesc
));
map
=
this
.
doJoinResult
(
actId
,
betAmount
,
uid3
);
Assert
.
assertEquals
(
map
.
get
(
"doneStatus"
),
"DOING"
,
String
.
format
(
"%d join failed, %s"
,
uid3
,
doneStatusDesc
));
map
=
this
.
doJoinResult
(
actId
,
betAmount
,
uid4
);
Assert
.
assertEquals
(
map
.
get
(
"doneStatus"
),
"DOING"
,
String
.
format
(
"%d join failed, %s"
,
uid4
,
doneStatusDesc
));
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid1
);
homeInfoRes
.
prettyPrint
();
// String joinTimeLimit = homeInfoRes.jsonPath().getString("data.joinTimeLimit");
// Assert.assertEquals(joinTimeLimit,"true", "参与时间限制校验失败");
String
betCount
=
homeInfoRes
.
jsonPath
().
getString
(
"data.betCount"
);
Assert
.
assertEquals
(
betCount
,
betAmount
,
"报名的额度不正确"
);
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
,
"参与期次号不正确"
);
String
currentPeriod
=
homeInfoRes
.
jsonPath
().
getString
(
"data.currentPeriod"
);
Assert
.
assertEquals
(
currentPeriod
,
"0"
,
"当前期次进度不正确"
);
//0-未报名 1-报名中 2-已报名,打卡未开始 3-未打卡:打卡开始,当天未打卡 4-已打卡:当天已打卡(非最后一天) 5-失败:出现断卡(未报名新一期) 6-成功: 已成功(未报名新一期)
String
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"2"
,
"当前参与状态不正确"
);
String
bankerBonus
=
homeInfoRes
.
jsonPath
().
getString
(
"data.bankerBonus"
);
Assert
.
assertEquals
(
bankerBonus
,
"10000"
,
"保底奖池数量不正确"
);
int
totalCount_new
=
Integer
.
valueOf
(
homeInfoRes
.
jsonPath
().
getString
(
"data.betTotalCount"
));
Assert
.
assertEquals
(
totalCount_new
,
10000
+
Integer
.
valueOf
(
betAmount
)*
4
,
"报名后奖池数量不正确"
);
}
@Test
(
description
=
"活动ID=2, uid1打卡"
,
priority
=
2
)
public
void
签到打卡
()
throws
Exception
{
String
actId
=
"2"
;
//修改期次,今日为打卡日
modifyIssuePeriod
(
actId
,
uid1
,-
1
);
Date
now
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"MMdd"
);
String
today
=
sdf
.
format
(
now
);
// 打卡前请求homeInfo接口
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid1
);
String
currentPeriod
=
homeInfoRes
.
jsonPath
().
getString
(
"data.currentPeriod"
);
Assert
.
assertEquals
(
currentPeriod
,
"1"
,
"当前非打卡第一天"
);
String
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"3"
,
"未打卡前打卡状态不正确"
);
String
periodShow
=
homeInfoRes
.
jsonPath
().
getString
(
"data.periodShow"
);
Assert
.
assertEquals
(
periodShow
,
today
,
"期次号不正确"
);
//打卡
Response
signRes
=
ContractSignService
.
doSign
(
"2"
,
uid1
);
String
success
=
signRes
.
jsonPath
().
getString
(
"success"
);
Assert
.
assertEquals
(
success
,
"true"
,
"打卡失败"
);
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actId
,
uid1
);
String
daySuccCount
=
homeInfoRes
.
jsonPath
().
getString
(
"data.daySuccCount"
);
Assert
.
assertEquals
(
daySuccCount
,
"1"
,
"打卡后,打卡成功人数不正确"
);
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"4"
,
"打卡完成后状态不正确"
);
}
@Test
(
description
=
"活动ID=2,uid2第六天断签"
,
priority
=
3
)
public
void
契约签到断签
()
throws
Exception
{
String
actID
=
"2"
;
//当天为周期第一天,周期往前再挪6天
modifyIssuePeriod
(
actID
,
uid2
,-
6
);
//补签前5天,第六天不签
this
.
contractResign
(
actID
,
uid2
,
7
,
true
);
Response
homeInfoRes
=
ContractSignService
.
getHomeInfo
(
actID
,
uid2
);
homeInfoRes
.
prettyPrint
();
String
status
=
homeInfoRes
.
jsonPath
().
getString
(
"data.status"
);
Assert
.
assertEquals
(
status
,
"5"
,
"当前签到状态不正确"
);
Date
now
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"MM-dd"
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
now
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
-
1
);
String
yesterday
=
sdf
.
format
(
calendar
.
getTime
());
String
failDate
=
homeInfoRes
.
jsonPath
().
getString
(
"data.failDate"
);
Assert
.
assertEquals
(
failDate
,
yesterday
,
"断签日期不正确"
);
}
//@Test(description = "打卡完成,活动ID=2",priority = 4)
public
void
契约签到整期打卡完成
()
throws
Exception
{
//
}
//@Test(description = "开奖,活动ID=2",priority = 5)
public
void
契约开奖
()
throws
Exception
{
//
}
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"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"totalCount"
,
doJoinRes
.
jsonPath
().
getString
(
"data.betCount"
));
map
.
put
(
"buyers"
,
doJoinRes
.
jsonPath
().
getString
(
"data.buyers"
));
map
.
put
(
"cycle"
,
doJoinRes
.
jsonPath
().
getString
(
"data.contractCycle"
));
map
.
put
(
"contractId"
,
doJoinRes
.
jsonPath
().
getString
(
"data.contractId"
));
map
.
put
(
"issueId"
,
doJoinRes
.
jsonPath
().
getString
(
"data.issueId"
));
map
.
put
(
"startTime"
,
doJoinRes
.
jsonPath
().
getString
(
"data.startTime"
));
map
.
put
(
"endTime"
,
doJoinRes
.
jsonPath
().
getString
(
"data.endTime"
));
int
count
=
15
;
Response
betStatusRes
=
ContractSignService
.
betStatus
(
contractId
,
uid
);
map
.
put
(
"betCount"
,
betStatusRes
.
jsonPath
().
getString
(
"data.betCount"
));
String
status
=
"INIT"
;
String
statusDesc
=
""
;
while
(
count
>
0
&&
status
.
equals
(
"INIT"
)){
Thread
.
sleep
(
500
);
betStatusRes
=
ContractSignService
.
betStatus
(
contractId
,
uid
);
status
=
betStatusRes
.
jsonPath
().
getString
(
"data.doneStatus"
);
statusDesc
=
betStatusRes
.
jsonPath
().
getString
(
"data.doneStatusDesc"
);
count
--;
}
map
.
put
(
"doneStatus"
,
status
);
logger
.
info
(
"报名status:"
+
status
);
map
.
put
(
"doneStatusDesc"
,
statusDesc
);
return
map
;
}
private
void
clearIssue
(
String
consumerId
,
String
actId
,
MysqlConnPool
jdbc
){
try
{
Map
<
String
,
Object
>
result
=
jdbc
.
findSimpleResult
(
"select id, issue_id from credits_sign.tb_sign_contract_bet where consumer_id="
+
consumerId
+
" and act_id="
+
actId
);
if
(!
result
.
isEmpty
())
{
String
issueId
=
result
.
get
(
"issue_id"
).
toString
();
//String contractId = result.get("id").toString();
jdbc
.
update
(
"delete from credits_sign.tb_sign_contract_issue where id="
+
issueId
);
jdbc
.
update
(
"delete from credits_sign.tb_sign_contract_bet where issue_id="
+
issueId
);
//jdbc.update("delete from credits_sign.tb_sign_contract_log where issue_id=" + issueId);
}
}
catch
(
SQLException
e
){
logger
.
info
(
"数据库更新异常"
);
}
}
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
(
"betType"
,
"2"
);
map
.
put
(
"bankerBonus"
,
"10000"
);
map
.
put
(
"ruleDesc:"
,
"<p>bao ming 截止时间</p>"
);
map
.
put
(
"contractCycle"
,
"7"
);
map
.
put
(
"joinTimeLimit"
,
"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"
);
logger
.
info
(
"请求save接口"
);
Response
response
=
given
().
contentType
(
"application/x-www-form-urlencoded;charset=UTF-8"
).
cookies
(
authorization
.
ssoLogin
()).
params
(
map
).
post
(
"https://mng.duibatest.com.cn/newmanager/signContract/save"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/signContract/save接口失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/signContract/save接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/signContract/save接口失败,返回信息:"
+
response
.
asString
());
}
}
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
();
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
();
}
}
else
{
throw
new
Exception
(
"用户没有正在参与的期次"
);
}
}
/**
* 补签今日之前的日期
* @param actId
* @param uid
* @param num 当前所在周期内第几天
* @param isBlock 不补签昨天
* @throws Exception
*/
private
void
contractResign
(
String
actId
,
int
uid
,
int
num
,
boolean
isBlock
)
throws
Exception
{
//查询issueId,contractId
Response
res
=
ContractSignService
.
getContracts
(
actId
,
uid
);
// 接口返回的第一条信息为最近参与的记录
String
issueId
=
res
.
jsonPath
().
getString
(
"data.list[0].issueId"
);
String
contractId
=
res
.
jsonPath
().
getString
(
"data.list[0].contractId"
);
if
(
StringUtils
.
isNotBlank
(
issueId
)
&&
StringUtils
.
isNotBlank
(
contractId
))
{
// 查询签到历史记录
String
queryLog
=
"select sign_date from credits_sign.tb_sign_contract_log where id="
+
contractId
;
List
<
Map
<
String
,
Object
>>
result
=
jdbc
.
findModeResult
(
queryLog
);
String
signedDate
;
List
<
String
>
dateList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++)
{
signedDate
=
result
.
get
(
i
).
get
(
"sign_date"
).
toString
();
dateList
.
add
(
signedDate
);
}
String
queryBet
=
"select consumer_id from credits_sign.tb_sign_contract_bet where id="
+
contractId
;
Map
<
String
,
Object
>
betResult
=
jdbc
.
findSimpleResult
(
queryBet
);
String
consumerId
=
betResult
.
get
(
"consumer_id"
).
toString
();
// 查询期次开始时间
String
queryPeriod
=
"select start_time, end_time, contract_cycle, winners from credits_sign.tb_sign_contract_issue where id="
+
issueId
;
Map
<
String
,
Object
>
issueResult
=
jdbc
.
findSimpleResult
(
queryPeriod
);
String
startDate
=
issueResult
.
get
(
"start_time"
).
toString
();
String
endDate
=
issueResult
.
get
(
"end_time"
).
toString
();
int
cycle
=
Integer
.
valueOf
(
issueResult
.
get
(
"contract_cycle"
).
toString
());
String
winners
=
issueResult
.
get
(
"winners"
).
toString
();
//需要打卡的日期
int
period
=
num
;
int
flag
=
0
;
if
(
num
>
cycle
)
{
period
=
cycle
+
1
;
}
if
(
isBlock
&&
result
.
size
()
==
0
)
{
flag
=
1
;
}
List
<
String
>
signDateList
=
new
ArrayList
<>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Date
startTime
=
sdf
.
parse
(
startDate
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
startTime
);
String
signDate
;
for
(
int
i
=
1
;
i
<
period
-
flag
;
i
++)
{
signDate
=
sdf
.
format
(
calendar
.
getTime
());
if
(!
dateList
.
contains
(
signDate
))
{
signDateList
.
add
(
signDate
);
}
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
}
String
updateBet
;
String
updateLog
;
if
(
num
<=
cycle
)
{
updateBet
=
"update credits_sign.tb_sign_contract_bet set done_days="
+
String
.
valueOf
(
num
-
1
-
flag
)
+
" where id="
+
contractId
;
try
{
jdbc
.
update
(
updateBet
);
if
(
signDateList
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
signDateList
.
size
();
i
++)
{
updateLog
=
String
.
format
(
"INSERT INTO credits_sign.tb_sign_contract_log(consumer_id, contract_id, act_id, issue_id, sign_date) VALUES (%s, %s, %s, %s, \'%s\')"
,
consumerId
,
contractId
,
actId
,
issueId
,
signDateList
.
get
(
i
));
jdbc
.
update
(
updateLog
);
logger
.
info
(
"补签成功"
);
}
}
}
catch
(
SQLException
e
)
{
logger
.
info
(
"数据库更新异常"
);
}
}
}
else
{
logger
.
info
(
"未执行补签"
);
}
}
}
src/test/java/http/cases/SignTest/Signin_signTest.java
View file @
be0a8962
...
@@ -164,7 +164,7 @@ public class Signin_signTest extends DuibaTestBase {
...
@@ -164,7 +164,7 @@ public class Signin_signTest extends DuibaTestBase {
Assert
.
assertEquals
(
act
,
exp
,
"积分与预期不符"
);
Assert
.
assertEquals
(
act
,
exp
,
"积分与预期不符"
);
//校验consumer和user表的积分
//校验consumer和user表的积分
Thread
.
sleep
(
2000
);
Thread
.
sleep
(
2000
);
consumerCredits
=
jdbc
.
findSimpleResult
(
"select * from consumer.consumer_0010 where id=100028002"
);
consumerCredits
=
jdbc
.
findSimpleResult
(
"select * from
new_
consumer.consumer_0010 where id=100028002"
);
Map
userCredits
=
jdbc
.
findSimpleResult
(
"select * from dafuweng.user where id ="
+
uid
);
Map
userCredits
=
jdbc
.
findSimpleResult
(
"select * from dafuweng.user where id ="
+
uid
);
Assert
.
assertEquals
(
consumerCredits
.
get
(
"credits"
).
toString
().
trim
(),
String
.
valueOf
(
exp
),
"consumer积分与预期不符"
);
Assert
.
assertEquals
(
consumerCredits
.
get
(
"credits"
).
toString
().
trim
(),
String
.
valueOf
(
exp
),
"consumer积分与预期不符"
);
Assert
.
assertEquals
(
userCredits
.
get
(
"credits"
).
toString
().
trim
(),
String
.
valueOf
(
exp
),
"user积分与预期不符"
);
Assert
.
assertEquals
(
userCredits
.
get
(
"credits"
).
toString
().
trim
(),
String
.
valueOf
(
exp
),
"user积分与预期不符"
);
...
...
src/test/java/http/service/Activity/ContractSignService.java
0 → 100644
View file @
be0a8962
package
http
.
service
.
Activity
;
import
common.DuibaLog
;
import
http.service.Authorization
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.testng.Assert
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* @author songbo 契约签到
*/
@Service
public
class
ContractSignService
{
@Value
(
"${activity.host}"
)
String
activityHost
;
@Value
(
"${hdserver.host}"
)
String
hdHost
;
@Autowired
Authorization
authorization
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
/**
* 契约签到报名
* @param betAmount 参与额度
* @param activityId 签到活动id
* @param uid 用户ID
* @return
* @throws Exception
*/
public
Response
doJoin
(
String
activityId
,
String
betAmount
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
map
.
put
(
"betAmount"
,
betAmount
);
logger
.
info
(
String
.
format
(
"%d 请求doJoin接口,签到活动id=%s, 参与额度betAmount=%s"
,
uid
,
activityId
,
betAmount
));
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
,
true
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/doJoin"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/doJoin接口失败"
);
logger
.
info
(
String
.
format
(
"%d 报名成功"
,
uid
));
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/doJoin报名失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/doJoin接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
doSign
(
String
activityId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
logger
.
info
(
"请求doSign接口,签到活动id="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/doSign"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/doSign接口失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/doSign接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/doSign接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
getHomeInfo
(
String
activityId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
logger
.
info
(
"请求getHomeInfo接口,签到活动id="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
get
(
activityHost
+
"/sign/contract/getHomeInfo"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/getHomeInfo接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/getHomeInfo接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/getHomeInfo接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
getFreshJoinInfo
(
String
activityId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
logger
.
info
(
"geFreshJoinInfo,签到活动id="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/geFreshJoinInfo"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/geFreshJoinInfo接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/geFreshJoinInfo接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/geFreshJoinInfo接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
/**
*
* @param activityId
* @param topNum 排名top,不超过100
* @param showType 1-打卡次数;2-收益总额
* @param uid
* @return
* @throws Exception
*/
public
Response
getContractRank
(
String
activityId
,
String
topNum
,
String
showType
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
map
.
put
(
"topNum"
,
topNum
);
map
.
put
(
"showType"
,
showType
);
logger
.
info
(
"请求geContractRank接口,签到活动id="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/geContractRank"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/geContractRank接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/geContractRank接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/geContractRank接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
getRewardTodayLimit200
(
String
activityId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
logger
.
info
(
"请求getRewardTodayLimit200接口,签到活动id="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/getRewardTodayLimit200"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/getRewardTodayLimit200接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/getRewardTodayLimit200接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/getRewardTodayLimit200接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
getContracts
(
String
activityId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
logger
.
info
(
"请求getContracts接口,签到活动id="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/getContracts"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/getContracts接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/getContracts接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/getContracts接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
getRewardRank
(
String
activityId
,
String
topNum
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
map
.
put
(
"topNum"
,
topNum
);
logger
.
info
(
"请求getRewardRank接口,签到活动id="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/getRewardRank"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/getRewardRank接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/getRewardRank接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/getRewardRank接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
getJoinStatics
(
String
activityId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
logger
.
info
(
"请求getJoinStatics接口,签到活动id="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/getJoinStatics"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/getJoinStatics接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/getJoinStatics接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/getJoinStatics接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
betStatus
(
String
ContractId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"contractId"
,
ContractId
);
logger
.
info
(
"查询betStatus接口,契约id="
+
ContractId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
,
true
)).
params
(
map
).
post
(
activityHost
+
"/sign/contract/betStatus"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/sign/contract/betStatus接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/betStatus接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/betStatus接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
getReward
(
String
ContractId
,
int
uid
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
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接口请求失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/sign/contract/getReward接口失败,返回信息"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/sign/contract/getReward接口失败,返回信息:"
+
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