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
a15f098e
Commit
a15f098e
authored
Jun 11, 2024
by
xuyamei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
课程管理
parent
7ea5f7bf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
509 additions
and
0 deletions
+509
-0
src/main/java/com/xiaomai/cases/polar/course/CourseTools.java
+0
-0
src/main/java/com/xiaomai/cases/polar/course/TestCheckCourseNameDup.java
+66
-0
src/main/java/com/xiaomai/cases/polar/course/TestCreateGroupCourse.java
+99
-0
src/main/java/com/xiaomai/cases/polar/course/TestCreatePersonalCourse.java
+115
-0
src/main/java/com/xiaomai/cases/polar/course/TestCreateSpecialDate.java
+48
-0
src/main/java/com/xiaomai/cases/polar/course/TestEditGroupCourse.java
+87
-0
src/main/java/com/xiaomai/cases/polar/course/TestEditPersonalCourse.java
+94
-0
No files found.
src/main/java/com/xiaomai/cases/polar/course/CourseTools.java
0 → 100644
View file @
a15f098e
This diff is collapsed.
Click to expand it.
src/main/java/com/xiaomai/cases/polar/course/TestCheckCourseNameDup.java
0 → 100644
View file @
a15f098e
package
com
.
xiaomai
.
cases
.
polar
.
course
;
import
com.alibaba.fastjson.JSONArray
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.setting.courseCategory.CourseCategoryTools
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.Terminal
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.course
* @Author: xuyamei
* @CreateTime: 2024-05-06 18:19
* @Description: 校验课程名称重复
* @Version: 1.0
*/
public
class
TestCheckCourseNameDup
extends
BaseTestImpl
{
@Resource
(
name
=
"courseCategoryTools"
)
CourseCategoryTools
courseCategoryTools
;
@Resource
(
name
=
"courseTools"
)
CourseTools
courseTools
;
@BeforeClass
public
void
beforeTest
(){
setTestInfo
(
ApiModule
.
Polar_Course
,
"API_checkCourseNameDup"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@DataProvider
()
public
Object
[][]
data
(){
return
new
Object
[][]{
{
"1对多名称是否重复校验哈哈哈哈哈哈哈"
,
false
,
"校验名称重复不存在但返回了true"
},
{
"课程"
,
true
,
"校验名称重复存在但返回了false"
}
};
}
@Test
(
dataProvider
=
"data"
)
public
void
testCheckCourseNameDup
(
String
name
,
boolean
isDup
,
String
msg
)
{
// 为了校验存在的课程名称返回的是否正确
if
(
isDup
){
// 获取课程分类
String
categoryId
=
courseCategoryTools
.
getCourseCategoryPage
(
"瑜伽"
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
JSONArray
arr
=
courseTools
.
getPersonalOrGroupCourseId
(
"GROUP"
,
name
,
categoryId
,
"STUDIO"
,
""
,
2
,
1
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
name
=
arr
.
getString
(
1
);
}
Assert
.
assertEquals
(
courseTools
.
checkCourseNameDup
(
name
),
isDup
,
msg
);
}
}
src/main/java/com/xiaomai/cases/polar/course/TestCreateGroupCourse.java
0 → 100644
View file @
a15f098e
package
com
.
xiaomai
.
cases
.
polar
.
course
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.setting.courseCategory.CourseCategoryTools
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.TimeUtils
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
import
java.util.Random
;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.course
* @Author: xuyamei
* @CreateTime: 2024-05-07 17:06
* @Description: 创建团课
* @Version: 1.0
*/
public
class
TestCreateGroupCourse
extends
BaseTestImpl
{
@Resource
(
name
=
"courseCategoryTools"
)
CourseCategoryTools
courseCategoryTools
;
@Resource
(
name
=
"courseTools"
)
CourseTools
courseTools
;
private
String
courseId
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Course
,
"API_createGroupCourse"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@Test
public
void
testCreateGroupCourse
()
{
// 查询存量的课程分类
String
categoryId
=
courseCategoryTools
.
getCourseCategoryPage
(
"瑜伽"
);
String
courseName
=
"瑜伽团课"
+
TimeUtils
.
getCurrentTime
();
Random
random
=
new
Random
();
int
duration
=
random
.
nextInt
(
60
)+
10
;
// 时长
int
difficulty
=
random
.
nextInt
(
5
)+
1
;
// 难度
int
calorie
=
random
.
nextInt
(
100
)+
100
;
String
introduction
=
"{\"items\":[{\"content\":\"花花世界的\",\"aspect\":\"\",\"type\":\"TEXT\"}]}"
;
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"courseName"
,
courseName
);
body
.
put
(
"duration"
,
duration
);
// 时长
body
.
put
(
"difficulty"
,
difficulty
);
// 难度
body
.
put
(
"color"
,
"#AACF53"
);
body
.
put
(
"coverId"
,
"0"
);
body
.
put
(
"timeUnit"
,
"MINUTE"
);
body
.
put
(
"categoryId"
,
categoryId
);
body
.
put
(
"introduction"
,
introduction
);
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"sourceId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 来源:场馆、品牌
body
.
put
(
"sourceType"
,
"STUDIO"
);
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
// 品牌
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 场馆
body
.
put
(
"calorie"
,
calorie
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
// 获取课程id
courseId
=
xmAppApi
.
getBodyInJSON
().
getString
(
"result"
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
// check 1:列表是否有该团课数据
JSONObject
coursePage
=
courseTools
.
getGroupClassPage
(
"ON"
,
0
,
courseName
,
categoryId
);
String
total
=
coursePage
.
getString
(
"total"
);
Assert
.
assertEquals
(
total
,
"1"
,
"新建之后团课列表没有找到相关数据"
);
// check 2:团课详情内容是否与新建一致
String
[]
keys
=
{
"courseName"
,
"duration"
,
"difficulty"
,
"color"
,
"coverId"
,
"timeUnit"
,
"categoryId"
,
"sourceId"
,
"sourceType"
,
"brandId"
,
"calorie"
};
String
[]
values
=
{
courseName
,
String
.
valueOf
(
duration
),
String
.
valueOf
(
difficulty
),
"#AACF53"
,
"1772108160765263873"
,
"MINUTE"
,
categoryId
,
xmAppApi
.
getLoginInfo
().
getStudioId
(),
"STUDIO"
,
xmAppApi
.
getLoginInfo
().
getBrandId
(),
String
.
valueOf
(
calorie
)};
JSONObject
courseDetail
=
courseTools
.
getCourseDetail
(
courseId
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
String
result
=
values
[
i
];
Assert
.
assertEquals
(
courseDetail
.
getString
(
keys
[
i
]),
result
,
"新建之后课程详情与新建内容不一致"
);
}
}
@Test
(
description
=
"清除增量数据"
,
priority
=
1
)
public
void
del
(){
// 删除课程数据
courseTools
.
modifyCourseStatus
(
courseId
,
"DELETE"
,
false
);
}
}
src/main/java/com/xiaomai/cases/polar/course/TestCreatePersonalCourse.java
0 → 100644
View file @
a15f098e
package
com
.
xiaomai
.
cases
.
polar
.
course
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.setting.courseCategory.CourseCategoryTools
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.TimeUtils
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.course
* @Author: xuyamei
* @CreateTime: 2024-04-23 14:15
* @Description: 创建私教课程
* @Version: 1.0
*/
public
class
TestCreatePersonalCourse
extends
BaseTestImpl
{
@Resource
(
name
=
"courseCategoryTools"
)
CourseCategoryTools
courseCategoryTools
;
@Resource
(
name
=
"courseTools"
)
CourseTools
courseTools
;
private
JSONArray
courseIds
=
new
JSONArray
();
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Course
,
"API_personalCreate"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@DataProvider
()
public
Object
[][]
data
(){
return
new
Object
[][]{
{
"1对多"
,
"ONE_TO_MANY"
},
// 1对多
{
"1对1"
,
"ONE_TO_ONE"
},
// 1对1
};
}
@Test
(
dataProvider
=
"data"
)
public
void
testCreatePersonalCourse
(
String
name
,
String
sizeType
)
{
// 获取课程分类
String
categoryId
=
courseCategoryTools
.
getCourseCategoryPage
(
"私教课分类"
+
TimeUtils
.
getCurrentTime
());
// 新建课程参数
JSONObject
body
=
new
JSONObject
();
String
courseName
=
name
+
"私教课程"
+
TimeUtils
.
getCurrentTime
();
body
.
put
(
"courseName"
,
courseName
);
body
.
put
(
"duration"
,
60
);
// 时长
body
.
put
(
"difficulty"
,
3
);
// 难度
body
.
put
(
"color"
,
"#AACF53"
);
body
.
put
(
"coverId"
,
"0"
);
body
.
put
(
"timeUnit"
,
"MINUTE"
);
body
.
put
(
"categoryId"
,
categoryId
);
// 课程分类id
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"sourceId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 来源:场馆、品牌
body
.
put
(
"sourceType"
,
"STUDIO"
);
// 来源类型:场馆、品牌
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
// 品牌
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"sizeType"
,
sizeType
);
// 私教模式
body
.
put
(
"allArea"
,
false
);
// 场地
JSONArray
coachIds
=
new
JSONArray
();
coachIds
.
add
(
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"coachIds"
,
coachIds
);
if
(
sizeType
.
equals
(
"ONE_TO_MANY"
)){
body
.
put
(
"capacity"
,
2
);
// 课容量
body
.
put
(
"minCapacity"
,
1
);
// 开课人数
}
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
String
courseId
=
xmAppApi
.
getBodyInJSON
().
getString
(
"result"
);
courseIds
.
add
(
courseId
);
try
{
Thread
.
sleep
(
2000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
// check 1:查询私教课程列表
String
total
=
courseTools
.
getPersonalPage
(
"ON"
,
0
,
courseName
,
categoryId
,
sizeType
,
""
).
getString
(
"total"
);
Assert
.
assertEquals
(
total
,
"1"
,
"新建之后私教列表没有找到相关数据"
);
// check 2: 查看课程详情是否与新建内容一致
JSONObject
courseDetail
=
courseTools
.
getCourseDetail
(
courseId
);
String
[]
keys
=
{
"courseName"
,
"duration"
,
"difficulty"
,
"color"
,
"coverId"
,
"timeUnit"
,
"categoryId"
,
"sourceId"
,
"sourceType"
,
"brandId"
,
"sizeType"
,
"allArea"
,
"capacity"
,
"minCapacity"
};
String
[]
values
=
{
courseName
,
"60"
,
"3"
,
"#AACF53"
,
"1772108160765263873"
,
"MINUTE"
,
categoryId
,
xmAppApi
.
getLoginInfo
().
getStudioId
(),
"STUDIO"
,
xmAppApi
.
getLoginInfo
().
getBrandId
(),
sizeType
,
"false"
,
"2"
,
"1"
};
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
String
result
=
values
[
i
];
// 1对1的容量为1
if
(
sizeType
.
equals
(
"ONE_TO_ONE"
)
&&
keys
[
i
].
equals
(
"capacity"
)){
result
=
"1"
;
}
Assert
.
assertEquals
(
courseDetail
.
getString
(
keys
[
i
]),
result
,
"新建之后课程详情与新建内容不一致"
);
}
}
@Test
(
description
=
"清除增量数据"
,
priority
=
1
)
public
void
del
(){
// 删除课程数据
for
(
int
i
=
0
;
i
<
courseIds
.
size
();
i
++){
courseTools
.
modifyCourseStatus
(
courseIds
.
getString
(
i
),
"DELETE"
,
false
);
}
}
}
src/main/java/com/xiaomai/cases/polar/course/TestCreateSpecialDate.java
0 → 100644
View file @
a15f098e
package
com
.
xiaomai
.
cases
.
polar
.
course
;
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.TimeUtils
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.course
* @Author: xuyamei
* @CreateTime: 2024-04-25 11:43
* @Description: 创建特定日期可约
* @Version: 1.0
*/
public
class
TestCreateSpecialDate
extends
BaseTestImpl
{
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Admin
,
"API_createSpecialDate"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@Test
public
void
testCreateSpecialDate
()
{
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"coachId"
,
"1762382404818898946"
);
// 特定时间
JSONObject
specialTimeInfoRequest
=
new
JSONObject
();
specialTimeInfoRequest
.
put
(
"dutyType"
,
"OFF_DUTY"
);
JSONArray
specialTimeInfoRequestArray
=
new
JSONArray
();
specialTimeInfoRequestArray
.
add
(
TimeUtils
.
getBeforeDayDate
(
3
));
specialTimeInfoRequest
.
put
(
"selectedDates"
,
specialTimeInfoRequestArray
);
body
.
put
(
"specialTimeInfoRequest"
,
specialTimeInfoRequest
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
}
}
src/main/java/com/xiaomai/cases/polar/course/TestEditGroupCourse.java
0 → 100644
View file @
a15f098e
package
com
.
xiaomai
.
cases
.
polar
.
course
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.setting.courseCategory.CourseCategoryTools
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.TimeUtils
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
import
java.util.Random
;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.course
* @Author: xuyamei
* @CreateTime: 2024-05-07 17:36
* @Description: 编辑团课
* @Version: 1.0
*/
public
class
TestEditGroupCourse
extends
BaseTestImpl
{
@Resource
(
name
=
"courseCategoryTools"
)
CourseCategoryTools
courseCategoryTools
;
@Resource
(
name
=
"courseTools"
)
CourseTools
courseTools
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Course
,
"API_editGroupCourse"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@Test
public
void
testEditGroupCourse
()
{
String
categoryId
=
courseCategoryTools
.
getCourseCategoryPage
(
""
);
String
courseId
=
courseTools
.
getPersonalOrGroupCourseId
(
"GROUP"
,
"存量瑜伽团课课程"
,
categoryId
,
"STUDIO"
,
""
,
2
,
1
).
getString
(
0
);
try
{
Thread
.
sleep
(
2000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
Random
random
=
new
Random
();
int
duration
=
random
.
nextInt
(
60
)
+
10
;
int
difficulty
=
random
.
nextInt
(
5
)
+
1
;
int
calorie
=
random
.
nextInt
(
100
)
+
100
;
String
introduction
=
"{\"items\":[{\"content\":\"花花世界的\",\"aspect\":\"\",\"type\":\"TEXT\"}]}"
;
String
courseName
=
"存量瑜伽团课课程"
+
TimeUtils
.
getCurrentTime
();
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"courseName"
,
courseName
);
body
.
put
(
"duration"
,
duration
);
// 时长
body
.
put
(
"difficulty"
,
difficulty
);
// 难度
body
.
put
(
"color"
,
"#AACF53"
);
body
.
put
(
"coverId"
,
"0"
);
body
.
put
(
"timeUnit"
,
"MINUTE"
);
body
.
put
(
"categoryId"
,
categoryId
);
body
.
put
(
"introduction"
,
introduction
);
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"sourceId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 来源:场馆、品牌
body
.
put
(
"sourceType"
,
"STUDIO"
);
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 场馆
body
.
put
(
"calorie"
,
calorie
);
// 卡路里
body
.
put
(
"brandCourseId"
,
courseId
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
String
[]
keys
=
{
"courseName"
,
"duration"
,
"difficulty"
,
"color"
,
"coverId"
,
"timeUnit"
,
"categoryId"
,
"sourceId"
,
"sourceType"
,
"brandId"
,
"calorie"
};
String
[]
values
=
{
courseName
,
String
.
valueOf
(
duration
),
String
.
valueOf
(
difficulty
),
"#AACF53"
,
"1772108160765263873"
,
"MINUTE"
,
categoryId
,
xmAppApi
.
getLoginInfo
().
getStudioId
(),
"STUDIO"
,
xmAppApi
.
getLoginInfo
().
getBrandId
(),
String
.
valueOf
(
calorie
)};
// 校验内容与编辑的是否一致
JSONObject
courseDetail
=
courseTools
.
getCourseDetail
(
courseId
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
String
result
=
values
[
i
];
Assert
.
assertEquals
(
courseDetail
.
getString
(
keys
[
i
]),
result
,
"编辑之后课程详情与编辑内容不一致"
);
}
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/course/TestEditPersonalCourse.java
0 → 100644
View file @
a15f098e
package
com
.
xiaomai
.
cases
.
polar
.
course
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.setting.courseCategory.CourseCategoryTools
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.TimeUtils
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
import
java.util.Random
;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.course
* @Author: xuyamei
* @CreateTime: 2024-05-07 14:36
* @Description: 编辑私教课
* @Version: 1.0
*/
public
class
TestEditPersonalCourse
extends
BaseTestImpl
{
@Resource
(
name
=
"courseCategoryTools"
)
CourseCategoryTools
courseCategoryTools
;
@Resource
(
name
=
"courseTools"
)
CourseTools
courseTools
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Course
,
"API_editPersonalCourse"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@Test
public
void
testEditPersonalCourse
()
{
String
categoryId
=
courseCategoryTools
.
getCourseCategoryPage
(
"瑜伽"
);
// 查询存量的课程用于编辑
JSONArray
courseIdArray
=
courseTools
.
getPersonalOrGroupCourseId
(
"PERSONAL"
,
"存量瑜伽课程"
,
categoryId
,
"STUDIO"
,
"ONE_TO_MANY"
,
2
,
1
);
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
String
courseId
=
courseIdArray
.
getString
(
0
);
Random
random
=
new
Random
();
JSONObject
courseDetail
=
courseTools
.
getCourseDetail
(
courseId
);
int
duration
=
random
.
nextInt
(
60
)+
10
;
int
difficulty
=
random
.
nextInt
(
5
)+
1
;
int
capacity
=
random
.
nextInt
(
10
)+
1
;
String
courseName
=
"存量瑜伽课程"
+
TimeUtils
.
getCurrentTime
();
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"categoryId"
,
courseDetail
.
getString
(
"categoryId"
));
body
.
put
(
"courseName"
,
courseName
);
body
.
put
(
"duration"
,
duration
);
// 时长
body
.
put
(
"difficulty"
,
difficulty
);
// 难度
body
.
put
(
"color"
,
"#AACF53"
);
body
.
put
(
"coverId"
,
"0"
);
body
.
put
(
"timeUnit"
,
"MINUTE"
);
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"sourceId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 来源:场馆、品牌
body
.
put
(
"sourceType"
,
"STUDIO"
);
// 来源类型:场馆、品牌
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
// 品牌
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"sizeType"
,
"ONE_TO_MANY"
);
// 私教模式
body
.
put
(
"allArea"
,
false
);
// 场地
JSONArray
coachIds
=
new
JSONArray
();
coachIds
.
add
(
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"coachIds"
,
coachIds
);
body
.
put
(
"capacity"
,
capacity
);
// 课容量
body
.
put
(
"minCapacity"
,
1
);
// 开课人数
body
.
put
(
"brandCourseId"
,
courseId
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
String
[]
keys
=
{
"courseName"
,
"duration"
,
"difficulty"
,
"color"
,
"coverId"
,
"timeUnit"
,
"categoryId"
,
"sourceId"
,
"sourceType"
,
"brandId"
,
"sizeType"
,
"allArea"
,
"capacity"
,
"minCapacity"
};
String
[]
values
=
{
courseName
,
String
.
valueOf
(
duration
),
String
.
valueOf
(
difficulty
),
"#AACF53"
,
"1772108160765263873"
,
"MINUTE"
,
categoryId
,
xmAppApi
.
getLoginInfo
().
getStudioId
(),
"STUDIO"
,
xmAppApi
.
getLoginInfo
().
getBrandId
(),
"ONE_TO_MANY"
,
"false"
,
String
.
valueOf
(
capacity
),
"1"
};
// 校验内容与编辑的是否一致
courseDetail
=
courseTools
.
getCourseDetail
(
courseId
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
String
result
=
values
[
i
];
Assert
.
assertEquals
(
courseDetail
.
getString
(
keys
[
i
]),
result
,
"编辑之后课程详情与编辑内容不一致"
);
}
}
}
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