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
da46efca
Commit
da46efca
authored
Dec 12, 2019
by
赵然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zr
parent
b84171cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
0 deletions
+148
-0
RconGame.java
src/test/java/http/cases/GameTest/RconGame.java
+93
-0
NgapiService.java
src/test/java/http/service/Activity/NgapiService.java
+55
-0
No files found.
src/test/java/http/cases/GameTest/RconGame.java
0 → 100644
View file @
da46efca
package
http
.
cases
.
GameTest
;
import
base.Config
;
import
base.DuibaLog
;
import
http.service.Activity.ManagerService
;
import
http.service.Activity.NgapiService
;
import
http.service.Authorization
;
import
http.service.hd.ActivityService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
;
import
org.testng.Assert
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
utils.ExcelDataProvider
;
import
utils.MatcherString
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
/**
* Created by zhaoran on 2019/12/09.
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
RconGame
extends
AbstractTestNGSpringContextTests
{
@Autowired
NgapiService
ngapiService
;
@Autowired
ManagerService
managerService
;
@Autowired
ActivityService
activityService
;
@Autowired
Authorization
authorization
;
@Value
(
"${activity.host}"
)
String
activityHost
;
private
static
DuibaLog
logger
=
DuibaLog
.
getLogger
();
private
static
final
Integer
uid
=
7417
;
private
static
final
String
consumerId
=
"100168013"
;
@Test
public
void
参与游戏测试
()
throws
Exception
{
Response
response
=
ngapiService
.
reconajaxElement
(
uid
,
"12399"
,
"45532"
);
String
freeLimit
=
response
.
jsonPath
().
getString
(
"data.element.freeLimit"
);
//扣去1次免费次数
String
ExpfreeLimit
=
String
.
valueOf
(
Integer
.
valueOf
(
freeLimit
)-
1
);
//进行接口测试传参
this
.
游戏接口传参
(
"45532"
);
Response
response2
=
ngapiService
.
reconajaxElement
(
uid
,
"12399"
,
"45532"
);
freeLimit
=
response2
.
jsonPath
().
getString
(
"data.element.freeLimit"
);
Assert
.
assertEquals
(
freeLimit
,
ExpfreeLimit
,
"免费次数扣除不正确"
);
}
public
Response
游戏接口传参
(
String
activityId
)
throws
Exception
{
Response
response
=
ngapiService
.
recondoJoin
(
uid
,
activityId
,
consumerId
);
response
.
prettyPrint
();
response
.
then
().
body
(
"success"
,
equalTo
(
true
));
String
orderId
=
response
.
jsonPath
().
getString
(
"data"
);
response
=
ngapiService
.
recongetStartStatus
(
uid
,
orderId
);
response
.
prettyPrint
();
// String message = String.valueOf(response.jsonPath().getString("message"));
// int i= 5;
// while(i>0&&(message.equals("处理中"))){
// Thread.sleep(1000);
// response = ngapiService.getStartStatus(uid,ticketId);
// message = String.valueOf(response.jsonPath().getString("message"));
// i--;
// response.prettyPrint();
// }
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"校验message失败"
);
// response = ngapiService.submit(uid,ticketId,device);
// response.prettyPrint();
return
response
;
}
}
\ No newline at end of file
src/test/java/http/service/Activity/NgapiService.java
View file @
da46efca
...
...
@@ -90,4 +90,59 @@ public class NgapiService {
return
response
;
}
public
Response
reconajaxElement
(
int
uid
,
String
duibaId
,
String
activityId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"duibaId"
,
duibaId
);
map
.
put
(
"activityId"
,
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
get
(
activityHost
+
"/hdtool/recon/ajaxElement"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/hdtool/recon/ajaxElement接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/hdtool/recon/ajaxElement接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/hdtool/recon/ajaxElement接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
recondoJoin
(
int
uid
,
String
activityId
,
String
consumerId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"activityId"
,
activityId
);
map
.
put
(
"activityType"
,
"hdtool"
);
map
.
put
(
"consumerId"
,
consumerId
);
map
.
put
(
"token"
,
"rl8v7"
);
logger
.
info
(
"请求doJoin接口,activityId="
+
activityId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/hdtool/recon/doJoin"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/hdtool/recon/doJoin接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/hdtool/recon/doJoin接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/hdtool/recon/doJoin接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
public
Response
recongetStartStatus
(
int
uid
,
String
orderId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"orderId"
,
orderId
);
logger
.
info
(
"请求getOrderStatus接口,orderId="
+
orderId
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/hdtool/recon/ngame/getNgameStartStatus"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/hdtool/recon/ngame/getNgameStartStatus接口失败"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"/hdtool/recon/ngame/getNgameStartStatus接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
){
throw
new
Exception
(
"/hdtool/recon/ngame/getNgameStartStatus接口失败,返回信息:"
+
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