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
956c7eb1
Commit
956c7eb1
authored
Oct 15, 2021
by
龚小红
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/20211014-xmc' into 'master'
Feat/20211014 xmc-秒杀限制需求覆盖 See merge request test-group/kejiji!136
parents
8c36baba
02d4f861
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
6 deletions
+101
-6
SecondKill.java
src/test/java/com/kjj/cases/live/secondKill/SecondKill.java
+99
-6
BasicConfig.java
src/test/java/com/kjj/config/BasicConfig.java
+2
-0
No files found.
src/test/java/com/kjj/cases/live/secondKill/SecondKill.java
View file @
956c7eb1
...
@@ -8,19 +8,18 @@ import com.kjj.constants.LiveConstants;
...
@@ -8,19 +8,18 @@ import com.kjj.constants.LiveConstants;
import
com.kjj.utils.BaseUtils
;
import
com.kjj.utils.BaseUtils
;
import
com.kjj.utils.IdMakeUtil
;
import
com.kjj.utils.IdMakeUtil
;
import
com.kjj.utils.JsonUtil
;
import
com.kjj.utils.JsonUtil
;
import
com.kjj.utils.ThreadSleepUtils
;
import
io.restassured.response.Response
;
import
io.restassured.response.Response
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
java.util.Date
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
kjj
.
utils
.
ThreadSleepUtils
.
sleep
;
import
static
com
.
kjj
.
utils
.
ThreadSleepUtils
.
sleep
;
public
class
SecondKill
implements
Authorization
{
public
class
SecondKill
implements
Authorization
{
private
List
<
Long
>
confIds
;
@BeforeClass
@BeforeClass
public
void
setUp
(){
public
void
setUp
(){
...
@@ -644,7 +643,101 @@ public class SecondKill implements Authorization {
...
@@ -644,7 +643,101 @@ public class SecondKill implements Authorization {
}
}
}
}
@Test
(
description
=
"删除已上架过的轮次"
,
priority
=
30
)
// 秒杀限制
@Test
(
description
=
"添加秒杀限制"
,
priority
=
30
)
public
void
添加秒杀限制
()
{
confIds
=
new
ArrayList
<>();
// 用户已成功下单0元秒杀商品
// 将0元秒杀商品和第二轮秒杀添加进限制组
confIds
.
add
(
IdMakeUtil
.
managerDecodeingId
(
ConfSecondKill
.
skIdThird
));
confIds
.
add
(
IdMakeUtil
.
managerDecodeingId
(
ConfSecondKill
.
skIdSecond
));
Map
<
String
,
Object
>
addLimitPar
=
new
HashMap
<>();
addLimitPar
.
put
(
"confIds"
,
confIds
);
addLimitPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
addLimitRes
=
network
.
postResponse
(
addLimitPar
,
BasicConfig
.
MANAGER_secondKillSaveLimitGroup
);
try
{
boolean
data
=
addLimitRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
addLimitPar
,
BasicConfig
.
MANAGER_secondKillSaveLimitGroup
,
"添加秒杀限制失败"
,
addLimitRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
addLimitPar
,
BasicConfig
.
MANAGER_secondKillSaveLimitGroup
,
"获取数据失败"
,
addLimitRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"查询秒杀限制组"
,
priority
=
31
)
public
void
查询秒杀限制组
()
{
Map
<
String
,
Object
>
limitGroupListPar
=
new
HashMap
<>();
limitGroupListPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
LIVE_ID
.
getKey
()));
Response
limitGroupListRes
=
network
.
getResponse
(
limitGroupListPar
,
BasicConfig
.
MANAGER_secondKillLimitGroupList
);
try
{
List
<
Object
>
data
=
limitGroupListRes
.
jsonPath
().
getList
(
"data"
);
if
(
data
.
size
()
!=
confIds
.
size
()){
Assert
.
fail
(
network
.
message
(
limitGroupListPar
,
BasicConfig
.
MANAGER_secondKillLimitGroupList
,
"秒杀限制组与预定配置不一致"
,
limitGroupListRes
.
body
().
asString
()));
}
for
(
int
i
=
0
;
i
<
data
.
size
();
i
++){
Assert
.
assertEquals
(
data
.
get
(
i
).
toString
(),
confIds
.
get
(
i
).
toString
(),
network
.
message
(
limitGroupListPar
,
BasicConfig
.
MANAGER_secondKillLimitGroupList
,
"秒杀限制组与预定配置不一致"
,
limitGroupListRes
.
body
().
asString
()));
}
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
limitGroupListPar
,
BasicConfig
.
MANAGER_secondKillLimitGroupList
,
"获取数据失败"
,
limitGroupListRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"限制组限制用户下单"
,
priority
=
32
)
public
void
限制组限制用户下单
()
{
// 等待两分钟代理人释放第二轮次库存
ThreadSleepUtils
.
sleep
(
180000
);
// 用户下单
visitorAuth1
();
Map
<
String
,
Object
>
orderPar
=
new
HashMap
<>();
orderPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
ENCODE_LIVE_ID
.
getKey
()));
orderPar
.
put
(
"confId"
,
ConfSecondKill
.
skIdSecond
);
Response
orderRes
=
network
.
postResponse
(
orderPar
,
BasicConfig
.
MOBILE_secondKill_goodsOrder
);
try
{
boolean
data
=
orderRes
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
data
,
network
.
message
(
orderPar
,
BasicConfig
.
MOBILE_secondKill_goodsOrder
,
"下单失败"
,
orderRes
.
body
().
asString
()));
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
orderPar
,
BasicConfig
.
MOBILE_secondKill_goodsOrder
,
"未获取到数据"
,
orderRes
.
body
().
asString
()));
}
Map
<
String
,
Object
>
orderResultPar
=
new
HashMap
<>();
orderResultPar
.
put
(
"liveId"
,
LiveConstants
.
getValue
(
LiveConstants
.
StringKeyEnum
.
ENCODE_LIVE_ID
.
getKey
()));
orderResultPar
.
put
(
"confId"
,
ConfSecondKill
.
skIdSecond
);
Response
orderResultRes
=
null
;
Object
data
=
null
;
int
i
=
0
;
try
{
// 轮训下单接口
while
(
data
==
null
){
sleep
(
2000
);
orderResultRes
=
network
.
getResponse
(
orderResultPar
,
BasicConfig
.
MOBILE_secondKill_goodsOrderResult
);
data
=
orderResultRes
.
jsonPath
().
getJsonObject
(
"data"
);
System
.
out
.
println
(
"data: "
+
data
);
i
++;
if
(
i
==
10
){
Assert
.
fail
(
network
.
message
(
orderResultPar
,
BasicConfig
.
MOBILE_secondKill_goodsOrderResult
,
"轮训下单结果超过10次"
,
orderResultRes
.
body
().
asString
()));
}
}
int
state
=
orderResultRes
.
jsonPath
().
getInt
(
"data.state"
);
if
(
state
==
2
){
int
code
=
orderResultRes
.
jsonPath
().
getInt
(
"data.code"
);
if
(
code
==
4
){
System
.
out
.
println
(
"失败原因code="
+
code
);
}
else
{
Assert
.
assertEquals
(
code
,
3
,
network
.
message
(
orderResultPar
,
BasicConfig
.
MOBILE_secondKill_goodsOrderResult
,
"失败原因不是被限制"
,
orderResultRes
.
body
().
asString
()));
}
}
else
{
Assert
.
fail
(
network
.
message
(
orderResultPar
,
BasicConfig
.
MOBILE_secondKill_goodsOrderResult
,
"用户下单未收到限制组限制"
,
orderResultRes
.
body
().
asString
()));
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
Assert
.
fail
(
network
.
message
(
orderResultPar
,
BasicConfig
.
MOBILE_secondKill_goodsOrderResult
,
"获取数据失败"
,
orderResultRes
.
body
().
asString
()));
}
}
@Test
(
description
=
"删除已上架过的轮次"
,
priority
=
33
)
public
void
已上架过的轮次无法删除
()
{
public
void
已上架过的轮次无法删除
()
{
long
id
=
IdMakeUtil
.
managerDecodeingId
(
ConfSecondKill
.
skIdFirst
);
long
id
=
IdMakeUtil
.
managerDecodeingId
(
ConfSecondKill
.
skIdFirst
);
Map
<
String
,
Object
>
delSkPar
=
new
HashMap
<>();
Map
<
String
,
Object
>
delSkPar
=
new
HashMap
<>();
...
@@ -663,7 +756,7 @@ public class SecondKill implements Authorization {
...
@@ -663,7 +756,7 @@ public class SecondKill implements Authorization {
}
}
}
}
@Test
(
description
=
"用户成功支付"
,
priority
=
3
1
)
@Test
(
description
=
"用户成功支付"
,
priority
=
3
4
)
public
void
用户成功支付
()
{
public
void
用户成功支付
()
{
visitorAuth1
();
visitorAuth1
();
// 新建订单
// 新建订单
...
...
src/test/java/com/kjj/config/BasicConfig.java
View file @
956c7eb1
...
@@ -138,6 +138,8 @@ public class BasicConfig {
...
@@ -138,6 +138,8 @@ 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
MANAGER_secondKillSaveLimitGroup
=
MANAGER_HOST
+
"/kjy/manager/live/second/kill/goods/saveLimitGroup"
;
public
static
final
String
MANAGER_secondKillLimitGroupList
=
MANAGER_HOST
+
"/kjy/manager/live/second/kill/goods/limitGroupList"
;
public
static
final
String
ANCHOR_secondKillSave
=
MOBILE_HOST
+
"/conf/live/second/kill/goods/save"
;
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_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_secondKillUpdate
=
MOBILE_HOST
+
"/conf/live/second/kill/goods/update"
;
...
...
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