Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oto
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
龚小红
oto
Commits
b7dfa753
Commit
b7dfa753
authored
Aug 26, 2021
by
xiamengchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
e4f9ceae
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
669 additions
and
394 deletions
+669
-394
AnchorGetSKList.java
src/test/java/com/kjj/bean/secondKill/AnchorGetSKList.java
+9
-0
LiveMaterial.java
...test/java/com/kjj/cases/live/liveConfig/LiveMaterial.java
+0
-118
SaveLive.java
src/test/java/com/kjj/cases/live/liveConfig/SaveLive.java
+0
-94
ConfSecondKill.java
...st/java/com/kjj/cases/live/secondKill/ConfSecondKill.java
+231
-0
ManagerConfGoods.java
.../java/com/kjj/cases/live/secondKill/ManagerConfGoods.java
+151
-0
SecondKill.java
src/test/java/com/kjj/cases/live/secondKill/SecondKill.java
+75
-0
BasicConfig.java
src/test/java/com/kjj/config/BasicConfig.java
+5
-0
liveTestNG.xml
src/test/liveTestNG.xml
+198
-182
No files found.
src/test/java/com/kjj/bean/secondKill/AnchorGetSKList.java
0 → 100644
View file @
b7dfa753
package
com
.
kjj
.
bean
.
secondKill
;
import
lombok.Data
;
@Data
public
class
AnchorGetSKList
{
private
int
interactStatus
;
private
long
id
;
}
src/test/java/com/kjj/cases/live/liveConfig/LiveMaterial.java
View file @
b7dfa753
...
...
@@ -17,15 +17,6 @@ import org.testng.annotations.Test;
import
java.util.*
;
public
class
LiveMaterial
implements
Authorization
{
private
final
String
killGoodsImg
=
"https://yun.dui88.com/kjy/image/20210818/1629269441692.jpeg"
;
private
final
String
killGoodsHeadImg
=
"https://yun.dui88.com/kjy/image/20210818/1629269453038.jpeg"
;
private
final
String
killGoodsPicture
=
"https://yun.dui88.com/kjy/image/20210818/1629269488947.jpeg"
;
private
final
long
companyId
=
101
;
// 直播公司ID
private
final
String
newGoodsTitle
=
"秒杀商品1"
;
private
long
skGoodsId
;
// 秒杀商品id
private
int
pageNum
;
// 秒杀商品分页数
private
int
goodsCount
;
// 当前页面商品数量
public
static
String
skGoodsTitle
=
"编辑秒杀商品"
;
//秒杀商品名称
@BeforeClass
public
void
setUp
()
{
...
...
@@ -363,114 +354,5 @@ public class LiveMaterial implements Authorization {
}
// 配置公司秒杀商品
@Test
(
description
=
"添加秒杀商品"
,
priority
=
15
)
public
void
添加秒杀商品
()
{
List
<
String
>
killGoodsHeadImgs
=
new
ArrayList
<>();
List
<
String
>
killGoodsPictures
=
new
ArrayList
<>();
killGoodsHeadImgs
.
add
(
killGoodsHeadImg
);
killGoodsPictures
.
add
(
killGoodsPicture
);
Map
<
String
,
Object
>
killGoodsPar
=
new
HashMap
<>();
killGoodsPar
.
put
(
"goodsImg"
,
killGoodsImg
);
killGoodsPar
.
put
(
"goodsHeadImg"
,
killGoodsHeadImgs
);
killGoodsPar
.
put
(
"goodsPictures"
,
killGoodsPictures
);
killGoodsPar
.
put
(
"companyId"
,
companyId
);
killGoodsPar
.
put
(
"goodsTitle"
,
newGoodsTitle
);
killGoodsPar
.
put
(
"goodsExplain"
,
"文字说明"
);
Response
killGoodsRes
=
network
.
postResponse
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
);
Assert
.
assertTrue
(
killGoodsRes
.
jsonPath
().
getBoolean
(
"success"
));
boolean
data
=
killGoodsRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"添加秒杀商品失败"
,
killGoodsRes
.
body
().
asString
()));
}
@Test
(
description
=
"获取秒杀商品列表"
,
priority
=
16
)
public
void
获取秒杀商品列表
()
{
Map
<
String
,
Object
>
skGoodsListsPar
=
new
HashMap
<>();
skGoodsListsPar
.
put
(
"companyId"
,
companyId
);
// 默认pageSize=20,pageNo=1
try
{
Response
skGoodsListsRes
=
network
.
getResponse
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
);
long
totalCount
=
skGoodsListsRes
.
jsonPath
().
getLong
(
"data.totalCount"
);
if
(
totalCount
>
20
){
pageNum
=
(
int
)
totalCount
/
20
+
1
;
skGoodsListsPar
.
put
(
"pageSize"
,
20
);
skGoodsListsPar
.
put
(
"pageNo"
,
pageNum
);
System
.
out
.
println
();
skGoodsListsRes
=
network
.
getResponse
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
);
}
List
<
KillGoodsList
>
killGoodsLists
=
JsonUtil
.
parseResponseToPageBean
(
skGoodsListsRes
,
KillGoodsList
.
class
);
goodsCount
=
killGoodsLists
.
size
();
KillGoodsList
killGoodsList
=
killGoodsLists
.
get
(
0
);
String
goodsTitle
=
killGoodsList
.
getGoodsTitle
();
Assert
.
assertEquals
(
goodsTitle
,
newGoodsTitle
,
network
.
message
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
,
"新增商品错误"
,
skGoodsListsRes
.
body
().
asString
()));
skGoodsId
=
killGoodsList
.
getId
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
@Test
(
description
=
"获取商品详情"
,
priority
=
17
)
public
void
获取商品详情
()
{
Map
<
String
,
Object
>
skGoodsDetailPar
=
new
HashMap
<>();
skGoodsDetailPar
.
put
(
"id"
,
skGoodsId
);
Response
skGoodsDetailRes
=
network
.
getResponse
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
);
long
id
=
skGoodsDetailRes
.
jsonPath
().
getLong
(
"data.companyId"
);
String
goodsTitle
=
skGoodsDetailRes
.
jsonPath
().
getString
(
"data.goodsTitle"
);
Assert
.
assertEquals
(
goodsTitle
,
newGoodsTitle
,
network
.
message
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
,
"获取商品标题错误"
,
skGoodsDetailRes
.
body
().
asString
()));
Assert
.
assertEquals
(
id
,
companyId
,
network
.
message
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
,
"获取商品所属公司id错误"
,
skGoodsDetailRes
.
body
().
asString
()));
}
@Test
(
description
=
"编辑秒杀商品"
,
priority
=
18
)
public
void
编辑秒杀商品
()
{
List
<
String
>
killGoodsHeadImgs
=
new
ArrayList
<>();
List
<
String
>
killGoodsPictures
=
new
ArrayList
<>();
killGoodsHeadImgs
.
add
(
killGoodsHeadImg
);
killGoodsPictures
.
add
(
killGoodsPicture
);
Map
<
String
,
Object
>
killGoodsPar
=
new
HashMap
<>();
killGoodsPar
.
put
(
"id"
,
skGoodsId
);
killGoodsPar
.
put
(
"goodsImg"
,
killGoodsImg
);
killGoodsPar
.
put
(
"goodsHeadImg"
,
killGoodsHeadImgs
);
killGoodsPar
.
put
(
"goodsPictures"
,
killGoodsPictures
);
killGoodsPar
.
put
(
"companyId"
,
companyId
);
killGoodsPar
.
put
(
"goodsTitle"
,
skGoodsTitle
);
killGoodsPar
.
put
(
"goodsExplain"
,
"文字说明"
);
Response
killGoodsRes
=
network
.
postResponse
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
);
try
{
boolean
data
=
killGoodsRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"编辑秒杀商品失败"
,
killGoodsRes
.
body
().
asString
()));
Map
<
String
,
Object
>
skGoodsDetailPar
=
new
HashMap
<>();
skGoodsDetailPar
.
put
(
"id"
,
skGoodsId
);
Response
skGoodsDetailRes
=
network
.
getResponse
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
);
String
goodsTitle
=
skGoodsDetailRes
.
jsonPath
().
getString
(
"data.goodsTitle"
);
Assert
.
assertEquals
(
goodsTitle
,
skGoodsTitle
,
network
.
message
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
,
"商品名称未更新"
,
skGoodsDetailRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
}
}
@Test
(
description
=
"删除秒杀商品"
,
priority
=
19
)
public
void
删除秒杀商品
()
{
Map
<
String
,
Object
>
skGoodsDelPar
=
new
HashMap
<>();
skGoodsDelPar
.
put
(
"id"
,
skGoodsId
);
Response
skGoodsDelRes
=
network
.
postResponse
(
skGoodsDelPar
,
BasicConfig
.
MANAGER_skGoodsDelete
);
boolean
data
=
skGoodsDelRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
skGoodsDelPar
,
BasicConfig
.
MANAGER_skGoodsDelete
,
"删除商品失败"
,
skGoodsDelRes
.
body
().
asString
()));
if
(
goodsCount
==
1
){
pageNum
=
pageNum
-
1
;
}
Map
<
String
,
Object
>
skGoodsListsPar
=
new
HashMap
<>();
skGoodsListsPar
.
put
(
"companyId"
,
companyId
);
skGoodsListsPar
.
put
(
"pageSize"
,
20
);
skGoodsListsPar
.
put
(
"pageNo"
,
pageNum
);
Response
skGoodsListsRes
=
network
.
getResponse
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
);
List
<
KillGoodsList
>
killGoodsLists
=
JsonUtil
.
parseResponseToPageBean
(
skGoodsListsRes
,
KillGoodsList
.
class
);
for
(
KillGoodsList
killGoodsList
:
killGoodsLists
){
long
id
=
killGoodsList
.
getId
();
Assert
.
assertNotEquals
(
id
,
skGoodsId
,
network
.
message
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
,
"被删除商品id仍存在于列表"
,
skGoodsListsRes
.
body
().
asString
()));
}
}
}
src/test/java/com/kjj/cases/live/liveConfig/SaveLive.java
View file @
b7dfa753
...
...
@@ -28,8 +28,6 @@ public class SaveLive implements Authorization {
public
long
welfareConfId
;
private
Integer
taskId
;
public
List
<
RedList
>
redId
;
private
long
newSecKillId
;
// 新增秒杀id
private
final
long
secKillGoodsId
=
115
;
// 用来配置轮次的秒杀商品ID
@BeforeClass
public
void
setUp
()
{
BaseUtils
.
ssoLogin
();
}
...
...
@@ -2344,96 +2342,4 @@ public class SaveLive implements Authorization {
Assert
.
assertNotNull
(
data
,
network
.
message
(
Params
,
BasicConfig
.
MANAGER_otherDetail
,
"查询第6轮时长红包详情失败"
,
response
.
body
().
asString
()));
}
/**
* 配置秒杀互动
*/
@Test
(
description
=
"添加秒杀互动"
,
priority
=
125
)
public
void
添加秒杀互动
()
{
Map
<
String
,
Object
>
secKillAddPar
=
new
HashMap
<>();
secKillAddPar
.
put
(
"goodsId"
,
secKillGoodsId
);
secKillAddPar
.
put
(
"goodsAmount"
,
1
);
// 1 == 0.01
secKillAddPar
.
put
(
"interactNum"
,
3
);
secKillAddPar
.
put
(
"ableAgent"
,
0
);
// 代理人不可参与
secKillAddPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
secKillAddRes
=
network
.
postResponse
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
);
try
{
boolean
data
=
secKillAddRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
,
"添加秒杀互动失败"
,
secKillAddRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
System
.
out
.
println
(
secKillAddRes
.
body
().
asString
());
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
,
"获取数据失败"
,
secKillAddRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"获取秒杀轮次列表"
,
priority
=
126
)
public
void
获取秒杀轮次列表
()
{
Map
<
String
,
Object
>
liveSecKillPar
=
new
HashMap
<>();
liveSecKillPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
liveSecKillRes
=
network
.
getResponse
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
);
List
<
SecondKillList
>
secondKillLists
;
try
{
secondKillLists
=
JsonUtil
.
parseResponseToListBean
(
liveSecKillRes
,
SecondKillList
.
class
);
}
catch
(
Exception
e
){
System
.
out
.
println
(
liveSecKillRes
.
body
().
asString
());
e
.
printStackTrace
();
return
;
}
SecondKillList
secondKillList
=
secondKillLists
.
get
(
0
);
long
goodsId
=
secondKillList
.
getGoodsId
();
Assert
.
assertEquals
(
goodsId
,
secKillGoodsId
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品id与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
int
goodsAmount
=
secondKillList
.
getGoodsAmount
();
Assert
.
assertEquals
(
goodsAmount
,
1
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品价格与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
String
goodsTitle
=
secondKillList
.
getGoodsTitle
();
Assert
.
assertEquals
(
goodsTitle
,
"自动化专用商品"
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品名称与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
int
interactNum
=
secondKillList
.
getInteractNum
();
Assert
.
assertEquals
(
interactNum
,
3
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品数量与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
int
surplusNum
=
secondKillList
.
getSurplusNum
();
Assert
.
assertEquals
(
surplusNum
,
3
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品剩余数量与实际不符"
,
liveSecKillRes
.
body
().
asString
()));
int
ableAgent
=
secondKillList
.
getAbleAgent
();
Assert
.
assertEquals
(
ableAgent
,
0
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"代理人参与限制与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
newSecKillId
=
secondKillList
.
getId
();
}
@Test
(
description
=
"编辑秒杀轮次"
,
priority
=
127
)
public
void
编辑秒杀轮次
()
{
Map
<
String
,
Object
>
secKillUpdatePar
=
new
HashMap
<>();
secKillUpdatePar
.
put
(
"goodsId"
,
secKillGoodsId
);
secKillUpdatePar
.
put
(
"goodsAmount"
,
0.01
);
secKillUpdatePar
.
put
(
"interactNum"
,
1
);
secKillUpdatePar
.
put
(
"id"
,
newSecKillId
);
secKillUpdatePar
.
put
(
"ableAgent"
,
0
);
Response
secKillUpdateRes
=
network
.
postResponse
(
secKillUpdatePar
,
BasicConfig
.
MANAGER_secondKillUpdate
);
try
{
boolean
data
=
secKillUpdateRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
secKillUpdatePar
,
BasicConfig
.
MANAGER_secondKillUpdate
,
"编辑秒杀轮次失败"
,
secKillUpdateRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
System
.
out
.
println
(
secKillUpdateRes
.
body
().
asString
());
e
.
printStackTrace
();
}
}
@Test
(
description
=
"删除秒杀轮次"
,
priority
=
128
)
public
void
删除秒杀轮次
()
{
Map
<
String
,
Object
>
secKillDelPar
=
new
HashMap
<>();
secKillDelPar
.
put
(
"id"
,
newSecKillId
);
Response
secKillDelRes
=
network
.
postResponse
(
secKillDelPar
,
BasicConfig
.
MANAGER_secondKillDel
);
boolean
data
=
secKillDelRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
secKillDelPar
,
BasicConfig
.
MANAGER_secondKillDel
,
"删除轮次失败"
,
secKillDelRes
.
body
().
asString
()));
Map
<
String
,
Object
>
liveSecKillPar
=
new
HashMap
<>();
liveSecKillPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
liveSecKillRes
=
network
.
getResponse
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
);
List
<
SecondKillList
>
secondKillLists
=
null
;
try
{
secondKillLists
=
JsonUtil
.
parseResponseToListBean
(
liveSecKillRes
,
SecondKillList
.
class
);
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
}
for
(
SecondKillList
secondKillList
:
secondKillLists
){
Assert
.
assertNotEquals
(
newSecKillId
,
secondKillList
.
getId
(),
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"被删除的轮次id还存在"
,
liveSecKillRes
.
body
().
asString
()));
}
}
}
src/test/java/com/kjj/cases/live/secondKill/ConfSecondKill.java
0 → 100644
View file @
b7dfa753
package
com
.
kjj
.
cases
.
live
.
secondKill
;
import
com.kjj.bean.secondKill.AnchorGetSKList
;
import
com.kjj.bean.secondKill.KillGoodsList
;
import
com.kjj.bean.secondKill.SecondKillList
;
import
com.kjj.cases.admin.Authorization
;
import
com.kjj.config.BasicConfig
;
import
com.kjj.constants.LiveConstants
;
import
com.kjj.utils.BaseUtils
;
import
com.kjj.utils.IdMakeUtil
;
import
com.kjj.utils.JsonUtil
;
import
io.restassured.response.Response
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
ConfSecondKill
implements
Authorization
{
private
final
long
companyId
=
101
;
private
long
newSecKillId
;
// 会被删除的秒杀id
private
static
final
long
secKillGoodsId
=
111
;
// 用来配置轮次的秒杀商品ID
public
static
final
String
secKillGoodsIdEncode
=
IdMakeUtil
.
managerEncodingId
(
secKillGoodsId
);
private
long
skId
;
// 秒杀id
@BeforeClass
public
void
setUp
(){
BaseUtils
.
ssoLogin
();
}
/**
* 管理后台直播纬度配置秒杀轮次
*/
@Test
(
description
=
"添加秒杀互动"
,
priority
=
1
)
public
void
添加秒杀互动
()
{
Map
<
String
,
Object
>
secKillAddPar
=
new
HashMap
<>();
secKillAddPar
.
put
(
"goodsId"
,
secKillGoodsId
);
secKillAddPar
.
put
(
"goodsAmount"
,
1
);
// 1 == 0.01
secKillAddPar
.
put
(
"interactNum"
,
3
);
secKillAddPar
.
put
(
"ableAgent"
,
0
);
// 代理人不可参与
secKillAddPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
secKillAddRes
=
network
.
postResponse
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
);
try
{
boolean
data
=
secKillAddRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
,
"添加秒杀互动失败"
,
secKillAddRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
,
"获取数据失败"
,
secKillAddRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"秒杀轮次上限限制"
,
priority
=
2
)
public
void
秒杀轮次上限限制
()
{
Map
<
String
,
Object
>
secKillAddPar
=
new
HashMap
<>();
secKillAddPar
.
put
(
"goodsId"
,
115
);
secKillAddPar
.
put
(
"goodsAmount"
,
1
);
// 1 == 0.01
secKillAddPar
.
put
(
"interactNum"
,
3
);
secKillAddPar
.
put
(
"ableAgent"
,
0
);
secKillAddPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
secKillAddRes
;
boolean
data
;
for
(
int
i
=
0
;
i
<=
49
;
i
++){
secKillAddRes
=
network
.
postResponse
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
);
try
{
if
(
i
==
49
){
boolean
success
=
secKillAddRes
.
jsonPath
().
getBoolean
(
"success"
);
Assert
.
assertFalse
(
success
,
network
.
message
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
,
"秒杀轮次超出限制"
,
secKillAddRes
.
body
().
asString
()));
return
;
}
data
=
secKillAddRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
,
"添加秒杀轮次失败"
,
secKillAddRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
secKillAddPar
,
BasicConfig
.
MANAGER_secondKillSave
,
"获取数据失败"
,
secKillAddRes
.
body
().
asString
()));
}
}
}
@Test
(
description
=
"获取秒杀轮次列表"
,
priority
=
3
)
public
void
获取秒杀轮次列表
()
{
Map
<
String
,
Object
>
liveSecKillPar
=
new
HashMap
<>();
liveSecKillPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
liveSecKillRes
=
network
.
getResponse
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
);
List
<
SecondKillList
>
secondKillLists
;
SecondKillList
secondKillList
=
null
;
try
{
secondKillLists
=
JsonUtil
.
parseResponseToListBean
(
liveSecKillRes
,
SecondKillList
.
class
);
secondKillList
=
secondKillLists
.
get
(
0
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"数据获取失败"
,
liveSecKillRes
.
body
().
asString
()));
}
long
goodsId
=
secondKillList
.
getGoodsId
();
Assert
.
assertEquals
(
goodsId
,
secKillGoodsId
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品id与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
int
goodsAmount
=
secondKillList
.
getGoodsAmount
();
Assert
.
assertEquals
(
goodsAmount
,
1
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品价格与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
String
goodsTitle
=
secondKillList
.
getGoodsTitle
();
Assert
.
assertEquals
(
goodsTitle
,
"秒杀商品4"
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品名称与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
int
interactNum
=
secondKillList
.
getInteractNum
();
Assert
.
assertEquals
(
interactNum
,
3
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品数量与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
int
surplusNum
=
secondKillList
.
getSurplusNum
();
Assert
.
assertEquals
(
surplusNum
,
3
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"商品剩余数量与实际不符"
,
liveSecKillRes
.
body
().
asString
()));
int
ableAgent
=
secondKillList
.
getAbleAgent
();
Assert
.
assertEquals
(
ableAgent
,
0
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"代理人参与限制与实际添加的不符"
,
liveSecKillRes
.
body
().
asString
()));
newSecKillId
=
secondKillList
.
getId
();
}
@Test
(
description
=
"编辑秒杀轮次"
,
priority
=
4
)
public
void
编辑秒杀轮次
()
{
Map
<
String
,
Object
>
secKillUpdatePar
=
new
HashMap
<>();
secKillUpdatePar
.
put
(
"goodsId"
,
secKillGoodsId
);
secKillUpdatePar
.
put
(
"goodsAmount"
,
1
);
secKillUpdatePar
.
put
(
"interactNum"
,
1
);
secKillUpdatePar
.
put
(
"id"
,
newSecKillId
);
secKillUpdatePar
.
put
(
"ableAgent"
,
0
);
Response
secKillUpdateRes
=
network
.
postResponse
(
secKillUpdatePar
,
BasicConfig
.
MANAGER_secondKillUpdate
);
try
{
boolean
data
=
secKillUpdateRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
secKillUpdatePar
,
BasicConfig
.
MANAGER_secondKillUpdate
,
"编辑秒杀轮次失败"
,
secKillUpdateRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
secKillUpdatePar
,
BasicConfig
.
MANAGER_secondKillUpdate
,
"获取数据失败"
,
secKillUpdateRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"删除秒杀轮次"
,
priority
=
5
)
public
void
删除秒杀轮次
()
{
Map
<
String
,
Object
>
secKillDelPar
=
new
HashMap
<>();
Map
<
String
,
Object
>
liveSecKillPar
=
new
HashMap
<>();
liveSecKillPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
liveSecKillRes
=
network
.
getResponse
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
);
List
<
SecondKillList
>
secondKillLists
=
null
;
try
{
secondKillLists
=
JsonUtil
.
parseResponseToListBean
(
liveSecKillRes
,
SecondKillList
.
class
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"获取数据失败"
,
liveSecKillRes
.
body
().
asString
()));
}
Response
secKillDelRes
;
for
(
SecondKillList
secondKillList
:
secondKillLists
){
secKillDelPar
.
put
(
"id"
,
secondKillList
.
getId
());
secKillDelRes
=
network
.
postResponse
(
secKillDelPar
,
BasicConfig
.
MANAGER_secondKillDel
);
boolean
data
=
false
;
try
{
data
=
secKillDelRes
.
jsonPath
().
getBoolean
(
"data"
);
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
secKillDelPar
,
BasicConfig
.
MANAGER_secondKillDel
,
"获取数据失败"
,
secKillDelRes
.
body
().
asString
()));
}
Assert
.
assertTrue
(
data
,
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillDel
,
"删除轮次失败"
,
secKillDelRes
.
body
().
asString
()));
}
}
/**
* 助播端编辑秒杀轮次
*/
@Test
(
description
=
"助播端获取公司秒杀商品列表"
,
priority
=
6
)
public
void
助播端获取公司秒杀商品列表
()
{
Map
<
String
,
Object
>
skGoodsListPar
=
new
HashMap
<>();
skGoodsListPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
ENCODE_LIVE_ID
.
getKey
()));
Response
skGoodsListRes
=
network
.
getResponse
(
skGoodsListPar
,
BasicConfig
.
ANCHOR_skGoodsLists
);
List
<
KillGoodsList
>
killGoodsLists
;
try
{
killGoodsLists
=
JsonUtil
.
parseResponseToListBean
(
skGoodsListRes
,
KillGoodsList
.
class
);
String
goodTitle
=
killGoodsLists
.
get
(
0
).
getGoodsTitle
();
Assert
.
assertEquals
(
goodTitle
,
"自动化专用商品"
,
network
.
message
(
skGoodsListPar
,
BasicConfig
.
ANCHOR_skGoodsLists
,
"商品名称不正确"
,
skGoodsListRes
.
body
().
asString
()));
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
skGoodsListPar
,
BasicConfig
.
ANCHOR_skGoodsLists
,
"未获取到数据"
,
skGoodsListRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"助播端新增秒杀轮次"
,
priority
=
7
)
public
void
助播端新增秒杀轮次
()
{
Map
<
String
,
Object
>
secKillAddPar
=
new
HashMap
<>();
secKillAddPar
.
put
(
"goodsId"
,
secKillGoodsIdEncode
);
secKillAddPar
.
put
(
"goodsAmount"
,
5
);
// 1 == 0.01
secKillAddPar
.
put
(
"interactNum"
,
3
);
secKillAddPar
.
put
(
"ableAgent"
,
0
);
// 代理人不可参与
secKillAddPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
ENCODE_LIVE_ID
.
getKey
()));
Response
secKillAddRes
=
network
.
postResponse
(
secKillAddPar
,
BasicConfig
.
ANCHOR_secondKillSave
);
try
{
boolean
data
=
secKillAddRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
secKillAddPar
,
BasicConfig
.
ANCHOR_secondKillSave
,
"新增轮次失败"
,
secKillAddRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
secKillAddPar
,
BasicConfig
.
ANCHOR_secondKillSave
,
"未获取到数据"
,
secKillAddRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"助播端获取秒杀轮次列表"
,
priority
=
8
)
public
void
助播端获取秒杀轮次列表
()
{
Map
<
String
,
Object
>
liveSecKillPar
=
new
HashMap
<>();
liveSecKillPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
ENCODE_LIVE_ID
.
getKey
()));
Response
liveSecKillRes
=
network
.
getResponse
(
liveSecKillPar
,
BasicConfig
.
ANCHOR_secondKillLists
);
List
<
AnchorGetSKList
>
secKillLists
;
try
{
secKillLists
=
JsonUtil
.
parseResponseToListBean
(
liveSecKillRes
,
AnchorGetSKList
.
class
);
skId
=
secKillLists
.
get
(-
1
).
getId
();
System
.
out
.
println
(
secKillLists
);
System
.
out
.
println
(
skId
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
liveSecKillPar
,
BasicConfig
.
ANCHOR_secondKillLists
,
"未获取到数据"
,
liveSecKillRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"助播端编辑秒杀轮次"
,
priority
=
9
)
public
void
助播端编辑秒杀轮次
()
{
Map
<
String
,
Object
>
secKillUpdatePar
=
new
HashMap
<>();
secKillUpdatePar
.
put
(
"goodsId"
,
secKillGoodsIdEncode
);
secKillUpdatePar
.
put
(
"goodsAmount"
,
1
);
secKillUpdatePar
.
put
(
"interactNum"
,
3
);
secKillUpdatePar
.
put
(
"id"
,
IdMakeUtil
.
managerEncodingId
(
skId
));
secKillUpdatePar
.
put
(
"ableAgent"
,
0
);
Response
secKillUpdateRes
=
network
.
postResponse
(
secKillUpdatePar
,
BasicConfig
.
ANCHOR_secondKillUpdate
);
try
{
boolean
data
=
secKillUpdateRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
secKillUpdatePar
,
BasicConfig
.
ANCHOR_secondKillUpdate
,
"编辑秒杀轮次失败"
,
secKillUpdateRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
secKillUpdatePar
,
BasicConfig
.
ANCHOR_secondKillUpdate
,
"未获取到数据"
,
secKillUpdateRes
.
body
().
asString
()));
}
}
}
src/test/java/com/kjj/cases/live/secondKill/ManagerConfGoods.java
0 → 100644
View file @
b7dfa753
package
com
.
kjj
.
cases
.
live
.
secondKill
;
import
com.kjj.bean.secondKill.KillGoodsList
;
import
com.kjj.cases.admin.Authorization
;
import
com.kjj.config.BasicConfig
;
import
com.kjj.utils.BaseUtils
;
import
com.kjj.utils.JsonUtil
;
import
io.restassured.response.Response
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
ManagerConfGoods
implements
Authorization
{
private
final
long
companyId
=
101
;
private
final
String
killGoodsImg
=
"https://yun.dui88.com/kjy/image/20210818/1629269441692.jpeg"
;
private
final
String
killGoodsHeadImg
=
"https://yun.dui88.com/kjy/image/20210818/1629269453038.jpeg"
;
private
final
String
killGoodsPicture
=
"https://yun.dui88.com/kjy/image/20210818/1629269488947.jpeg"
;
private
final
String
newGoodsTitle
=
"秒杀商品1"
;
private
long
skGoodsId
;
// 秒杀商品id
public
final
static
String
skGoodsTitle
=
"编辑秒杀商品"
;
//秒杀商品名称
@BeforeClass
public
void
setUp
(){
BaseUtils
.
ssoLogin
();
}
/**
* 管理后台公司纬度配置秒杀商品
*/
@Test
(
description
=
"添加秒杀商品"
,
priority
=
2
)
public
void
添加秒杀商品
()
{
List
<
String
>
killGoodsHeadImgs
=
new
ArrayList
<>();
List
<
String
>
killGoodsPictures
=
new
ArrayList
<>();
killGoodsHeadImgs
.
add
(
killGoodsHeadImg
);
killGoodsPictures
.
add
(
killGoodsPicture
);
Map
<
String
,
Object
>
killGoodsPar
=
new
HashMap
<>();
killGoodsPar
.
put
(
"goodsImg"
,
killGoodsImg
);
killGoodsPar
.
put
(
"goodsHeadImg"
,
killGoodsHeadImgs
);
killGoodsPar
.
put
(
"goodsPictures"
,
killGoodsPictures
);
killGoodsPar
.
put
(
"companyId"
,
companyId
);
killGoodsPar
.
put
(
"goodsTitle"
,
newGoodsTitle
);
killGoodsPar
.
put
(
"goodsExplain"
,
"文字说明"
);
Response
killGoodsRes
=
network
.
postResponse
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
);
try
{
boolean
data
=
killGoodsRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"添加秒杀商品失败"
,
killGoodsRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"获取数据失败"
,
killGoodsRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"获取秒杀商品列表"
,
priority
=
3
)
public
void
获取秒杀商品列表
()
{
Map
<
String
,
Object
>
skGoodsListsPar
=
new
HashMap
<>();
skGoodsListsPar
.
put
(
"companyId"
,
companyId
);
// 默认pageSize=20,pageNo=1
Response
skGoodsListsRes
=
network
.
getResponse
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
);
try
{
List
<
KillGoodsList
>
killGoodsLists
=
JsonUtil
.
parseResponseToPageBean
(
skGoodsListsRes
,
KillGoodsList
.
class
);
KillGoodsList
killGoodsList
=
killGoodsLists
.
get
(
0
);
String
goodsTitle
=
killGoodsList
.
getGoodsTitle
();
Assert
.
assertEquals
(
goodsTitle
,
newGoodsTitle
,
network
.
message
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
,
"列表首个商品信息与实际不符"
,
skGoodsListsRes
.
body
().
asString
()));
skGoodsId
=
killGoodsList
.
getId
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"获取数据失败"
,
skGoodsListsRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"获取商品详情"
,
priority
=
4
)
public
void
获取商品详情
()
{
Map
<
String
,
Object
>
skGoodsDetailPar
=
new
HashMap
<>();
skGoodsDetailPar
.
put
(
"id"
,
skGoodsId
);
Response
skGoodsDetailRes
=
network
.
getResponse
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
);
long
id
=
skGoodsDetailRes
.
jsonPath
().
getLong
(
"data.companyId"
);
String
goodsTitle
=
skGoodsDetailRes
.
jsonPath
().
getString
(
"data.goodsTitle"
);
Assert
.
assertEquals
(
goodsTitle
,
newGoodsTitle
,
network
.
message
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
,
"获取商品标题错误"
,
skGoodsDetailRes
.
body
().
asString
()));
Assert
.
assertEquals
(
id
,
companyId
,
network
.
message
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
,
"获取商品所属公司id错误"
,
skGoodsDetailRes
.
body
().
asString
()));
}
@Test
(
description
=
"编辑秒杀商品"
,
priority
=
5
)
public
void
编辑秒杀商品
()
{
List
<
String
>
killGoodsHeadImgs
=
new
ArrayList
<>();
List
<
String
>
killGoodsPictures
=
new
ArrayList
<>();
killGoodsHeadImgs
.
add
(
killGoodsHeadImg
);
killGoodsPictures
.
add
(
killGoodsPicture
);
Map
<
String
,
Object
>
killGoodsPar
=
new
HashMap
<>();
killGoodsPar
.
put
(
"id"
,
skGoodsId
);
killGoodsPar
.
put
(
"goodsImg"
,
killGoodsImg
);
killGoodsPar
.
put
(
"goodsHeadImg"
,
killGoodsHeadImgs
);
killGoodsPar
.
put
(
"goodsPictures"
,
killGoodsPictures
);
killGoodsPar
.
put
(
"companyId"
,
companyId
);
killGoodsPar
.
put
(
"goodsTitle"
,
skGoodsTitle
);
killGoodsPar
.
put
(
"goodsExplain"
,
"文字说明"
);
Response
killGoodsRes
=
network
.
postResponse
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
);
try
{
boolean
data
=
killGoodsRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"编辑秒杀商品失败"
,
killGoodsRes
.
body
().
asString
()));
Map
<
String
,
Object
>
skGoodsDetailPar
=
new
HashMap
<>();
skGoodsDetailPar
.
put
(
"id"
,
skGoodsId
);
Response
skGoodsDetailRes
=
network
.
getResponse
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
);
String
goodsTitle
=
skGoodsDetailRes
.
jsonPath
().
getString
(
"data.goodsTitle"
);
Assert
.
assertEquals
(
goodsTitle
,
skGoodsTitle
,
network
.
message
(
skGoodsDetailPar
,
BasicConfig
.
MANAGER_skGoodsDetail
,
"商品名称未更新"
,
skGoodsDetailRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
killGoodsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"获取数据失败"
,
killGoodsRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"删除秒杀商品"
,
priority
=
6
)
public
void
删除秒杀商品
()
{
Map
<
String
,
Object
>
skGoodsDelPar
=
new
HashMap
<>();
skGoodsDelPar
.
put
(
"id"
,
skGoodsId
);
Response
skGoodsDelRes
=
network
.
postResponse
(
skGoodsDelPar
,
BasicConfig
.
MANAGER_skGoodsDelete
);
try
{
boolean
data
=
skGoodsDelRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
skGoodsDelPar
,
BasicConfig
.
MANAGER_skGoodsDelete
,
"删除商品失败"
,
skGoodsDelRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
skGoodsDelPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"获取数据失败"
,
skGoodsDelRes
.
body
().
asString
()));
}
// 检查列表中是否还存在被删除的商品
Map
<
String
,
Object
>
skGoodsListsPar
=
new
HashMap
<>();
skGoodsListsPar
.
put
(
"companyId"
,
companyId
);
Response
skGoodsListsRes
=
null
;
long
totalCount
=
0
;
try
{
skGoodsListsRes
=
network
.
getResponse
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
);
totalCount
=
skGoodsListsRes
.
jsonPath
().
getLong
(
"data.totalCount"
);
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsSaveOrUpdate
,
"获取数据失败"
,
skGoodsListsRes
.
body
().
asString
()));
}
skGoodsListsPar
.
put
(
"pageSize"
,
totalCount
);
skGoodsListsPar
.
put
(
"pageNo"
,
1
);
skGoodsListsRes
=
network
.
getResponse
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
);
List
<
KillGoodsList
>
killGoodsLists
=
JsonUtil
.
parseResponseToPageBean
(
skGoodsListsRes
,
KillGoodsList
.
class
);
for
(
KillGoodsList
killGoodsList
:
killGoodsLists
){
long
id
=
killGoodsList
.
getId
();
Assert
.
assertNotEquals
(
id
,
skGoodsId
,
network
.
message
(
skGoodsListsPar
,
BasicConfig
.
MANAGER_skGoodsLists
,
"被删除商品依然存在于列表"
,
skGoodsListsRes
.
body
().
asString
()));
}
}
}
src/test/java/com/kjj/cases/live/secondKill/SecondKill.java
0 → 100644
View file @
b7dfa753
package
com
.
kjj
.
cases
.
live
.
secondKill
;
import
com.kjj.bean.secondKill.SecondKillList
;
import
com.kjj.cases.admin.Authorization
;
import
com.kjj.config.BasicConfig
;
import
com.kjj.constants.LiveConstants
;
import
com.kjj.utils.BaseUtils
;
import
com.kjj.utils.IdMakeUtil
;
import
com.kjj.utils.JsonUtil
;
import
io.restassured.response.Response
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
SecondKill
implements
Authorization
{
private
String
secKillId
;
@BeforeClass
public
void
setUp
(){
BaseUtils
.
ssoLogin
();
}
/**
* 直播中编辑秒杀轮次
*/
@Test
(
description
=
"获取第一轮秒杀信息"
,
priority
=
1
)
public
void
获取第一轮秒杀信息
()
{
Map
<
String
,
Object
>
liveSecKillPar
=
new
HashMap
<>();
liveSecKillPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
liveSecKillRes
=
network
.
getResponse
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
);
List
<
SecondKillList
>
secondKillLists
;
SecondKillList
secondKillList
=
null
;
try
{
secondKillLists
=
JsonUtil
.
parseResponseToListBean
(
liveSecKillRes
,
SecondKillList
.
class
);
secondKillList
=
secondKillLists
.
get
(
0
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
liveSecKillPar
,
BasicConfig
.
MANAGER_secondKillLists
,
"未获取到数据"
,
liveSecKillRes
.
body
().
asString
()));
}
secKillId
=
IdMakeUtil
.
managerEncodingId
(
secondKillList
.
getId
());
}
@Test
(
description
=
"修改秒杀商品"
,
priority
=
2
)
public
void
修改秒杀商品
()
{
Map
<
String
,
Object
>
secKillUpdatePar
=
new
HashMap
<>();
secKillUpdatePar
.
put
(
"goodsId"
,
IdMakeUtil
.
managerEncodingId
(
111
));
secKillUpdatePar
.
put
(
"goodsAmount"
,
1
);
secKillUpdatePar
.
put
(
"interactNum"
,
3
);
secKillUpdatePar
.
put
(
"id"
,
secKillId
);
secKillUpdatePar
.
put
(
"ableAgent"
,
0
);
Response
secKillUpdateRes
=
network
.
postResponse
(
secKillUpdatePar
,
BasicConfig
.
ANCHOR_secondKillUpdate
);
System
.
out
.
println
(
secKillUpdateRes
.
body
().
asString
());
}
@Test
(
description
=
"修改秒杀价格"
,
priority
=
3
)
public
void
修改秒杀价格
()
{
Map
<
String
,
Object
>
secKillUpdatePar
=
new
HashMap
<>();
secKillUpdatePar
.
put
(
"goodsId"
,
ConfSecondKill
.
secKillGoodsIdEncode
);
secKillUpdatePar
.
put
(
"goodsAmount"
,
5
);
secKillUpdatePar
.
put
(
"interactNum"
,
3
);
secKillUpdatePar
.
put
(
"id"
,
secKillId
);
secKillUpdatePar
.
put
(
"ableAgent"
,
0
);
Response
secKillUpdateRes
=
network
.
postResponse
(
secKillUpdatePar
,
BasicConfig
.
ANCHOR_secondKillUpdate
);
System
.
out
.
println
(
secKillUpdateRes
.
body
().
asString
());
}
@Test
(
description
=
"减少秒杀商品数量"
,
priority
=
4
)
public
void
减少秒杀商品数量
()
{
}
}
src/test/java/com/kjj/config/BasicConfig.java
View file @
b7dfa753
...
...
@@ -136,6 +136,10 @@ public class BasicConfig {
public
static
final
String
MANAGER_secondKillLists
=
MANAGER_HOST
+
"/kjy/manager/live/second/kill/goods/list"
;
public
static
final
String
MANAGER_secondKillDel
=
MANAGER_HOST
+
"/kjy/manager/live/second/kill/goods/delete"
;
public
static
final
String
MANAGER_secondKillUpdate
=
MANAGER_HOST
+
"/kjy/manager/live/second/kill/goods/update"
;
public
static
final
String
ANCHOR_secondKillSave
=
MOBILE_HOST
+
"/conf/live/second/kill/goods/save"
;
public
static
final
String
ANCHOR_secondKillLists
=
MOBILE_HOST
+
"/conf/live/second/kill/goods/list"
;
public
static
final
String
ANCHOR_secondKillUpdate
=
MOBILE_HOST
+
"/conf/live/second/kill/goods/update"
;
public
static
final
String
ANCHOR_skGoodsLists
=
MOBILE_HOST
+
"/conf/live/second/kill/goods/goodsList"
;
// *************** 闯关答题 ***************
public
static
final
String
MANAGER_addOrUpdateQues
=
MANAGER_HOST
+
"/kjy/manager/pass/ques/addOrUpdateQues"
;
...
...
@@ -1077,4 +1081,5 @@ public class BasicConfig {
public
static
final
String
MANAGER_exclusiveItemPage
=
MANAGER_HOST
+
"/kjy/manager/exclusiveItem/page"
;
public
static
final
String
MANAGER_exclusiveItemDel
=
MANAGER_HOST
+
"/kjy/manager/exclusiveItem/del"
;
public
static
final
String
MANAGER_searchCompany
=
MANAGER_HOST
+
"/kjy/manager/live/company/search"
;
public
static
final
String
MANAGER_liveList
=
MANAGER_HOST
+
"/kjy/manager/live/list"
;
}
src/test/liveTestNG.xml
View file @
b7dfa753
...
...
@@ -2,90 +2,101 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite
name=
"直播"
verbose=
"1"
thread-count=
"3"
>
<test
preserve-order=
"true"
name=
"直播素材"
>
<!-- <test preserve-order="true" name="直播素材">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.liveConfig.LiveMaterial"/>-->
<!-- </classes>-->
<!-- </test>-->
<test
preserve-order=
"true"
name=
"配置秒杀商品"
>
<classes>
<class
name=
"com.kjj.cases.live.liveConfig.LiveMaterial"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"团队管理"
>
<classes>
<class
name=
"com.kjj.cases.live.liveConfig.Team"
/>
<class
name=
"com.kjj.cases.live.secondKill.ManagerConfGoods"
/>
</classes>
</test>
<!-- <test preserve-order="true" name="团队管理">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.liveConfig.Team"/>-->
<!-- </classes>-->
<!-- </test>-->
<test
preserve-order=
"true"
name=
"精彩视频"
>
<classes
>
<class
name=
"com.kjj.cases.live.liveConfig.Video"
/
>
</classes
>
</test
>
<!-- <test preserve-order="true" name="精彩视频">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.liveConfig.Video"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<test
preserve-order=
"true"
name=
"创建直播"
>
<classes>
<class
name=
"com.kjj.cases.live.liveConfig.SaveLive"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"
成功案例
"
>
<test
preserve-order=
"true"
name=
"
配置秒杀轮次
"
>
<classes>
<class
name=
"com.kjj.cases.live.
liveConfig.LiveCase
"
/>
<class
name=
"com.kjj.cases.live.
secondKill.ConfSecondKill
"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"资料贴片"
>
<classes
>
<class
name=
"com.kjj.cases.live.liveConfig.Paster"
/
>
</classes
>
</test
>
<!-- <test preserve-order="true" name="成功案例">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.liveConfig.LiveCase"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<!-- <test preserve-order="true" name="资料贴片">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.liveConfig.Paster"/>-->
<!-- </classes>-->
<!-- </test>-->
<test
preserve-order=
"true"
name=
"代理人首页"
>
<classes>
<class
name=
"com.kjj.cases.live.agent.Agent"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"小程序分享"
>
<classes
>
<class
name=
"com.kjj.cases.live.liveConfig.Share"
/
>
</classes
>
</test
>
<!-- <test preserve-order="true" name="代理人首页">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.agent.Agent"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<test
preserve-order=
"true"
name=
"获取抽奖码校验"
>
<classes
>
<class
name=
"com.kjj.cases.live.lotteryCode.LotteryCode"
/
>
</classes
>
</test
>
<!-- <test preserve-order="true" name="小程序分享">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.liveConfig.Share"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<test
preserve-order=
"false"
name=
"预告页"
>
<classes
>
<class
name=
"com.kjj.cases.live.preview.Preview"
/
>
</classes
>
</test
>
<!-- <test preserve-order="true" name="获取抽奖码校验">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.lotteryCode.LotteryCode"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<test
preserve-order=
"false"
name=
"翻牌集字红包"
>
<classes
>
<class
name=
"com.kjj.cases.live.flipCard.FlipCard"
/
>
</classes
>
</test
>
<!-- <test preserve-order="false" name="预告页">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.preview.Preview"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<test
preserve-order=
"true"
name=
"中奖规则配置"
>
<classes
>
<class
name=
"com.kjj.cases.live.liveConfig.WinningRules"
/
>
</classes
>
</test
>
<!-- <test preserve-order="false" name="翻牌集字红包">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.flipCard.FlipCard"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<!-- <test preserve-order="true" name="中奖规则配置">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.liveConfig.WinningRules"/>-->
<!-- </classes>-->
<!-- </test>-->
<test
preserve-order=
"true"
name=
"指定中奖"
>
<classes>
<class
name=
"com.kjj.cases.live.lottery.DesignatedWinner"
/>
</classes>
</test>
<!-- <test preserve-order="true" name="指定中奖">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.lottery.DesignatedWinner"/>-->
<!-- </classes>-->
<!-- </test>-->
<test
preserve-order=
"true"
name=
"直播前-我的客户页"
>
<classes>
<class
name=
"com.kjj.cases.live.agent.LiveBefore"
/>
</classes>
</test>
<!-- <test preserve-order="true" name="直播前-我的客户页">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.agent.LiveBefore"/>-->
<!-- </classes>-->
<!-- </test>-->
<test
preserve-order=
"true"
name=
"助播-开启直播"
>
...
...
@@ -94,94 +105,99 @@
</classes>
</test>
<test
preserve-order=
"true"
name=
"访客签到"
>
<classes>
<class
name=
"com.kjj.cases.live.lotteryCode.SignIn"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"宝箱裂变"
>
<classes>
<class
name=
"com.kjj.cases.live.treasure.Treasure"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"直播中抽奖"
>
<classes>
<class
name=
"com.kjj.cases.live.lottery.Lottery"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"猜数字红包"
>
<classes>
<class
name=
"com.kjj.cases.live.guess.LiveGuess"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"看直播攒现金"
>
<classes>
<class
name=
"com.kjj.cases.live.treasure.TimeRed"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"免费领福利"
>
<classes>
<class
name=
"com.kjj.cases.live.FreeReward.FreeReward"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"我要咨询"
>
<classes>
<class
name=
"com.kjj.cases.live.agent.Potential"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"访客领取资料"
>
<classes>
<class
name=
"com.kjj.cases.live.anchor.LiveVisitors"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"红包领取"
>
<classes>
<class
name=
"com.kjj.cases.live.red.LiveVistorRed"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"有奖答题"
>
<classes>
<class
name=
"com.kjj.cases.live.answer.Answer"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"投票"
>
<classes>
<class
name=
"com.kjj.cases.live.choice.Choice"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"问题"
>
<classes>
<class
name=
"com.kjj.cases.live.question.Question"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"直播中时长宝箱"
>
<classes>
<class
name=
"com.kjj.cases.live.treasure.TreasureTime"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"闯关答题"
>
<classes>
<class
name=
"com.kjj.cases.live.answer.passQues"
/>
</classes>
</test>
<test
preserve-order=
"true"
name=
"直播中获取线索统计"
>
<classes>
<class
name=
"com.kjj.cases.live.agent.LiveAgent"
/>
</classes>
</test>
<!-- <test preserve-order="true" name="访客签到">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.lotteryCode.SignIn"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="宝箱裂变">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.treasure.Treasure"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="直播中抽奖">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.lottery.Lottery"/>-->
<!-- </classes>-->
<!-- </test>-->
<test
preserve-order=
"true"
name=
"秒杀互动"
>
<classes>
<class
name=
"com.kjj.cases.live.secondKill.SecondKill"
/>
</classes>
</test>
<!-- <test preserve-order="true" name="猜数字红包">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.guess.LiveGuess"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="看直播攒现金">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.treasure.TimeRed"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="免费领福利">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.FreeReward.FreeReward"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="我要咨询">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.agent.Potential"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="访客领取资料">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.anchor.LiveVisitors"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="红包领取">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.red.LiveVistorRed"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="有奖答题">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.answer.Answer"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="投票">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.choice.Choice"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="问题">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.question.Question"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="直播中时长宝箱">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.treasure.TreasureTime"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="闯关答题">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.answer.passQues"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="直播中获取线索统计">-->
<!-- <classes>-->
<!-- <class name="com.kjj.cases.live.agent.LiveAgent"/>-->
<!-- </classes>-->
<!-- </test>-->
<test
preserve-order=
"true"
name=
"助播-结束直播"
>
<classes>
...
...
@@ -189,40 +205,40 @@
</classes>
</test>
<test
preserve-order=
"true"
name=
"直播结束-我的客户页"
>
<classes
>
<class
name=
"com.kjj.cases.live.agent.LiveLater"
/
>
</classes
>
</test
>
<test
preserve-order=
"true"
name=
"奖品发放配置"
>
<classes
>
<class
name=
"com.kjj.cases.live.agent.Reward"
/
>
</classes
>
</test
>
<test
preserve-order=
"true"
name=
"指定中奖付款码"
>
<classes
>
<class
name=
"com.kjj.cases.live.liveConfig.spec"
/
>
</classes
>
</test
>
<test
preserve-order=
"true"
name=
"客户管理"
>
<classes
>
<class
name=
"com.kjj.cases.live.agent.Customer"
/
>
</classes
>
</test
>
<test
preserve-order=
"true"
name=
"访客端直播结束页"
>
<classes
>
<class
name=
"com.kjj.cases.live.customer.AfterLive"
/
>
</classes
>
</test
>
<test
preserve-order=
"true"
name=
"访客端个人主页"
>
<classes
>
<class
name=
"com.kjj.cases.live.customer.PersonalPage"
/
>
</classes
>
</test
>
<!-- <test preserve-order="true" name="直播结束-我的客户页">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.agent.LiveLater"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<!-- <test preserve-order="true" name="奖品发放配置">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.agent.Reward"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<!-- <test preserve-order="true" name="指定中奖付款码">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.liveConfig.spec"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<!-- <test preserve-order="true" name="客户管理">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.agent.Customer"/>--
>
<!-- </classes>--
>
<!-- </test>--
>
<!-- <test preserve-order="true" name="访客端直播结束页">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.customer.AfterLive" />--
>
<!-- </classes>--
>
<!-- </test>--
>
<!-- <test preserve-order="true" name="访客端个人主页">--
>
<!-- <classes>--
>
<!-- <class name="com.kjj.cases.live.customer.PersonalPage" />--
>
<!-- </classes>--
>
<!-- </test>--
>
</suite>
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