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
98401528
Commit
98401528
authored
Dec 22, 2018
by
qwj-github
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
75e1af1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
219 additions
and
0 deletions
+219
-0
pk_瓜分红包_首页中奖弹层测试.java
src/test/java/http/cases/PkTest/pk_瓜分红包_首页中奖弹层测试.java
+190
-0
PkPopPrizeVo.java
src/test/java/http/model/PkPopPrizeVo.java
+29
-0
No files found.
src/test/java/http/cases/PkTest/pk_瓜分红包_首页中奖弹层测试.java
0 → 100644
View file @
98401528
/**
* 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.joda.time.DateTime
;
import
org.joda.time.format.DateTimeFormat
;
import
org.joda.time.format.DateTimeFormatter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeMethod
;
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
String
newBetId
=
""
;
private
List
<
String
>
optionsIds
=
new
ArrayList
<>();
//146-pk测试3,pk测试4
private
String
groupId
=
"194"
;
private
Integer
user01
=
5434
;
//appid=21982
private
String
consumerId01
=
"100122071"
;
private
Integer
user02
=
5435
;
//appid=21982
private
String
consumerId02
=
"100122072"
;
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public
void
setUpPkActivity
()
{
try
{
createPk
(
"2"
,
"2020-08-12 00:00:00"
,
groupId
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
@Test
public
void
瓜分红包
_
首页中奖
()
throws
Exception
{
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
));
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
(
user01
);
popRes
.
prettyPrint
();
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.show"
),
"true"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.totalBonus"
),
"0.1"
,
"校验是否展示弹层失败"
);
Assert
.
assertEquals
(
popRes
.
jsonPath
().
getString
(
"data.drawType"
),
"0"
,
"校验开奖类型失败"
);
Assert
.
assertEquals
(
popRes
.
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的瓜分红包金额失败"
);
}
}
}
@Test
public
void
瓜分红包
_
首页不中奖
()
throws
Exception
{
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"
),
"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"
);
}
public
void
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"
);
newBetId
=
betId
;
logger
.
info
(
"newBetId的信息为"
+
newBetId
);
Response
betRelation
=
pkActivityService
.
betGroupRelation
(
betId
,
endTime
,
groupId
);
Response
modifyStatusResponse
=
pkActivityService
.
modifySatus
(
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
{
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/model/PkPopPrizeVo.java
0 → 100644
View file @
98401528
/**
* Copyright (C), 2015-2018
* FileName: PkPopPrizeVo
* Author: qianwenjun
* Date: 2018/12/22 14:07
* Description:
*/
package
http
.
model
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/22
* @since 1.0.0
*/
@Getter
@Setter
public
class
PkPopPrizeVo
{
private
String
bonusType
;
private
String
pluginId
;
private
String
title
;
private
String
totalBonus
;
}
\ No newline at end of file
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