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
Expand all
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;
...
@@ -17,15 +17,6 @@ import org.testng.annotations.Test;
import
java.util.*
;
import
java.util.*
;
public
class
LiveMaterial
implements
Authorization
{
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
@BeforeClass
public
void
setUp
()
{
public
void
setUp
()
{
...
@@ -363,114 +354,5 @@ public class LiveMaterial implements Authorization {
...
@@ -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 {
...
@@ -28,8 +28,6 @@ public class SaveLive implements Authorization {
public
long
welfareConfId
;
public
long
welfareConfId
;
private
Integer
taskId
;
private
Integer
taskId
;
public
List
<
RedList
>
redId
;
public
List
<
RedList
>
redId
;
private
long
newSecKillId
;
// 新增秒杀id
private
final
long
secKillGoodsId
=
115
;
// 用来配置轮次的秒杀商品ID
@BeforeClass
@BeforeClass
public
void
setUp
()
{
BaseUtils
.
ssoLogin
();
}
public
void
setUp
()
{
BaseUtils
.
ssoLogin
();
}
...
@@ -2344,96 +2342,4 @@ public class SaveLive implements Authorization {
...
@@ -2344,96 +2342,4 @@ public class SaveLive implements Authorization {
Assert
.
assertNotNull
(
data
,
network
.
message
(
Params
,
BasicConfig
.
MANAGER_otherDetail
,
"查询第6轮时长红包详情失败"
,
response
.
body
().
asString
()));
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
This diff is collapsed.
Click to expand it.
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 {
...
@@ -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_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_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
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"
;
public
static
final
String
MANAGER_addOrUpdateQues
=
MANAGER_HOST
+
"/kjy/manager/pass/ques/addOrUpdateQues"
;
...
@@ -1077,4 +1081,5 @@ public class BasicConfig {
...
@@ -1077,4 +1081,5 @@ public class BasicConfig {
public
static
final
String
MANAGER_exclusiveItemPage
=
MANAGER_HOST
+
"/kjy/manager/exclusiveItem/page"
;
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_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_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
This diff is collapsed.
Click to expand it.
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