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
c8eddab0
Commit
c8eddab0
authored
Nov 28, 2019
by
吕雯燕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv
parent
ab3eba78
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
157 additions
and
5 deletions
+157
-5
集卡活动领奖_AccessTest.java
src/test/java/http/cases/ClcardTest/集卡活动领奖_AccessTest.java
+75
-0
ClcardService.java
src/test/java/http/service/Activity/ClcardService.java
+82
-0
HappyCodeNewService.java
src/test/java/http/service/Activity/HappyCodeNewService.java
+0
-5
No files found.
src/test/java/http/cases/ClcardTest/集卡活动领奖_AccessTest.java
0 → 100644
View file @
c8eddab0
package
http
.
cases
.
ClcardTest
;
import
base.DuibaTestBase
;
import
http.service.Activity.ClcardService
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterMethod
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
java.sql.SQLException
;
import
java.util.Map
;
public
class
集卡活动领奖
_AccessTest
extends
DuibaTestBase
{
@Autowired
ClcardService
clcardService
;
@BeforeMethod
public
void
before
(){
try
{
//修改表,增加用户卡片
jdbc
.
update
(
"update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100164132 AND item_id = 12"
);
jdbc
.
update
(
"update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +2 , item_total_count = item_total_count +2 WHERE consumer_id = 100164132 AND item_id = 13"
);
jdbc
.
update
(
"update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +3 , item_total_count = item_total_count +3 WHERE consumer_id = 100164132 AND item_id = 14"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
(
description
=
"集卡活动领奖支付宝测试"
)
public
void
集卡领奖成功
()
throws
Exception
{
int
uid
=
7402
;
String
activityId
=
"45501"
;
//集卡领奖
Response
openPrizeResponse
=
clcardService
.
openPrize
(
uid
,
activityId
);
openPrizeResponse
.
prettyPrint
();
String
desc
=
openPrizeResponse
.
jsonPath
().
getString
(
"desc"
);
//活动首页信息
Response
response
=
clcardService
.
activity
(
uid
,
activityId
);
response
.
prettyPrint
();
String
cards0
=
response
.
jsonPath
().
getString
(
"data.cards[0].count"
);
String
cards1
=
response
.
jsonPath
().
getString
(
"data.cards[1].count"
);
String
cards2
=
response
.
jsonPath
().
getString
(
"data.cards[2].count"
);
String
rules0
=
response
.
jsonPath
().
getString
(
"data.prizes[0].rules[0].cardCount"
);
String
rules1
=
response
.
jsonPath
().
getString
(
"data.prizes[0].rules[1].cardCount"
);
String
rules2
=
response
.
jsonPath
().
getString
(
"data.prizes[0].rules[2].cardCount"
);
Assert
.
assertEquals
(
desc
,
"OK"
,
"校验desc失败"
);
Assert
.
assertEquals
(
cards0
,
"0"
,
"校验card0失败"
);
Assert
.
assertEquals
(
cards1
,
"0"
,
"校验card1失败"
);
Assert
.
assertEquals
(
cards2
,
"1"
,
"校验card2失败"
);
Assert
.
assertEquals
(
rules0
,
"1"
,
"校验rules0失败"
);
Assert
.
assertEquals
(
rules1
,
"2"
,
"校验rules1失败"
);
Assert
.
assertEquals
(
rules2
,
"3"
,
"校验rules2失败"
);
logger
.
info
(
"集卡活动领奖成功"
);
}
}
src/test/java/http/service/Activity/ClcardService.java
0 → 100644
View file @
c8eddab0
package
http
.
service
.
Activity
;
import
base.DuibaLog
;
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.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by lvwenyan on 2019/11/27
*/
@Service
public
class
ClcardService
{
@Value
(
"${activity.host}"
)
String
activityHost
;
@Autowired
Authorization
authorization
;
private
DuibaLog
logger
=
DuibaLog
.
getLogger
();
/**
* @param activityId 活动id
* @param uid 用户id
* @return
* @throws Exception
*/
public
Response
openPrize
(
int
uid
,
String
activityId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
activityId
);
map
.
put
(
"grade"
,
"1"
);
map
.
put
(
"preview"
,
"false"
);
logger
.
info
(
"请求/hdtool/clcard/openPrize接口"
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
post
(
activityHost
+
"/hdtool/clcard/openPrize"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/hdtool/clcard/openPrize接口失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/hdtool/clcard/openPrize接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/hdtool/clcard/openPrize接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
/**
* @param activityId 活动id
* @param uid 用户id
* @return
* @throws Exception
*/
public
Response
activity
(
int
uid
,
String
activityId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
activityId
);
logger
.
info
(
"请求/hdtool/clcard/activity接口"
);
Response
response
=
given
().
cookies
(
authorization
.
dafuwengLogin
(
uid
)).
params
(
map
).
get
(
activityHost
+
"/hdtool/clcard/activity"
);
try
{
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"success"
),
"true"
,
"/hdtool/clcard/activity接口失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/hdtool/clcard/activity接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/hdtool/clcard/activity接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
}
src/test/java/http/service/Activity/HappyCodeNewService.java
View file @
c8eddab0
package
http
.
service
.
Activity
;
import
base.DuibaLog
;
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
;
...
...
@@ -10,13 +8,10 @@ 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
;
import
static
io
.
restassured
.
RestAssured
.
trustStore
;
/**
* Created by lvwenyan on 2019/11/23
...
...
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