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
757f26e9
Commit
757f26e9
authored
Jul 08, 2024
by
DuJunLi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加训练营活动相关case
parent
d36541a4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
491 additions
and
5 deletions
+491
-5
src/main/java/com/xiaomai/cases/polar/memberCard/TestDiscardManualDeduct.java
+0
-4
src/main/java/com/xiaomai/cases/polar/training/BaseCreateTrainingData.java
+80
-0
src/main/java/com/xiaomai/cases/polar/training/TestCheckTrainingTitleDuplicate.java
+51
-0
src/main/java/com/xiaomai/cases/polar/training/TestDoForceOpenTraining.java
+89
-0
src/main/java/com/xiaomai/cases/polar/training/TestEditTraining.java
+149
-0
src/main/java/com/xiaomai/cases/polar/training/TestSearchTrainingList.java
+99
-0
src/main/java/com/xiaomai/cases/polar/training/TrainingTools.java
+0
-0
src/main/java/com/xiaomai/enums/ApiModule.java
+1
-0
src/main/java/com/xiaomai/enums/LoginAccount.java
+2
-0
src/main/java/com/xiaomai/utils/CommUtil.java
+20
-1
No files found.
src/main/java/com/xiaomai/cases/polar/memberCard/TestDiscardManualDeduct.java
View file @
757f26e9
...
...
@@ -33,7 +33,6 @@ public class TestDiscardManualDeduct extends XMBaseTest {
Cardtools
.
manualDeduct
(
benefitId
,
memberCardId
);
//手动扣次
Cardtools
.
fetchPageOfConsumeRecord
(
benefitId
,
memberCardId
);
String
consumeRecordId
=
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.records[0].id"
);
//
...
...
@@ -43,9 +42,6 @@ public class TestDiscardManualDeduct extends XMBaseTest {
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
jsonObject
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
}
...
...
src/main/java/com/xiaomai/cases/polar/training/BaseCreateTrainingData.java
0 → 100644
View file @
757f26e9
package
com
.
xiaomai
.
cases
.
polar
.
training
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.course.CourseTools
;
import
com.xiaomai.cases.polar.schedule.group.GroupScheduleTools
;
import
com.xiaomai.cases.polar.setting.courseCategory.CourseCategoryTools
;
import
com.xiaomai.utils.CommUtil
;
import
com.xiaomai.utils.XMJSONPath
;
import
org.testng.annotations.BeforeClass
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author adu
* data 2024/7/3 19:44
*/
public
class
BaseCreateTrainingData
extends
BaseTestImpl
{
@Resource
(
name
=
"trainingTools"
)
TrainingTools
trainingTools
;
@Resource
(
name
=
"courseCategoryTools"
)
CourseCategoryTools
courseCategoryTools
;
@Resource
(
name
=
"courseTools"
)
CourseTools
courseTools
;
@Resource
(
name
=
"groupScheduleTools"
)
GroupScheduleTools
groupScheduleTools
;
String
applyStartTime
=
""
;
String
applyEndTime
=
""
;
String
openStartDate
=
""
;
String
openEndDate
=
""
;
String
openStartDate1
=
""
;
String
openEndDate1
=
""
;
String
courseName
=
""
;
String
trainingTitle
=
""
;
List
<
String
>
trainerListIdS
;
List
<
String
>
editTrainerListId
;
String
courseId
=
""
;
long
currentTimestamp
=
System
.
currentTimeMillis
();
// 在当前时间的基础上,加上2秒(2000毫秒)
long
futureTimestamp
=
currentTimestamp
+
5000
;
//晚于当前时间8秒
String
futureTimestampS
=
String
.
valueOf
(
futureTimestamp
);
@BeforeClass
public
void
beforeTest
()
{
super
.
beforeTest
();
applyStartTime
=
String
.
valueOf
(
CommUtil
.
getWholeHourTimestamp
());
//当前时间的整点+1小时,比如现在是13:00,然后获取的是14:00的时间戳
applyEndTime
=
CommUtil
.
oneKeyGetAddDay
(
1
);
//明天0点
openStartDate
=
applyEndTime
;
openEndDate
=
CommUtil
.
getNDayEndTimeTamp
(
2
);
//后天23:59:59
openStartDate1
=
CommUtil
.
oneKeyGetAddDay
(
2
);
//后天0点
openEndDate1
=
CommUtil
.
getNDayEndTimeTamp
(
5
);
// 23:59:59
courseName
=
"训练营课程-感统课"
;
trainingTitle
=
"三期36天训练营感统课"
;
courseTools
.
getTrainingCampCourseList
(
new
ArrayList
<>(),
"ON"
,
courseName
);
int
n
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result.records"
).
size
();
if
(
n
>
0
)
{
courseId
=
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.records[0].brandCourseId"
);
}
if
(
courseId
==
""
)
{
//获取存量课程分类ID
String
categoryId
=
courseCategoryTools
.
getCourseCategoryPage
(
"训练营"
);
courseId
=
courseTools
.
createTrainingCampCourse
(
courseName
,
categoryId
,
"50"
,
"#AACF53"
);
}
List
<
String
>
trainerList
=
new
ArrayList
<>();
trainerList
.
add
(
"木头"
);
trainerList
.
add
(
"吴彦祖"
);
trainerList
.
add
(
"杜君丽"
);
trainerListIdS
=
groupScheduleTools
.
getStudioAdminId
(
trainerList
);
List
<
String
>
trainerListEdit
=
new
ArrayList
<>();
trainerListEdit
.
add
(
"杜君丽"
);
editTrainerListId
=
groupScheduleTools
.
getStudioAdminId
(
trainerListEdit
);
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/training/TestCheckTrainingTitleDuplicate.java
0 → 100644
View file @
757f26e9
package
com
.
xiaomai
.
cases
.
polar
.
training
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.RandomStringUtil
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
/**
* 创建训练营活动名称验重
*
* @author adu
* data 2024/7/5 17:18
*/
public
class
TestCheckTrainingTitleDuplicate
extends
BaseCreateTrainingData
{
String
trainingId
=
""
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Training
,
"API_checkTrainingTitleDuplicate"
,
LoginAccount
.
ADU_PROD
,
Terminal
.
B
,
"adu"
);
super
.
beforeTest
();
}
@Test
(
description
=
"测试创建训练营名称是否重复前置校验"
)
public
void
testCheckTrainingTitleDuplicate
()
throws
InterruptedException
{
//1.先创建一个活动
String
title
=
"杭州减肥训练营-未发布"
+
RandomStringUtil
.
randomString
(
5
);
trainingId
=
trainingTools
.
createTrainingNoPublish
(
title
,
courseId
,
trainerListIdS
);
//2.再次创建相同名称的活动,前置校验 返回true 重名,不能创建
Boolean
flag
=
trainingTools
.
checkTrainingTitleDuplicate
(
title
);
System
.
out
.
println
(
"%%%%%%%%%"
+
dataApi
.
getApi_response
());
Assert
.
assertTrue
(
flag
==
true
,
"存在相同训练营活动名称,没拦截,验重有bug"
);
//3.删除创建的活动后,再次创建check
trainingTools
.
deleteTraining
(
trainingId
);
Thread
.
sleep
(
1000
);
Boolean
flag1
=
trainingTools
.
checkTrainingTitleDuplicate
(
title
);
//false 不重名,可以创建
System
.
out
.
println
(
"^^^^^^^^"
+
dataApi
.
getApi_response
());
Assert
.
assertTrue
(
flag1
==
false
,
"相同名称活动已删除,但是还是不能创建"
);
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/training/TestDoForceOpenTraining.java
0 → 100644
View file @
757f26e9
package
com
.
xiaomai
.
cases
.
polar
.
training
;
import
com.alibaba.fastjson.JSONObject
;
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.AfterClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
/**
* 对报名中的活动操作立即成营
*
* @author adu
* data 2024/7/3 17:53
*/
public
class
TestDoForceOpenTraining
extends
BaseCreateTrainingData
{
@Resource
(
name
=
"trainingTools"
)
TrainingTools
trainingTools
;
String
id
=
""
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Training
,
"API_forceOpenTraining"
,
LoginAccount
.
ADU_PROD
,
Terminal
.
B
,
"adu"
);
super
.
beforeTest
();
}
@Test
(
description
=
"测试对未开营的活动操作立即成营"
)
public
void
testForceOpenTraining
()
throws
InterruptedException
{
//1.创建训练营活动:保存并发布
id
=
trainingTools
.
createThenPublishTraining
(
futureTimestampS
,
applyEndTime
,
courseId
,
openStartDate
,
openEndDate
,
0.01
,
trainingTitle
,
2
,
1
,
trainerListIdS
,
"YES"
);
if
(
id
.
isEmpty
())
{
id
=
trainingTools
.
createThenPublishTraining
(
futureTimestampS
,
applyEndTime
,
courseId
,
openStartDate
,
openEndDate
,
0.01
,
trainingTitle
+
RandomStringUtil
.
randomString
(
3
),
2
,
1
,
trainerListIdS
,
"YES"
);
}
//2.查看活动详情,check 活动状态
trainingTools
.
findTrainingDetailById
(
id
);
String
status
=
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.state"
);
//报名未开始APPLY_NOT_START
if
(
status
.
equals
(
"APPLY_NOT_START"
))
{
//对报名未开始的活动操作立即成营
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
dataApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"brandId"
,
dataApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"id"
,
id
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
xmAppApi
.
getApi_response
(),
"$.message"
),
"只有报名中的训练营能【立即成营】"
);
}
//3.创建成功后,全局搜索check
trainingTools
.
commonSearchTraining
(
trainingTitle
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
>
0
,
"活动创建后,根据活动名称全局搜索没有数据"
);
Thread
.
sleep
(
5000
);
//延迟5秒后,活动达到报名时间(可能状态没同步,定时任务没到时间执行,但是数据库中已是报名中)
//4.对报名中的活动操作立即成营
JSONObject
body1
=
new
JSONObject
();
body1
.
put
(
"operatorId"
,
dataApi
.
getLoginInfo
().
getAdminId
());
body1
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
body1
.
put
(
"brandId"
,
dataApi
.
getLoginInfo
().
getBrandId
());
body1
.
put
(
"id"
,
id
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body1
.
toString
(),
headers
).
assetsSuccess
(
true
);
}
@AfterClass
(
description
=
"删除此case创建的训练营活动"
)
public
void
delData
()
{
if
(!
id
.
isEmpty
())
{
trainingTools
.
deleteTraining
(
id
);
}
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/training/TestEditTraining.java
0 → 100644
View file @
757f26e9
package
com
.
xiaomai
.
cases
.
polar
.
training
;
import
com.alibaba.fastjson.JSONObject
;
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.AfterClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
/**
* 编辑训练营活动
* 场景1:未发布的操作编辑
* 场景2:报名中的操作编辑
*
* @author adu
* data 2024/7/3 20:51
*/
public
class
TestEditTraining
extends
BaseCreateTrainingData
{
@Resource
(
name
=
"trainingTools"
)
TrainingTools
trainingTools
;
String
trainingId
=
""
;
String
oneKeytTrainingId
=
""
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Training
,
"API_editTraining"
,
LoginAccount
.
ADU_PROD
,
Terminal
.
B
,
"adu"
);
super
.
beforeTest
();
}
@Test
(
description
=
"测试编辑未发布的训练营活动"
)
public
void
testEditTraining
()
{
//1创建未发布的训练营活动
String
title
=
"杭州减肥训练营-未发布"
+
RandomStringUtil
.
randomString
(
3
);
trainingId
=
trainingTools
.
createTrainingNoPublish
(
title
,
courseId
,
trainerListIdS
);
//根据训练营活动名称全局搜索
trainingTools
.
commonSearchTraining
(
title
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
>
0
,
"刚创建的活动没在全局搜索中发现哈"
);
//编辑未发布的活动
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 场馆
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"applyEndTime"
,
applyEndTime
);
//报名结束时间
body
.
put
(
"applyStartTime"
,
applyStartTime
);
//报名开始时间
body
.
put
(
"courseId"
,
courseId
);
//关联课程ID
body
.
put
(
"creatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
// 创建人即操作者
body
.
put
(
"openEndDate"
,
openEndDate1
);
//改了开营开始时间
body
.
put
(
"openStartDate"
,
openStartDate1
);
//改了开营结束时间
body
.
put
(
"price"
,
0.09
);
//售卖价格
body
.
put
(
"surfaceUrl"
,
"https://xiaomai-res.oss-cn-hangzhou.aliyuncs.com/xmfit/course_cover/training_camp_0.png"
);
// 默认活动封面图
String
editTitle
=
"杭州自动化测试训练营-未发布-编辑title"
+
RandomStringUtil
.
randomString
(
3
);
body
.
put
(
"title"
,
editTitle
);
body
.
put
(
"totalClassHour"
,
1
);
// 总课次数
body
.
put
(
"traineeLowerLimit"
,
1
);
// 开营人数
body
.
put
(
"traineeUpperLimit"
,
10
);
// 人数上限
body
.
put
(
"trainerList"
,
editTrainerListId
);
// 移除一个人
body
.
put
(
"xcxSaleStatus"
,
"NO"
);
//开启改成关闭小程序售卖
body
.
put
(
"underlinePrice"
,
999
);
//划线价
body
.
put
(
"id"
,
trainingId
);
//活动ID
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
//查看训练营活动详情
trainingTools
.
findTrainingDetailById
(
trainingId
);
String
detailResult
=
dataApi
.
getApi_response
();
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.title"
),
editTitle
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.openStartDate"
),
openStartDate1
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.xcxSaleStatus"
),
"NO"
);
Assert
.
assertEquals
(
Double
.
valueOf
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.underlinePrice"
)),
999.00
);
Assert
.
assertEquals
(
Double
.
valueOf
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.price"
)),
0.09
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.traineeLowerLimit"
),
"1"
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.traineeUpperLimit"
),
"10"
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.totalClassHour"
),
"1"
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
detailResult
,
"$.result.trainerIds"
).
size
()
==
1
,
"教练修改成1个人后,数据对不上"
);
}
@Test
(
description
=
"编辑已发布训练营活动"
)
public
void
editPublishTraining
()
{
//1.查询关联对应课程的活动数据
trainingTools
.
searchTrainingList
(
courseId
,
new
ArrayList
<>());
int
listCountBefore
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result.records"
).
size
();
//2.创建已发布的训练营活动
oneKeytTrainingId
=
trainingTools
.
oneKeyCreateTraining
(
courseId
,
trainerListIdS
);
//3.列表搜索数据check
trainingTools
.
searchTrainingList
(
courseId
,
new
ArrayList
<>());
int
listCountAfter
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result.records"
).
size
();
Assert
.
assertEquals
(
listCountAfter
,
(
listCountBefore
+
1
),
"训练营活动创建成功列表数据没增加"
);
JSONObject
goalObject
=
XMJSONPath
.
getJSONObjectByReadPath
(
dataApi
.
getApi_response
(),
"$.result.records[0]"
);
String
title
=
goalObject
.
getString
(
"title"
);
String
applyEndTime
=
goalObject
.
getString
(
"applyEndTime"
);
String
applyStartTime
=
goalObject
.
getString
(
"applyStartTime"
);
String
openStartDate
=
goalObject
.
getString
(
"openStartDate"
);
String
openEndDate
=
goalObject
.
getString
(
"openEndDate"
);
//4.编辑已发布的活动(训练营名称,关联课程,开营时间,总课次数,售价,报名开始时间,报名结束时间不能修改)check不能修改的传值后也不会改变
JSONObject
editBody
=
new
JSONObject
();
editBody
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
editBody
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 场馆
editBody
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
editBody
.
put
(
"applyEndTime"
,
applyEndTime
);
//报名结束时间
editBody
.
put
(
"applyStartTime"
,
applyStartTime
);
//报名开始时间
editBody
.
put
(
"courseId"
,
courseId
);
//关联课程ID
editBody
.
put
(
"creatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
// 创建人即操作者
editBody
.
put
(
"openEndDate"
,
openEndDate
);
//开营结束时间
editBody
.
put
(
"openStartDate"
,
openStartDate
);
//开营开始时间
editBody
.
put
(
"price"
,
10
);
//售卖价格
editBody
.
put
(
"surfaceUrl"
,
"https://xiaomai-res.oss-cn-hangzhou.aliyuncs.com/xmfit/course_cover/training_camp_0.png"
);
// 默认活动封面图
editBody
.
put
(
"title"
,
"title"
);
//名称不能修改,这里故意修改了,等保存后check数据
editBody
.
put
(
"totalClassHour"
,
20
);
// 总课时数,不能修改,这里故意修改了,等保存后check数据
editBody
.
put
(
"traineeLowerLimit"
,
1
);
// 开营人数
editBody
.
put
(
"traineeUpperLimit"
,
99
);
// 人数上限
editBody
.
put
(
"trainerList"
,
trainerListIdS
);
// 上课教练
editBody
.
put
(
"xcxSaleStatus"
,
"YES"
);
//开启小程序售卖
editBody
.
put
(
"underlinePrice"
,
29.9
);
//可以修改
editBody
.
put
(
"id"
,
oneKeytTrainingId
);
//活动ID
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
editBody
.
toString
(),
headers
).
assetsSuccess
(
true
);
//5.查看活动详情,check 不能修改项和一修改项是否被同步修改
trainingTools
.
findTrainingDetailById
(
oneKeytTrainingId
);
//5.1不能修改的字段check(修改后和修改前比对)
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.title"
),
title
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.totalClassHour"
),
"2"
);
Assert
.
assertEquals
(
Double
.
valueOf
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.price"
)),
0.00
);
//5.2可以修改字段check是否被同步修改
Assert
.
assertEquals
(
Double
.
valueOf
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.underlinePrice"
)),
29.90
);
}
@AfterClass
(
description
=
"删除此case创建的训练营"
)
public
void
delData
()
{
if
(!
trainingId
.
isEmpty
())
{
trainingTools
.
deleteTraining
(
trainingId
);
}
if
(!
oneKeytTrainingId
.
isEmpty
())
{
trainingTools
.
deleteTraining
(
oneKeytTrainingId
);
}
}
}
src/main/java/com/xiaomai/cases/polar/training/TestSearchTrainingList.java
0 → 100644
View file @
757f26e9
package
com
.
xiaomai
.
cases
.
polar
.
training
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.XMJSONPath
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 训练营活动列表筛选下测试
*
* @author adu
* data 2024/7/5 18:08
*/
public
class
TestSearchTrainingList
extends
BaseCreateTrainingData
{
@Resource
(
name
=
"trainingTools"
)
TrainingTools
trainingTools
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Training
,
"API_searchTrainingList"
,
LoginAccount
.
ADU_PROD
,
Terminal
.
B
,
"adu"
);
super
.
beforeTest
();
}
@DataProvider
(
name
=
"filterTrainingListDateByCondition"
)
public
Object
[][]
dataProvider
()
{
List
<
String
>
statu1
=
new
ArrayList
<>();
statu1
.
add
(
"UNPUBLISHED"
);
//未发布
List
<
String
>
statu2
=
new
ArrayList
<>();
statu2
.
add
(
"APPLY_NOT_START"
);
//报名未开始
List
<
String
>
statu3
=
new
ArrayList
<>();
statu3
.
add
(
"APPLYING"
);
//报名中
List
<
String
>
statu4
=
new
ArrayList
<>();
statu4
.
add
(
"TO_BE_OPEN"
);
//待开营
List
<
String
>
statu5
=
new
ArrayList
<>();
statu5
.
add
(
"OPENING"
);
//进行中
List
<
String
>
statu6
=
new
ArrayList
<>();
statu6
.
add
(
"CLOSED"
);
//已结束
List
<
String
>
statu7
=
new
ArrayList
<>();
statu7
.
add
(
"CANCEL"
);
//已取消
List
<
String
>
statu8
=
new
ArrayList
<>();
//训练营排课时选择以下4种状态的活动
statu8
.
add
(
"APPLY_NOT_START"
);
//报名未开始
statu8
.
add
(
"APPLYING"
);
//报名中
statu8
.
add
(
"TO_BE_OPEN"
);
//待开营
statu8
.
add
(
"OPENING"
);
//进行中
return
new
Object
[][]{
{
""
,
""
,
new
ArrayList
<>()},
//无筛选条件
{
courseId
,
""
,
new
ArrayList
<>()},
//根据关联课程搜索
{
""
,
"杭州自动化测试训练营"
,
statu8
},
//根据训练营名称搜索
{
""
,
""
,
statu1
},
//根据训练营状态(未发布)搜索
{
""
,
""
,
statu2
},
//根据训练营状态(报名未开始)搜索
{
""
,
""
,
statu3
},
//根据训练营状态(报名中)搜索
{
""
,
""
,
statu4
},
//根据训练营状态(待开营)搜索
{
""
,
""
,
statu5
},
//根据训练营状态(进行中)搜索
{
""
,
""
,
statu6
},
//根据训练营状态(已结束)搜索
{
""
,
""
,
statu7
},
//根据训练营状态(已取消)搜索
{
courseId
,
""
,
statu1
},
//根据训练营状态(未发布)和关联课程搜索
{
courseId
,
""
,
statu2
},
//根据训练营状态(报名未开和关联课程搜索
{
courseId
,
""
,
statu3
},
//根据训练营状态(报名中)和关联课程搜索
{
courseId
,
""
,
statu4
},
//根据训练营状态(待开营)和关联课程搜索
{
courseId
,
""
,
statu5
},
//根据训练营状态(进行中)和关联课程搜索
{
courseId
,
""
,
statu6
},
//根据训练营状态(已结束)和关联课程搜索
{
courseId
,
""
,
statu7
},
//根据训练营状态(已取消)和关联课程搜索
};
}
@Test
(
dataProvider
=
"filterTrainingListDateByCondition"
)
public
void
testSearchTrainingList
(
String
courseId
,
String
title
,
List
<
String
>
stateList
){
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"current"
,
0
);
body
.
put
(
"size"
,
20
);
body
.
put
(
"courseId"
,
courseId
);
body
.
put
(
"stateList"
,
stateList
);
body
.
put
(
"title"
,
title
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
//有存量数据,理论上每个查询都会至少有1条数据
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
xmAppApi
.
getApi_response
(),
"$.result.records"
).
size
()>=
1
,
"没有搜索到相关数据"
);
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/training/TrainingTools.java
0 → 100644
View file @
757f26e9
This diff is collapsed.
Click to expand it.
src/main/java/com/xiaomai/enums/ApiModule.java
View file @
757f26e9
...
...
@@ -22,6 +22,7 @@ public class ApiModule {
public
static
String
Polar_Schedule
=
"polar_schedule"
;
//课程排期
public
static
String
Polar_Card
=
"polar_card"
;
//会员卡
public
static
String
Polar_Training
=
"polar_training"
;
//训练营活动
...
...
src/main/java/com/xiaomai/enums/LoginAccount.java
View file @
757f26e9
...
...
@@ -18,4 +18,6 @@ public class LoginAccount {
public
static
String
XYM_MINIAPPC
=
"xym_miniAppC"
;
public
static
String
GYM_MINIAPPC
=
"gym_miniAppC"
;
public
static
String
XYY_PROD
=
"xyy_prod"
;
}
src/main/java/com/xiaomai/utils/CommUtil.java
View file @
757f26e9
...
...
@@ -12,6 +12,7 @@ import java.lang.reflect.Method;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.util.*
;
public
class
CommUtil
{
...
...
@@ -250,7 +251,7 @@ public class CommUtil {
*/
public
static
Long
getWholeHourTimestamp
(){
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
6
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
Long
wholeHourTimestamp
=
calendar
.
getTimeInMillis
();
...
...
@@ -259,6 +260,7 @@ public class CommUtil {
}
public
static
String
getStringTimestampByStrTime
(
String
time
)
{
String
timestamp
=
null
;
DateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
...
...
@@ -292,6 +294,23 @@ public class CommUtil {
String
startStamp
=
getStringTimestampByStrTime
(
getNextWeekXDayDataS
+
" "
+
"14:00"
);
System
.
out
.
println
(
"********"
+
startStamp
);
long
currentTimestamp
=
System
.
currentTimeMillis
();
// 在当前时间的基础上,加上2秒(2000毫秒)
long
futureTimestamp
=
currentTimestamp
+
2000
;
// 输出未来时间戳
System
.
out
.
println
(
"当前时间戳: "
+
currentTimestamp
);
System
.
out
.
println
(
"未来2秒后的时间戳: "
+
futureTimestamp
);
// 获取当前时间
LocalDateTime
now
=
LocalDateTime
.
now
();
System
.
out
.
println
(
"当前时间: "
+
now
);
// 延后2秒
LocalDateTime
future
=
now
.
plusSeconds
(
2
);
System
.
out
.
println
(
"未来2秒时间: "
+
future
);
}
...
...
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