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
42613838
Commit
42613838
authored
Jul 24, 2024
by
xuyamei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增设置私教教练可约时间
parent
edc2b7a3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
424 additions
and
10 deletions
+424
-10
src/main/java/com/xiaomai/cases/polar/reserve/ReserveTools.java
+39
-4
src/main/java/com/xiaomai/cases/polar/reserve/personal/TestCreateBatchNormalDate.java
+125
-0
src/main/java/com/xiaomai/cases/polar/reserve/personal/TestCreateBatchSpecialDate.java
+179
-0
src/main/java/com/xiaomai/cases/polar/reserve/personal/TestCreateSpecialDate.java
+1
-6
src/main/java/com/xiaomai/cases/polar/reserve/personal/TestModifySpecialDate.java
+80
-0
No files found.
src/main/java/com/xiaomai/cases/polar/reserve/ReserveTools.java
View file @
42613838
...
...
@@ -433,9 +433,9 @@ public class ReserveTools extends XMBaseTest {
* @description:创建特殊可约时间
* @author: xuyamei
* @date: 2024/7/23 16:39
* @param coachId
* @param coachId
教练id
* @param dutyType ["OFF_DUTY","ON_DUTY"] ["全天休息","可约时间"]
* @param specialTimeInfoRequests
* @param specialTimeInfoRequests
:可单独传可约时间段,不用默认创建全天休息的时间
* @param userInfo
* @return: void
**/
...
...
@@ -456,7 +456,7 @@ public class ReserveTools extends XMBaseTest {
// 设置特定日期
JSONArray
selectedDates
=
new
JSONArray
();
selectedDates
.
add
(
TimeUtils
.
get
BeforeDayDate
(
3
));
selectedDates
.
add
(
TimeUtils
.
get
TodayTime
(
));
specialTimeInfoRequests
.
put
(
"selectedDates"
,
selectedDates
);
// 如果是可约时间非全天休息,则传可约时间段
...
...
@@ -475,6 +475,11 @@ public class ReserveTools extends XMBaseTest {
body
.
put
(
"specialTimeInfoRequest"
,
specialTimeInfoRequests
);
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
body
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
...
...
@@ -482,7 +487,7 @@ public class ReserveTools extends XMBaseTest {
* @description: 删除特殊可约时间
* @author: xuyamei
* @date: 2024/7/23 16:39
* @param id 特约日期id
* @param id 特约日期
记录
id
* @param userInfo
**/
public
void
deleteSpecialDate
(
String
id
,
DataUserInfo
...
userInfo
){
...
...
@@ -500,6 +505,36 @@ public class ReserveTools extends XMBaseTest {
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
body
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
}
/**
* @description: 修改特殊可约时间
* @author: xuyamei
* @date: 2024/7/24 11:16
* @param coachId 教练id
* @param dutyType 可约类型 ["OFF_DUTY","ON_DUTY"] ["全天休息","可约时间"]
* @param timePeriodInfos 时间段 [{minuteOffset,spanMinutes}] 可约类型为全天休息时传空
* @param userInfo
* @return: void
**/
public
void
modifySpecialDate
(
String
coachId
,
String
dutyType
,
JSONArray
timePeriodInfos
,
Long
selectedDate
,
DataUserInfo
...
userInfo
){
setUp
(
"API_modifySpecialDate"
,
userInfo
);
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"brandId"
,
dataApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"operatorId"
,
dataApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"dutyType"
,
dutyType
);
body
.
put
(
"coachId"
,
coachId
);
body
.
put
(
"selectedDate"
,
selectedDate
);
if
(
timePeriodInfos
.
size
()
!=
0
){
body
.
put
(
"timePeriodInfos"
,
timePeriodInfos
);
}
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
body
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
}
}
src/main/java/com/xiaomai/cases/polar/reserve/personal/TestCreateBatchNormalDate.java
0 → 100644
View file @
42613838
package
com
.
xiaomai
.
cases
.
polar
.
reserve
.
personal
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.reserve.ReserveTools
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.Random
;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.reserve.personal
* @Author: xuyamei
* @CreateTime: 2024-07-24 11:49
* @Description: 批量设置常规可约时间
* @Version: 1.0
*/
public
class
TestCreateBatchNormalDate
extends
BaseTestImpl
{
@Resource
(
name
=
"reserveTools"
)
ReserveTools
reserveTools
;
JSONArray
coachIds
=
new
JSONArray
();
@BeforeClass
public
void
beforeTest
(){
setTestInfo
(
ApiModule
.
Polar_Reserve
,
"API_createBatchNormalDate"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@Test
public
void
testCreateBatchNormalDate
(){
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
// 操作人id
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
// 获取教练列表
JSONObject
pageStudioPersonalCoach
=
reserveTools
.
pageStudioPersonalCoach
(
""
);
int
total
=
pageStudioPersonalCoach
.
getInteger
(
"total"
);
Random
rand
=
new
Random
();
// 随机取两个教练
String
coachedId1
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
10
:
total
)).
getString
(
"id"
);
coachIds
.
add
(
coachedId1
);
String
coachedId2
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
10
:
total
)).
getString
(
"id"
);
if
(
coachedId1
.
equals
(
coachedId2
)){
coachedId2
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
9
:
total
-
1
)).
getString
(
"id"
);
}
coachIds
.
add
(
coachedId2
);
body
.
put
(
"coachIds"
,
coachIds
);
// 员工id
// 设置可约时间
JSONArray
normalTimeInfoRequests
=
new
JSONArray
();
JSONObject
infoRequests
=
new
JSONObject
();
JSONArray
timePeriodInfos
=
new
JSONArray
();
// 三个时段 5:00-12:00 12:00-18:00 18:00-23:00
int
[]
minuteOffset
=
{
300
,
720
,
1080
};
int
[]
spanMinutes
=
{
420
,
360
,
300
};
for
(
int
i
=
0
;
i
<
3
;
i
++){
JSONObject
timeInfo
=
new
JSONObject
();
timeInfo
.
put
(
"minuteOffset"
,
minuteOffset
[
i
]);
timeInfo
.
put
(
"spanMinutes"
,
spanMinutes
[
i
]);
timePeriodInfos
.
add
(
timeInfo
);
}
infoRequests
.
put
(
"timePeriodInfos"
,
timePeriodInfos
);
// 每星期
String
[]
weekdays
=
{
"MONDAY"
,
"TUESDAY"
,
"WEDNESDAY"
,
"THURSDAY"
,
"FRIDAY"
,
"SATURDAY"
,
"SUNDAY"
};
infoRequests
.
put
(
"weekdays"
,
weekdays
);
normalTimeInfoRequests
.
add
(
infoRequests
);
body
.
put
(
"normalTimeInfoRequests"
,
normalTimeInfoRequests
);
// 批量设置可约时间
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
for
(
int
i
=
0
;
i
<
coachIds
.
size
();
i
++){
JSONArray
personalCoachTime
=
reserveTools
.
getPersonalCoachTime
(
coachIds
.
getString
(
i
),
"normalTimeVOS"
);
// 校验每周重复的可约时间
Assert
.
assertEquals
(
timePeriodInfos
.
toString
(),
personalCoachTime
.
getJSONObject
(
0
).
getJSONArray
(
"timePeriodInfos"
).
toString
(),
"每周重复的可约时间请求结果与实际结果不一样"
);
JSONArray
weekDays
=
new
JSONArray
(
Arrays
.
asList
(
weekdays
));
Assert
.
assertEquals
(
weekDays
.
toString
(),
personalCoachTime
.
getJSONObject
(
0
).
getJSONArray
(
"weekdays"
).
toString
(),
"每周重复的周请求结果与实际结果不一样"
);
}
}
@Test
(
description
=
"将设置的值清空"
,
priority
=
1
)
public
void
testCreateBatchNormalDate_clear
(){
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
// 操作人id
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
JSONArray
normalTimeInfoRequests
=
new
JSONArray
();
body
.
put
(
"normalTimeInfoRequests"
,
normalTimeInfoRequests
);
body
.
put
(
"coachIds"
,
coachIds
);
// 员工id
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
for
(
int
i
=
0
;
i
<
coachIds
.
size
();
i
++){
JSONArray
personalCoachTime
=
reserveTools
.
getPersonalCoachTime
(
coachIds
.
getString
(
i
),
"normalTimeVOS"
);
// 校验每周重复的可约时间
Assert
.
assertTrue
(
personalCoachTime
.
size
()==
0
,
"清空数据后还能查询到数据"
);
}
}
}
src/main/java/com/xiaomai/cases/polar/reserve/personal/TestCreateBatchSpecialDate.java
0 → 100644
View file @
42613838
package
com
.
xiaomai
.
cases
.
polar
.
reserve
.
personal
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.reserve.ReserveTools
;
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.reserve.personal
* @Author: xuyamei
* @CreateTime: 2024-07-24 15:32
* @Description:批量设置特殊可约时间
* @Version: 1.0
*/
public
class
TestCreateBatchSpecialDate
extends
BaseTestImpl
{
@Resource
(
name
=
"reserveTools"
)
ReserveTools
reserveTools
;
JSONArray
coachIds
=
new
JSONArray
();
JSONArray
records
=
new
JSONArray
();
@BeforeClass
public
void
beforeTest
(){
setTestInfo
(
ApiModule
.
Polar_Reserve
,
"API_createBatchSpecialDate"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@Test
(
description
=
"设置特定日期可约"
)
public
void
testCreateBatchSpecialDate
()
{
// 获取教练列表
JSONObject
pageStudioPersonalCoach
=
reserveTools
.
pageStudioPersonalCoach
(
""
);
int
total
=
pageStudioPersonalCoach
.
getInteger
(
"total"
);
Random
rand
=
new
Random
();
// 随机取两个教练
String
coachedId1
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
10
:
total
)).
getString
(
"id"
);
coachIds
.
add
(
coachedId1
);
String
coachedId2
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
10
:
total
)).
getString
(
"id"
);
if
(
coachedId1
.
equals
(
coachedId2
)){
coachedId2
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
9
:
total
-
1
)).
getString
(
"id"
);
}
coachIds
.
add
(
coachedId2
);
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
// 操作人id
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
JSONObject
specialTimeInfoRequest
=
new
JSONObject
();
// 可约时间类型
specialTimeInfoRequest
.
put
(
"dutyType"
,
"ON_DUTY"
);
// 设置特定日期
JSONArray
selectedDates
=
new
JSONArray
();
selectedDates
.
add
(
TimeUtils
.
getTodayTime
());
specialTimeInfoRequest
.
put
(
"selectedDates"
,
selectedDates
);
// 如果是可约时间非全天休息,则传可约时间段
// 时间段 00:00 ~ 23:59
JSONArray
timePeriodInfos
=
new
JSONArray
();
JSONObject
timeInfo
=
new
JSONObject
();
timeInfo
.
put
(
"minuteOffset"
,
0
);
timeInfo
.
put
(
"spanMinutes"
,
60
);
timePeriodInfos
.
add
(
timeInfo
);
specialTimeInfoRequest
.
put
(
"timePeriodInfos"
,
timePeriodInfos
);
body
.
put
(
"specialTimeInfoRequest"
,
specialTimeInfoRequest
);
body
.
put
(
"coachIds"
,
coachIds
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
// 批量设置特殊可约时间后检查个人私教时间是否有这条数据
for
(
int
j
=
0
;
j
<
coachIds
.
size
();
j
++){
JSONArray
specialTimeVOS
=
reserveTools
.
getPersonalCoachTime
(
coachIds
.
getString
(
j
),
"specialTimeVOS"
);
boolean
flag
=
false
;
for
(
int
i
=
0
;
i
<
specialTimeVOS
.
size
();
i
++)
{
JSONObject
specialTimeVO
=
specialTimeVOS
.
getJSONObject
(
i
);
if
(
selectedDates
.
getString
(
0
).
equals
(
specialTimeVO
.
getString
(
"dutyDate"
)))
{
flag
=
true
;
// 查询可约类型: 全天休息 -1, 可约时间 1,
Assert
.
assertEquals
(
specialTimeVO
.
getString
(
"dutyType"
),
"1"
,
"特殊日期类型错误"
);
// 查询这条数据的可约时间
Assert
.
assertTrue
(
specialTimeVO
.
getString
(
"timePeriodInfos"
).
equals
(
timePeriodInfos
.
toString
()),
"特殊日期可约时间段"
);
}
}
Assert
.
assertTrue
(
flag
,
"批量设置特殊日期后没有找到相关数据"
);
}
}
@Test
(
description
=
"设置特定日期全天休息"
,
priority
=
1
)
public
void
testCreateBatchSpecialDate2
()
{
// 获取教练列表
JSONObject
pageStudioPersonalCoach
=
reserveTools
.
pageStudioPersonalCoach
(
""
);
int
total
=
pageStudioPersonalCoach
.
getInteger
(
"total"
);
Random
rand
=
new
Random
();
// 随机取两个教练
String
coachedId1
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
10
:
total
)).
getString
(
"id"
);
coachIds
.
add
(
coachedId1
);
String
coachedId2
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
10
:
total
)).
getString
(
"id"
);
if
(
coachedId1
.
equals
(
coachedId2
)){
coachedId2
=
pageStudioPersonalCoach
.
getJSONArray
(
"records"
).
getJSONObject
(
rand
.
nextInt
(
total
>
10
?
9
:
total
-
1
)).
getString
(
"id"
);
}
coachIds
.
add
(
coachedId2
);
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
// 操作人id
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
JSONObject
specialTimeInfoRequest
=
new
JSONObject
();
// 可约时间类型
specialTimeInfoRequest
.
put
(
"dutyType"
,
"OFF_DUTY"
);
// 设置特定日期
JSONArray
selectedDates
=
new
JSONArray
();
selectedDates
.
add
(
TimeUtils
.
getBeforeDayDate
(-
1
));
// 第二天
specialTimeInfoRequest
.
put
(
"selectedDates"
,
selectedDates
);
body
.
put
(
"specialTimeInfoRequest"
,
specialTimeInfoRequest
);
body
.
put
(
"coachIds"
,
coachIds
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
// 批量设置特殊可约时间后检查个人私教时间是否有这条数据
for
(
int
j
=
0
;
j
<
coachIds
.
size
();
j
++){
JSONArray
specialTimeVOS
=
reserveTools
.
getPersonalCoachTime
(
coachIds
.
getString
(
j
),
"specialTimeVOS"
);
boolean
flag
=
false
;
for
(
int
i
=
0
;
i
<
specialTimeVOS
.
size
();
i
++){
JSONObject
specialTimeVO
=
specialTimeVOS
.
getJSONObject
(
i
);
if
(
selectedDates
.
getString
(
0
).
equals
(
specialTimeVO
.
getString
(
"dutyDate"
))){
flag
=
true
;
// 查询可约类型: 全天休息 -1, 可约时间 1,
Assert
.
assertEquals
(
specialTimeVO
.
getString
(
"dutyType"
),
"-1"
,
"特殊日期类型错误"
);
}
}
Assert
.
assertTrue
(
flag
,
"设置特殊日期全天休息后没有找到相关数据"
);
}
}
@Test
(
description
=
"删除特殊日期"
,
priority
=
2
)
public
void
testDeleteSpecialDate
()
{
for
(
int
j
=
0
;
j
<
coachIds
.
size
();
j
++){
// 查询特殊可约时间列表
JSONArray
specialTimeVOS
=
reserveTools
.
getPersonalCoachTime
(
coachIds
.
getString
(
j
),
"specialTimeVOS"
);
for
(
int
i
=
0
;
i
<
specialTimeVOS
.
size
();
i
++){
String
id
=
specialTimeVOS
.
getJSONObject
(
i
).
getJSONArray
(
"recordIds"
).
getString
(
0
);
// 删除查询到的特殊可约时间
reserveTools
.
deleteSpecialDate
(
id
);
}
specialTimeVOS
=
reserveTools
.
getPersonalCoachTime
(
xmAppApi
.
getLoginInfo
().
getAdminId
(),
"specialTimeVOS"
);
Assert
.
assertEquals
(
specialTimeVOS
.
size
(),
0
,
"删除特殊日期后,特殊日期列表不为空"
);
}
}
}
src/main/java/com/xiaomai/cases/polar/reserve/personal/TestCreateSpecialDate.java
View file @
42613838
...
...
@@ -51,7 +51,7 @@ public class TestCreateSpecialDate extends BaseTestImpl {
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
25
00
);
Thread
.
sleep
(
50
00
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
@@ -71,11 +71,6 @@ public class TestCreateSpecialDate extends BaseTestImpl {
@Test
(
description
=
"设置特定日期可约"
,
priority
=
1
)
public
void
testCreateSpecialDate_ON
()
{
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
JSONObject
specialTimeInfoRequest
=
new
JSONObject
();
// 可约时间类型
specialTimeInfoRequest
.
put
(
"dutyType"
,
"ON_DUTY"
);
...
...
src/main/java/com/xiaomai/cases/polar/reserve/personal/TestModifySpecialDate.java
0 → 100644
View file @
42613838
package
com
.
xiaomai
.
cases
.
polar
.
reserve
.
personal
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.reserve.ReserveTools
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
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
;
/**
* @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.reserve.personal
* @Author: xuyamei
* @CreateTime: 2024-07-24 10:05
* @Description: 修改特定可约时间
* @Version: 1.0
*/
public
class
TestModifySpecialDate
extends
BaseTestImpl
{
@Resource
(
name
=
"reserveTools"
)
ReserveTools
reserveTools
;
private
String
id
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Reserve
,
"API_modifySpecialDate"
,
LoginAccount
.
GYM_PROD
,
Terminal
.
B
,
"xym"
);
super
.
beforeTest
();
}
@Test
public
void
testModifySpecialDate
(){
Long
date
=
TimeUtils
.
getTodayTime
();
// 先创建特殊可约时间,当天可休息
reserveTools
.
createSpecialDate
(
xmAppApi
.
getLoginInfo
().
getAdminId
(),
"OFF_DUTY"
,
new
JSONObject
());
// 可约时间段
JSONArray
timePeriodInfos
=
new
JSONArray
();
JSONObject
timePeriodInfo
=
new
JSONObject
();
timePeriodInfo
.
put
(
"minuteOffset"
,
0
);
timePeriodInfo
.
put
(
"spanMinutes"
,
720
);
timePeriodInfos
.
add
(
timePeriodInfo
);
// 修改特殊可约时间
reserveTools
.
modifySpecialDate
(
xmAppApi
.
getLoginInfo
().
getAdminId
(),
"ON_DUTY"
,
timePeriodInfos
,
date
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
// 修改特殊可约时间后检查个人私教时间
JSONArray
specialTimeVOS
=
reserveTools
.
getPersonalCoachTime
(
xmAppApi
.
getLoginInfo
().
getAdminId
(),
"specialTimeVOS"
);
boolean
flag
=
false
;
for
(
int
i
=
0
;
i
<
specialTimeVOS
.
size
();
i
++){
JSONObject
specialTimeVO
=
specialTimeVOS
.
getJSONObject
(
i
);
if
(
date
.
toString
().
equals
(
specialTimeVO
.
getString
(
"dutyDate"
))){
flag
=
true
;
id
=
specialTimeVO
.
getJSONArray
(
"recordIds"
).
getString
(
0
);
Assert
.
assertEquals
(
specialTimeVO
.
getString
(
"dutyType"
),
"1"
,
"修改特殊日期类型后查询到全天休息"
);
Assert
.
assertTrue
(
specialTimeVO
.
getString
(
"timePeriodInfos"
).
equals
(
timePeriodInfos
.
toString
()),
"修改特殊日期可约时间段与查询到的数据不一致"
);
}
}
Assert
.
assertTrue
(
flag
,
"特殊日期不存在"
);
}
@Test
(
description
=
"清除数据"
,
priority
=
1
)
public
void
del
(){
reserveTools
.
deleteSpecialDate
(
id
);
}
}
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