Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xm-sportstest
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiamai-test
xm-sportstest
Commits
df7f1527
Commit
df7f1527
authored
Aug 14, 2024
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
搜索优惠券+失效后搜索查看优惠券详情
parent
885f36bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
src/main/java/com/xiaomai/cases/polar/coupon/TestGetStudioCouponList.java
+63
-0
No files found.
src/main/java/com/xiaomai/cases/polar/coupon/TestGetStudioCouponList.java
0 → 100644
View file @
df7f1527
package
com
.
xiaomai
.
cases
.
polar
.
coupon
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.RandomStringUtil
;
import
com.xiaomai.utils.XMJSONPath
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TestGetStudioCouponList
extends
BaseTestImpl
{
@Resource
(
name
=
"couponTools"
)
CouponTools
couponTools
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Coupon
,
"API_getStudioCouponList"
,
LoginAccount
.
ADU_PROD
,
Terminal
.
B
,
"yj"
);
super
.
beforeTest
();
}
@Test
(
description
=
"搜索对应的优惠券"
)
public
void
testgetStudioCouponList
()
{
List
<
String
>
memberStatusLimitsB
=
new
ArrayList
<>();
memberStatusLimitsB
.
add
(
"POTENTIAL"
);
String
couponName
=
"用于搜索的优惠券"
+
RandomStringUtil
.
randomString
(
3
);
couponTools
.
createCoupon
(
"WITHOUT"
,
"WITHOUT"
,
memberStatusLimitsB
,
couponName
,
false
,
"DISCOUNT"
,
2
,
"ABSOLUTE"
,
"搜索的优惠券备注"
);
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"current"
,
0
);
body
.
put
(
"size"
,
20
);
body
.
put
(
"nameLike"
,
couponName
);
body
.
put
(
"brandId"
,
dataApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"operatorId"
,
dataApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
JSONObject
response
=
xmAppApi
.
getBodyInJSON
();
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
response
,
"$.message"
),
"操作成功!"
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
response
,
"$.result.records[0].name"
),
couponName
);
couponTools
.
getStudioCouponList
(
couponName
,
"CLAIMABLE"
);
//搜索正常的优惠券
String
couponId
=
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.records[0].id"
);
//拿搜索的第一条唯一优惠券
couponTools
.
InvalidCoupon
(
couponId
);
//失效优惠券
couponTools
.
getStudioCouponList
(
couponName
,
"VOIDED"
);
//搜索失效的优惠券
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
response
,
"$.result.records[0].name"
),
couponName
);
//失效的优惠券
couponTools
.
getCouponDetail
(
couponId
);
//优惠券详情
Assert
.
assertTrue
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.status"
).
equals
(
"VOIDED"
),
"操作失效优惠券后,查看优惠券详情,后端返回的状态值不是VOIDED"
);
}
}
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