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
1e7f8a1b
Commit
1e7f8a1b
authored
Dec 22, 2018
by
qwj-github
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
98401528
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
228 additions
and
26 deletions
+228
-26
pk_瓜分红包_发券测试.java
src/test/java/http/cases/PkTest/pk_瓜分红包_发券测试.java
+157
-0
pk_瓜分红包_首页中奖弹层测试.java
src/test/java/http/cases/PkTest/pk_瓜分红包_首页中奖弹层测试.java
+71
-26
No files found.
src/test/java/http/cases/PkTest/pk_瓜分红包_发券测试.java
0 → 100644
View file @
1e7f8a1b
/**
* Copyright (C), 2015-2018
* FileName: pk_瓜分红包_首页中奖弹层测试
* Author: qianwenjun
* Date: 2018/12/22 12:38
* Description:
*/
package
http
.
cases
.
PkTest
;
import
base.DuibaLog
;
import
base.DuibaTestBase
;
import
com.alibaba.fastjson.JSONObject
;
import
http.model.PkPopPrizeVo
;
import
http.service.Activity.PkService
;
import
http.service.Manager.PkActivityService
;
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
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/22
* @since 1.0.0
*/
public
class
pk_
瓜分红包
_
发券测试
extends
DuibaTestBase
{
@Autowired
PkService
pkService
;
@Autowired
PkActivityService
pkActivityService
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
private
Integer
user01
=
5447
;
//appid=21982
private
Integer
user02
=
5448
;
//appid=21982
// private Integer user03 = 5449;//appid=21982
//
// private Integer user04 = 5450;//appid=21982
List
<
String
>
newBetIds
=
new
ArrayList
<>();
@Test
(
priority
=
0
)
public
void
瓜分红包
_
首页不中奖
_
发券
()
throws
Exception
{
String
newBetId
=
""
;
List
<
String
>
optionsIds
=
new
ArrayList
<>();
String
groupId
=
"199"
;
newBetId
=
createPk
(
"2"
,
"2020-08-12 00:00:00"
,
groupId
);
newBetIds
.
add
(
newBetId
);
List
<
Map
<
String
,
Object
>>
pks
=
jdbc
.
findModeResult
(
"select * from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
logger
.
info
(
"pk活动信息为"
+
JSONObject
.
toJSONString
(
pks
));
for
(
int
i
=
0
;
i
<
pks
.
size
();
i
++){
optionsIds
.
add
(
pks
.
get
(
i
).
get
(
"id"
).
toString
());
}
logger
.
info
(
"pk活动id为:"
+
newBetId
+
",选项id为:"
+
optionsIds
.
toString
());
Response
res1
=
pkService
.
doJoin
(
user01
,
newBetId
,
optionsIds
.
get
(
0
));
Response
res2
=
pkService
.
doJoin
(
user02
,
newBetId
,
optionsIds
.
get
(
1
));
this
.
modifyOpenPrizeTime
(
newBetId
,
60
);
//调用开奖接口
Response
doDrowRresponse
=
pkActivityService
.
doDraw
();
Assert
.
assertEquals
(
doDrowRresponse
.
jsonPath
().
getString
(
"success"
),
"true"
,
"开奖结果校验失败"
);
Assert
.
assertEquals
(
doDrowRresponse
.
jsonPath
().
getString
(
"data"
),
"开奖中。。。"
,
"开奖messag校验失败"
);
Thread
.
sleep
(
8000
);
Response
popRes
=
pkService
.
popup
(
user02
);
popRes
.
prettyPrint
();
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.show"
),
"false"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.totalBonus"
),
"0.0"
,
"校验红包值失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.drawType"
),
"0"
,
"校验开奖类型失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.lucky"
),
"true"
,
"校验不发福袋失败失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.prizeList"
),
null
,
"校验中奖list为null"
);
Response
popRes1
=
pkService
.
popup
(
user01
);
popRes1
.
prettyPrint
();
Assert
.
assertEquals
(
popRes1
.
jsonPath
().
getString
(
"data.show"
),
"true"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes1
.
jsonPath
().
getString
(
"data.totalBonus"
),
"0.1"
,
"校验红包值失败"
);
Assert
.
assertEquals
(
popRes1
.
jsonPath
().
getString
(
"data.drawType"
),
"0"
,
"校验开奖类型失败"
);
Assert
.
assertEquals
(
popRes1
.
jsonPath
().
getString
(
"data.lucky"
),
"false"
,
"校验不发福袋失败失败"
);
List
<
PkPopPrizeVo
>
prizeVoList
=
popRes
.
jsonPath
().
getList
(
"data.prizeList"
,
PkPopPrizeVo
.
class
);
logger
.
info
(
"开奖结果的list为:"
+
JSONObject
.
toJSONString
(
prizeVoList
));
for
(
PkPopPrizeVo
prize:
prizeVoList
){
if
(
prize
.
getBonusType
().
equals
(
"2"
)){
Assert
.
assertEquals
(
prize
.
getTotalBonus
(),
"10"
,
"校验list的瓜分红包金额失败"
);
}
}
}
public
String
createPk
(
String
bounsType
,
String
endTime
,
String
groupId
)
throws
Exception
{
Response
betResponse
=
pkActivityService
.
betForSetUp
(
bounsType
,
endTime
);
logger
.
info
(
"新建pk活动的结果信息为"
+
JSONObject
.
toJSONString
(
betResponse
.
prettyPrint
()));
betResponse
.
prettyPrint
();
String
betId
=
betResponse
.
jsonPath
().
getString
(
"data"
);
logger
.
info
(
"newBetId的信息为"
+
betId
);
Response
betRelation
=
pkActivityService
.
betGroupRelation
(
betId
,
endTime
,
groupId
);
Response
modifyStatusResponse
=
pkActivityService
.
modifySatus
(
betId
);
return
betId
;
}
public
void
modifyOpenPrizeTime
(
String
betId
,
int
x
)
throws
Exception
{
String
endTimeStr
=
"2018-11-26 20:24:39"
;
Boolean
result1
=
jdbc
.
update
(
"update act_com_conf.tb_bet_config set end_time = ? where id = ?\n"
,
endTimeStr
,
betId
);
Boolean
result2
=
jdbc
.
update
(
"update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n"
,
endTimeStr
,
betId
);
}
@AfterClass
public
void
tearDown
()
{
try
{
for
(
String
newBetId:
newBetIds
){
Boolean
result1
=
jdbc
.
update
(
"delete from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
Boolean
result4
=
jdbc
.
update
(
"delete from act_record.tb_bet_record where bet_id = ?"
,
newBetId
);
Boolean
result5
=
jdbc
.
update
(
"delete from bet_activity.tb_bet_result where bet_id = ?"
,
newBetId
);
Boolean
result2
=
jdbc
.
update
(
"delete from act_com_conf.tb_bet_group_relation where bet_id = ?"
,
newBetId
);
Boolean
result3
=
jdbc
.
update
(
"delete from act_com_conf.tb_bet_config where id = ?"
,
newBetId
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
src/test/java/http/cases/PkTest/pk_瓜分红包_首页中奖弹层测试.java
View file @
1e7f8a1b
...
@@ -46,33 +46,29 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
...
@@ -46,33 +46,29 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
private
String
newBetId
=
""
;
private
List
<
String
>
optionsIds
=
new
ArrayList
<>();
//146-pk测试3,pk测试4
private
String
groupId
=
"194"
;
private
Integer
user01
=
5434
;
//appid=21982
private
Integer
user01
=
5434
;
//appid=21982
private
String
consumerId01
=
"100122071"
;
private
String
consumerId01
=
"100122071"
;
private
Integer
user02
=
5435
;
//appid=21982
private
Integer
user02
=
5435
;
//appid=21982
private
String
consumerId02
=
"100122072"
;
private
String
consumerId02
=
"100122072"
;
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public
void
setUpPkActivity
()
{
private
Integer
user03
=
5449
;
//appid=21982
try
{
private
Integer
user04
=
5450
;
//appid=21982
createPk
(
"2"
,
"2020-08-12 00:00:00"
,
groupId
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
List
<
String
>
newBetIds
=
new
ArrayList
<>();
@Test
@Test
(
priority
=
0
)
public
void
瓜分红包
_
首页中奖
()
throws
Exception
{
public
void
瓜分红包
_
首页中奖
()
throws
Exception
{
String
newBetId
=
""
;
List
<
String
>
optionsIds
=
new
ArrayList
<>();
String
groupId
=
"194"
;
newBetId
=
createPk
(
"2"
,
"2020-08-12 00:00:00"
,
groupId
);
newBetIds
.
add
(
newBetId
);
List
<
Map
<
String
,
Object
>>
pks
=
jdbc
.
findModeResult
(
"select * from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
List
<
Map
<
String
,
Object
>>
pks
=
jdbc
.
findModeResult
(
"select * from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
logger
.
info
(
"pk活动信息为"
+
JSONObject
.
toJSONString
(
pks
));
logger
.
info
(
"pk活动信息为"
+
JSONObject
.
toJSONString
(
pks
));
...
@@ -80,7 +76,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
...
@@ -80,7 +76,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
optionsIds
.
add
(
pks
.
get
(
i
).
get
(
"id"
).
toString
());
optionsIds
.
add
(
pks
.
get
(
i
).
get
(
"id"
).
toString
());
}
}
logger
.
info
(
"pk活动id为:"
+
newBetId
+
",选项id为:"
+
optionsIds
.
toString
());
logger
.
info
(
"pk活动id为:"
+
newBetId
+
",选项id为:"
+
optionsIds
.
toString
());
Response
res1
=
pkService
.
doJoin
(
user0
1
,
newBetId
,
optionsIds
.
get
(
0
));
Response
res1
=
pkService
.
doJoin
(
user0
3
,
newBetId
,
optionsIds
.
get
(
0
));
this
.
modifyOpenPrizeTime
(
newBetId
,
60
);
this
.
modifyOpenPrizeTime
(
newBetId
,
60
);
...
@@ -91,7 +87,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
...
@@ -91,7 +87,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
Thread
.
sleep
(
8000
);
Thread
.
sleep
(
8000
);
Response
popRes
=
pkService
.
popup
(
user0
1
);
Response
popRes
=
pkService
.
popup
(
user0
3
);
popRes
.
prettyPrint
();
popRes
.
prettyPrint
();
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.show"
),
"true"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.show"
),
"true"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.totalBonus"
),
"0.1"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.totalBonus"
),
"0.1"
,
"校验是否展示弹层失败"
);
...
@@ -109,8 +105,15 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
...
@@ -109,8 +105,15 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
}
}
@Test
@Test
(
priority
=
2
)
public
void
瓜分红包
_
首页不中奖
()
throws
Exception
{
public
void
瓜分红包
_
首页不中奖
()
throws
Exception
{
String
newBetId
=
""
;
List
<
String
>
optionsIds
=
new
ArrayList
<>();
String
groupId
=
"194"
;
newBetId
=
createPk
(
"2"
,
"2020-08-12 00:00:00"
,
groupId
);
newBetIds
.
add
(
newBetId
);
List
<
Map
<
String
,
Object
>>
pks
=
jdbc
.
findModeResult
(
"select * from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
List
<
Map
<
String
,
Object
>>
pks
=
jdbc
.
findModeResult
(
"select * from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
logger
.
info
(
"pk活动信息为"
+
JSONObject
.
toJSONString
(
pks
));
logger
.
info
(
"pk活动信息为"
+
JSONObject
.
toJSONString
(
pks
));
...
@@ -138,24 +141,64 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
...
@@ -138,24 +141,64 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.drawType"
),
"0"
,
"校验开奖类型失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.drawType"
),
"0"
,
"校验开奖类型失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.lucky"
),
"false"
,
"校验不发福袋失败失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.lucky"
),
"false"
,
"校验不发福袋失败失败"
);
// List<PkPopPrizeVo> prizeVoList = popRes.jsonPath().getList("data.prizeList",PkPopPrizeVo.class);
// logger.info("开奖结果的list为:"+JSONObject.toJSONString(prizeVoList));
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.prizeList"
),
null
,
"校验中奖list为null"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.prizeList"
),
null
,
"校验中奖list为null"
);
}
}
@Test
(
priority
=
1
)
public
void
瓜分红包
_
首页中
_
多次中奖
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
3
;
i
++){
String
newBetId
=
""
;
List
<
String
>
optionsIds
=
new
ArrayList
<>();
String
groupId
=
"194"
;
newBetId
=
createPk
(
"2"
,
"2020-08-12 00:00:00"
,
groupId
);
newBetIds
.
add
(
newBetId
);
List
<
Map
<
String
,
Object
>>
pks
=
jdbc
.
findModeResult
(
"select * from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
logger
.
info
(
"pk活动信息为"
+
JSONObject
.
toJSONString
(
pks
));
for
(
int
j
=
0
;
j
<
pks
.
size
();
j
++){
optionsIds
.
add
(
pks
.
get
(
j
).
get
(
"id"
).
toString
());
}
logger
.
info
(
"pk活动id为:"
+
newBetId
+
",选项id为:"
+
optionsIds
.
toString
());
Response
res1
=
pkService
.
doJoin
(
user04
,
newBetId
,
optionsIds
.
get
(
0
));
this
.
modifyOpenPrizeTime
(
newBetId
,
60
);
}
//调用开奖接口
Response
doDrowRresponse
=
pkActivityService
.
doDraw
();
Assert
.
assertEquals
(
doDrowRresponse
.
jsonPath
().
getString
(
"success"
),
"true"
,
"开奖结果校验失败"
);
Assert
.
assertEquals
(
doDrowRresponse
.
jsonPath
().
getString
(
"data"
),
"开奖中。。。"
,
"开奖messag校验失败"
);
Thread
.
sleep
(
8000
);
Response
popRes
=
pkService
.
popup
(
user04
);
popRes
.
prettyPrint
();
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.show"
),
"true"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.totalBonus"
),
"0.3"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.drawType"
),
"0"
,
"校验开奖类型失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.lucky"
),
"false"
,
"校验不发福袋失败失败"
);
public
void
createPk
(
String
bounsType
,
String
endTime
,
String
groupId
)
throws
Exception
{
List
<
PkPopPrizeVo
>
prizeVoList
=
popRes
.
jsonPath
().
getList
(
"data.prizeList"
,
PkPopPrizeVo
.
class
);
logger
.
info
(
"开奖结果的list为:"
+
JSONObject
.
toJSONString
(
prizeVoList
));
for
(
PkPopPrizeVo
prize:
prizeVoList
){
if
(
prize
.
getBonusType
().
equals
(
"2"
)){
Assert
.
assertEquals
(
prize
.
getTotalBonus
(),
"30"
,
"校验list的瓜分红包金额失败"
);
}
}
}
public
String
createPk
(
String
bounsType
,
String
endTime
,
String
groupId
)
throws
Exception
{
Response
betResponse
=
pkActivityService
.
betForSetUp
(
bounsType
,
endTime
);
Response
betResponse
=
pkActivityService
.
betForSetUp
(
bounsType
,
endTime
);
logger
.
info
(
"新建pk活动的结果信息为"
+
JSONObject
.
toJSONString
(
betResponse
.
prettyPrint
()));
logger
.
info
(
"新建pk活动的结果信息为"
+
JSONObject
.
toJSONString
(
betResponse
.
prettyPrint
()));
betResponse
.
prettyPrint
();
betResponse
.
prettyPrint
();
String
betId
=
betResponse
.
jsonPath
().
getString
(
"data"
);
newBetId
=
betId
;
String
betId
=
betResponse
.
jsonPath
().
getString
(
"data"
);
logger
.
info
(
"newBetId的信息为"
+
newB
etId
);
logger
.
info
(
"newBetId的信息为"
+
b
etId
);
Response
betRelation
=
pkActivityService
.
betGroupRelation
(
betId
,
endTime
,
groupId
);
Response
betRelation
=
pkActivityService
.
betGroupRelation
(
betId
,
endTime
,
groupId
);
Response
modifyStatusResponse
=
pkActivityService
.
modifySatus
(
betId
);
Response
modifyStatusResponse
=
pkActivityService
.
modifySatus
(
betId
);
return
betId
;
}
}
public
void
modifyOpenPrizeTime
(
String
betId
,
int
x
)
throws
Exception
{
public
void
modifyOpenPrizeTime
(
String
betId
,
int
x
)
throws
Exception
{
...
@@ -171,7 +214,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
...
@@ -171,7 +214,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
public
void
tearDown
()
{
public
void
tearDown
()
{
try
{
try
{
for
(
String
newBetId:
newBetIds
){
Boolean
result1
=
jdbc
.
update
(
"delete from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
Boolean
result1
=
jdbc
.
update
(
"delete from act_com_conf.tb_bet_option where bet_id = ?"
,
newBetId
);
Boolean
result4
=
jdbc
.
update
(
"delete from act_record.tb_bet_record where bet_id = ?"
,
newBetId
);
Boolean
result4
=
jdbc
.
update
(
"delete from act_record.tb_bet_record where bet_id = ?"
,
newBetId
);
Boolean
result5
=
jdbc
.
update
(
"delete from bet_activity.tb_bet_result where bet_id = ?"
,
newBetId
);
Boolean
result5
=
jdbc
.
update
(
"delete from bet_activity.tb_bet_result where bet_id = ?"
,
newBetId
);
...
@@ -179,6 +222,8 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
...
@@ -179,6 +222,8 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
Boolean
result3
=
jdbc
.
update
(
"delete from act_com_conf.tb_bet_config where id = ?"
,
newBetId
);
Boolean
result3
=
jdbc
.
update
(
"delete from act_com_conf.tb_bet_config where id = ?"
,
newBetId
);
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
...
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