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
29127928
Commit
29127928
authored
Apr 04, 2019
by
吕雯燕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv
parent
b565ebab
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
273 additions
and
13 deletions
+273
-13
SingleLottery_AccessTest.java
...ttp/cases/SingleLotteryTest/SingleLottery_AccessTest.java
+2
-0
兑吧单品抽奖_新商品_AccessTest.java
...a/http/cases/SingleLotteryTest/兑吧单品抽奖_新商品_AccessTest.java
+82
-0
自有单品抽奖_新商品_AccessTest.java
...a/http/cases/SingleLotteryTest/自有单品抽奖_新商品_AccessTest.java
+80
-0
SingleLotteryService.java
...test/java/http/service/Activity/SingleLotteryService.java
+13
-13
AdminDuibaSingleLotteryService.java
.../http/service/Manager/AdminDuibaSingleLotteryService.java
+51
-0
AppSingleLotteryService.java
src/test/java/http/service/hd/AppSingleLotteryService.java
+45
-0
No files found.
src/test/java/http/cases/SingleLotteryTest/SingleLottery_AccessTest.java
View file @
29127928
...
...
@@ -258,4 +258,6 @@ public class SingleLottery_AccessTest extends DuibaTestBase {
}
}
\ No newline at end of file
src/test/java/http/cases/SingleLotteryTest/兑吧单品抽奖_新商品_AccessTest.java
0 → 100644
View file @
29127928
package
http
.
cases
.
SingleLotteryTest
;
import
base.DuibaTestBase
;
import
http.service.Activity.SingleLotteryService
;
import
http.service.Manager.AdminDuibaSingleLotteryService
;
import
utils.MatcherString
;
import
base.DuibaLog
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
/**
* Created by lvwenyan on 2019/4/4.
*/
public
class
兑吧单品抽奖
_
新商品
_AccessTest
extends
DuibaTestBase
{
@Autowired
SingleLotteryService
singleLotteryService
;
@Autowired
AdminDuibaSingleLotteryService
adminDuibaSingleLotteryService
;
int
uid
=
7126
;
@Test
(
description
=
"添加新商品作为奖品"
)
public
void
选择主奖品为新实物
()
throws
Exception
{
String
itemId
=
"32604"
;
Response
response
=
adminDuibaSingleLotteryService
.
ajaxFindItemById
(
itemId
);
response
.
prettyPrint
();
String
id
=
response
.
jsonPath
().
getString
(
"item.id"
);
String
name
=
response
.
jsonPath
().
getString
(
"item.name"
);
Assert
.
assertEquals
(
id
,
"32604"
,
"校验商品id失败"
);
Assert
.
assertEquals
(
name
,
"【自动化勿动】兑吧新实物活动专用"
,
"校验商品名称失败"
);
logger
.
info
(
"校验单品抽奖添加新实物成功"
);
}
@Test
(
description
=
"单品抽奖中奖新实物"
)
public
void
中奖新实物
()
throws
Exception
{
String
activityId
=
"43725"
;
String
token
=
"ix18rh"
;
Response
response
=
singleLotteryService
.
doJoin
(
uid
,
activityId
,
activityId
,
token
);
response
.
prettyPrint
();
String
id
=
MatcherString
.
getString
(
response
.
asString
(),
"singleLotteryOrderId\":(.*?),"
,
1
);
response
=
singleLotteryService
.
getOrderStatus
(
uid
,
id
,
""
);
int
i
=
10
;
while
(
"处理中"
.
equals
(
response
.
jsonPath
().
getString
(
"message"
))
&&
i
>
0
)
{
Thread
.
sleep
(
500
);
response
=
singleLotteryService
.
getOrderStatus
(
uid
,
id
,
""
);
i
--;
}
String
descrption
=
response
.
jsonPath
().
getString
(
"descrption"
);
String
itemId
=
response
.
jsonPath
().
getString
(
"itemId"
);
String
lotteryType
=
response
.
jsonPath
().
getString
(
"lotteryType"
);
Assert
.
assertEquals
(
descrption
,
"【自动化勿动】兑吧新实物活动专用"
,
"校验descrption失败"
);
Assert
.
assertEquals
(
itemId
,
"32604"
,
"校验itemid失败"
);
Assert
.
assertEquals
(
lotteryType
,
"object"
,
"校验lotteryType失败"
);
logger
.
info
(
"校验单品抽奖中奖新实物成功"
);
}
}
src/test/java/http/cases/SingleLotteryTest/自有单品抽奖_新商品_AccessTest.java
0 → 100644
View file @
29127928
package
http
.
cases
.
SingleLotteryTest
;
import
base.DuibaTestBase
;
import
http.service.Activity.SingleLotteryService
;
import
http.service.Authorization
;
import
http.service.hd.AppSingleLotteryService
;
import
utils.MatcherString
;
import
base.DuibaLog
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Created by lvwenyan on 2019/4/4.
*/
public
class
自有单品抽奖
_
新商品
_AccessTest
extends
DuibaTestBase
{
@Autowired
SingleLotteryService
singleLotteryService
;
@Autowired
AppSingleLotteryService
appSingleLotteryService
;
@Autowired
Authorization
authorization
;
int
uid
=
7126
;
@Test
(
description
=
"自有单品抽奖添加新实物商品"
)
public
void
添加新实物奖品
()
throws
Exception
{
String
appId
=
"22561"
;
String
appItemId
=
"195020"
;
Map
cookies
=
authorization
.
hdLoginCommonNew
(
"15855555555"
);
Response
response
=
appSingleLotteryService
.
ajaxFindAppItemById
(
cookies
,
appId
,
appItemId
);
response
.
prettyPrint
();
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"data.appItemId"
),
appItemId
,
"校验appItemId失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"desc"
),
"成功"
,
"校验desc失败"
);
logger
.
info
(
"校验自有单品抽奖添加新实物成功"
);
}
@Test
(
description
=
"自有单品抽奖中奖新实物"
)
public
void
中奖新实物
()
throws
Exception
{
String
activityId
=
"43751"
;
String
token
=
"6xgees"
;
Response
response
=
singleLotteryService
.
doJoin
(
uid
,
activityId
,
activityId
,
token
);
response
.
prettyPrint
();
String
id
=
MatcherString
.
getString
(
response
.
asString
(),
"singleLotteryOrderId\":(.*?),"
,
1
);
response
=
singleLotteryService
.
getOrderStatus
(
uid
,
id
,
""
);
int
i
=
10
;
while
(
"处理中"
.
equals
(
response
.
jsonPath
().
getString
(
"message"
))
&&
i
>
0
)
{
Thread
.
sleep
(
500
);
response
=
singleLotteryService
.
getOrderStatus
(
uid
,
id
,
""
);
i
--;
}
String
descrption
=
response
.
jsonPath
().
getString
(
"descrption"
);
String
appItemId
=
response
.
jsonPath
().
getString
(
"appItemId"
);
String
lotteryType
=
response
.
jsonPath
().
getString
(
"lotteryType"
);
Assert
.
assertEquals
(
descrption
,
"【自动化勿动】自有实物活动专用"
,
"校验descrption失败"
);
Assert
.
assertEquals
(
appItemId
,
"195020"
,
"校验itemid失败"
);
Assert
.
assertEquals
(
lotteryType
,
"object"
,
"校验lotteryType失败"
);
logger
.
info
(
"校验自有单品抽奖中奖新实物成功"
);
}
}
src/test/java/http/service/Activity/SingleLotteryService.java
View file @
29127928
...
...
@@ -144,7 +144,7 @@ public class SingleLotteryService {
//获取单品抽奖信息
public
Response
AdminDuibaSingleLottery
(
String
actId
)
throws
Exception
{
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery/edit/"
+
actId
;
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery
Service
/edit/"
+
actId
;
logger
.
info
(
"请求兑吧管理后台余额url:"
+
url
);
Response
response
=
given
().
cookies
(
authorization
.
ssoLogin
()).
get
(
"http://"
+
url
);
...
...
@@ -152,16 +152,16 @@ public class SingleLotteryService {
try
{
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"管理后台兑换项请求异常"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/AdminDuibaSingleLottery/edit/接口失败,返回信息:"
+
response
.
asString
());
throw
new
Exception
(
"/AdminDuibaSingleLottery
Service
/edit/接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/AdminDuibaSingleLottery/edit/接口失败,返回信息:"
+
response
.
asString
());
throw
new
Exception
(
"/AdminDuibaSingleLottery
Service
/edit/接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
//兑吧管理后台创建单品抽奖活动
public
void
SingleLottery_create
(
String
title
,
Map
<
String
,
String
>
incite
)
throws
Exception
{
String
saveUrl
=
ManagerHost
+
"/AdminDuibaSingleLottery/create"
;
String
saveUrl
=
ManagerHost
+
"/AdminDuibaSingleLottery
Service
/create"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"title"
,
title
);
...
...
@@ -202,7 +202,7 @@ public class SingleLotteryService {
//兑吧管理后台单品抽奖列表页
public
Response
manager_index
()
throws
Exception
{
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery/index"
;
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery
Service
/index"
;
Response
response
=
given
().
cookies
(
authorization
.
ssoLogin
()).
get
(
"http://"
+
url
);
//Response.prettyPrint();
...
...
@@ -218,7 +218,7 @@ public class SingleLotteryService {
//兑吧管理后台开启单品抽奖活动 1-开启且可见
public
void
changeStatus
(
String
atcId
,
String
val
)
throws
Exception
{
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery/changeStatus"
;
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery
Service
/changeStatus"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
atcId
);
...
...
@@ -228,26 +228,26 @@ public class SingleLotteryService {
Response
response
=
given
().
cookies
(
authorization
.
ssoLogin
()).
params
(
map
).
post
(
"http://"
+
url
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/AdminDuibaSingleLottery/changeStatus接口失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/AdminDuibaSingleLottery
Service
/changeStatus接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/AdminDuibaSingleLottery/changeStatus接口失败,返回信息:"
+
response
.
asString
());
throw
new
Exception
(
"/AdminDuibaSingleLottery
Service
/changeStatus接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/AdminDuibaSingleLottery/changeStatus接口失败,返回信息:"
+
response
.
asString
());
throw
new
Exception
(
"/AdminDuibaSingleLottery
Service
/changeStatus接口失败,返回信息:"
+
response
.
asString
());
}
}
//兑吧管理后台删除活动
public
void
delete
(
String
atcId
)
throws
Exception
{
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery/delete/"
+
atcId
;
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery
Service
/delete/"
+
atcId
;
Response
response
=
given
().
cookies
(
authorization
.
ssoLogin
()).
post
(
"http://"
+
url
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/AdminDuibaSingleLottery/delete/接口失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/AdminDuibaSingleLottery
Service
/delete/接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/AdminDuibaSingleLottery/delete/接口失败,返回信息:"
+
response
.
asString
());
throw
new
Exception
(
"/AdminDuibaSingleLottery
Service
/delete/接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/AdminDuibaSingleLottery/delete/接口失败,返回信息:"
+
response
.
asString
());
throw
new
Exception
(
"/AdminDuibaSingleLottery
Service
/delete/接口失败,返回信息:"
+
response
.
asString
());
}
}
}
\ No newline at end of file
src/test/java/http/service/Manager/AdminDuibaSingleLotteryService.java
0 → 100644
View file @
29127928
package
http
.
service
.
Manager
;
import
base.DuibaLog
;
import
cn.com.duiba.activity.center.api.dto.activity.CLRewardDto
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
http.service.Authorization
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.testng.Assert
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by lvwenyan on 2019/4/4.
*/
@Service
public
class
AdminDuibaSingleLotteryService
{
@Value
(
"${manager.host}"
)
String
ManagerHost
;
//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization
authorization
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
//单品抽奖添加奖品
public
Response
ajaxFindItemById
(
String
itemId
)
throws
Exception
{
String
url
=
ManagerHost
+
"/AdminDuibaSingleLottery/ajaxFindItemById"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"itemId"
,
itemId
);
Response
response
=
given
().
contentType
(
"text/html;charset=UTF-8"
).
cookies
(
authorization
.
ssoLogin
()).
params
(
map
).
get
(
"http://"
+
url
);
// response.prettyPrint();
return
response
;
}
}
src/test/java/http/service/hd/AppSingleLotteryService.java
0 → 100644
View file @
29127928
package
http
.
service
.
hd
;
import
base.DuibaLog
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.testng.Assert
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by lvwenyan on 2019/4/4
*/
@Service
public
class
AppSingleLotteryService
{
@Value
(
"${hdserver.host}"
)
String
hdserverHost
;
public
Response
ajaxFindAppItemById
(
Map
cookies
,
String
appId
,
String
appItemId
)
throws
Exception
{
String
url
=
hdserverHost
+
"/appSingleLottery/ajaxFindAppItemById"
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"appId"
,
appId
);
map
.
put
(
"appItemId"
,
appItemId
);
Response
response
=
given
().
contentType
(
"application/json;charset=UTF-8"
).
cookies
(
cookies
).
params
(
map
).
get
(
"http://"
+
url
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/appSingleLottery/ajaxFindAppItemById接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/appSingleLottery/ajaxFindAppItemById接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
}
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