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
079e6625
Commit
079e6625
authored
Jul 13, 2024
by
DuJunLi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑训练营排课课次,删除训练营排课课次,优化代码
parent
0bf67329
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
473 additions
and
34 deletions
+473
-34
src/main/java/com/xiaomai/cases/polar/schedule/camp/CampScheduleTools.java
+4
-1
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestCreateCampRuleSchedule.java
+2
-6
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestDelCampScheduleItem.java
+123
-0
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestEditCampRuleSchedule.java
+0
-3
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestEditCampScheduleItem.java
+272
-0
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestGetCampScheduleItemDetail.java
+0
-3
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestGetCampScheduleTable.java
+1
-5
src/main/java/com/xiaomai/cases/polar/schedule/group/TestEditGroupSchedule.java
+4
-16
src/main/java/com/xiaomai/utils/CommUtil.java
+67
-0
No files found.
src/main/java/com/xiaomai/cases/polar/schedule/camp/CampScheduleTools.java
View file @
079e6625
...
...
@@ -275,9 +275,11 @@ public class CampScheduleTools extends XMBaseTest {
}
return
null
;
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestCreateCampRuleSchedule.java
View file @
079e6625
...
...
@@ -37,7 +37,6 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
@Test
(
description
=
"创建训练营排课日程"
)
public
void
testCreateCampRuleSchedule
()
{
System
.
out
.
println
(
"*********************"
+
campInfo
);
//从训练营活动中获取教练信息
String
chiefCoachId
=
super
.
chiefCoachId
;
...
...
@@ -47,7 +46,7 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
//获取存量场地
List
<
String
>
venueAreaIds
=
groupScheduleTools
.
getStockArea
(
"流星花园秘密基地"
);
String
campId
=
super
.
campId
;
//创建训练营排课
//创建训练营排课
:按日期
campScheduleTools
.
createCampRuleSchedule
(
campId
,
assistCoachIds
,
chiefCoachId
,
super
.
courseId
,
super
.
traineeLowerLimit
,
super
.
traineeUpperLimit
,
"1020"
,
super
.
openStartDate
,
super
.
openEndDate
,
true
,
...
...
@@ -61,10 +60,7 @@ public class TestCreateCampRuleSchedule extends SelectTargetTrainingCampAndGetIn
@AfterClass
(
description
=
"删除此case创建的训练营排课日程和训练营活动"
)
public
void
delData
()
{
if
(
null
!=
ruldId
||!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
}
//直接删除训练营会的,对应的排课日程会被自动删除,校验其他case中已有
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
...
...
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestDelCampScheduleItem.java
0 → 100644
View file @
079e6625
package
com
.
xiaomai
.
cases
.
polar
.
schedule
.
camp
;
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.CommUtil
;
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.Arrays
;
import
java.util.List
;
import
java.util.Set
;
/**
* 删除训练营课次(单个/当前及后续)
* @author adu
* data 2024/7/12 17:05
*/
public
class
TestDelCampScheduleItem
extends
SelectTargetTrainingCampAndGetInfo
{
@Resource
(
name
=
"campScheduleTools"
)
CampScheduleTools
campScheduleTools
;
String
campId
=
""
;
String
chiefCoachId
=
""
;
String
ruldId
=
""
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Schedule
,
"API_delCampScheduleItem"
,
LoginAccount
.
ADU_PROD
,
Terminal
.
B
,
"adu"
);
super
.
beforeTest
();
// 获取选择的训练营ID
campId
=
super
.
campId
;
//1.2获取训练营活动的指定教练ID
chiefCoachId
=
super
.
chiefCoachId
;
//获取目标时间段内 最大有效课时数
String
[]
weekDaysArray
=
{
"TUESDAY"
,
"THURSDAY"
,
"SATURDAY"
,
"SUNDAY"
};
List
<
String
>
weekdaysList
=
Arrays
.
asList
(
weekDaysArray
);
int
loopNum
=
campScheduleTools
.
queryExpectedLoopNum
(
CommUtil
.
oneKeyGetAddDay
(
3
),
super
.
openEndDate
,
weekdaysList
);
//创建训练营排课:按次数 星期:2,4,6,7
campScheduleTools
.
oneKeyCreateCampRuleSchedule
(
campId
,
chiefCoachId
,
super
.
courseId
,
super
.
traineeLowerLimit
,
super
.
traineeUpperLimit
,
"1140"
,
super
.
openEndDate
,
true
,
String
.
valueOf
(
loopNum
));
//查询排课日程:根据训练营和关联课程查询
campScheduleTools
.
getCampRuleScheduleList
(
campId
,
super
.
courseId
,
""
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
==
1
,
"排课创建成功后,日程中没查询到对应数据"
);
ruldId
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
getJSONObject
(
0
).
getString
(
"ruleId"
);
}
@Test
(
description
=
"删除当前课次"
)
public
void
testDelCurrentCampScheduleItem
(){
//获取下周日课次ID
Set
<
String
>
scheduleIds7
=
campScheduleTools
.
getCampTableDate
(
13
);
if
(
scheduleIds7
.
size
()
!=
0
&&
scheduleIds7
!=
null
){
//删除下周日所有的课次
scheduleIds7
.
stream
().
forEach
(
scheduleId
->
{
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"applyRestRule"
,
false
);
body
.
put
(
"scheduleId"
,
scheduleId
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
});
//删除成功后check 下周日课表是否有数据
String
startDate
=
CommUtil
.
oneKeyGetNextWeekXDay
(
13
);
//下周日00点时间
String
endDate
=
CommUtil
.
oneKeyGetNextWeekEndXDay
(
7
);
//下周日23:59
campScheduleTools
.
getCampScheduleTable
(
startDate
,
endDate
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.totalCount"
),
"0"
);
}
}
@Test
(
description
=
"删除当前及后续课次"
,
priority
=
1
)
public
void
testDelCurrentAndSubsequentCampSchedule
()
{
//获取下周六课次ID
Set
<
String
>
scheduleIds6
=
campScheduleTools
.
getCampTableDate
(
12
);
if
(
scheduleIds6
.
size
()
!=
0
&&
scheduleIds6
!=
null
){
//删除下周日所有的课次
scheduleIds6
.
stream
().
forEach
(
scheduleId
->
{
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"applyRestRule"
,
true
);
body
.
put
(
"scheduleId"
,
scheduleId
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
});
//删除成功后check从下周六到排课结束日期课表是否有数据
String
startDate
=
CommUtil
.
oneKeyGetNextWeekXDay
(
12
);
//下周六00点时间
campScheduleTools
.
getCampScheduleTable
(
startDate
,
super
.
openEndDate
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.totalCount"
),
"0"
);
}
}
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
public
void
delData
()
{
//先删除规则,再操作删除对应的训练营活动,此处顺序不能换,如果先删除训练营活动,对应的排课会自动删除,所以就不用删除排课日程了,这个场景其他case中会体现
if
(
null
!=
ruldId
||!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
//删除日程后check 日程列表数据是否还能搜索到,期望搜索结果数据为空
campScheduleTools
.
getCampRuleScheduleList
(
campId
,
super
.
courseId
,
""
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
==
0
,
"日程被删除后,对应的排课日程列表还可以查到相关数据"
);
}
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestEditCampRuleSchedule.java
View file @
079e6625
...
...
@@ -103,9 +103,6 @@ public class TestEditCampRuleSchedule extends SelectTargetTrainingCampAndGetInfo
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
public
void
delData
()
{
if
(
null
!=
ruldId
||!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
}
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
...
...
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestEditCampScheduleItem.java
0 → 100644
View file @
079e6625
package
com
.
xiaomai
.
cases
.
polar
.
schedule
.
camp
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.cases.polar.schedule.group.GroupScheduleTools
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.CommUtil
;
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.*
;
import
java.util.stream.Collectors
;
/**
* 编辑训练营课次(单个/后续课次)
*
* @author adu
* data 2024/7/12 17:08
*/
public
class
TestEditCampScheduleItem
extends
SelectTargetTrainingCampAndGetInfo
{
public
static
Date
now
=
new
Date
();
Set
<
String
>
scheduleIdsN
;
@Resource
(
name
=
"groupScheduleTools"
)
GroupScheduleTools
groupScheduleTools
;
@Resource
(
name
=
"campScheduleTools"
)
CampScheduleTools
campScheduleTools
;
String
campId
=
""
;
String
chiefCoachId
=
""
;
String
ruldId
=
""
;
String
newRuldId
=
""
;
//获取下周日某个时间点的开始时间戳
String
startStamp
=
CommUtil
.
getWholeHourTimeStamp
(
13
,
"13:30"
);
public
String
sDateBefore
;
public
String
eDateBefore
=
""
;
public
int
scheduleClassHourEditBefore
=
0
;
public
int
scheduleClassHourEditAfter
=
0
;
public
List
<
String
>
venueAreaIdsEditAfter
;
public
Boolean
flag
;
@BeforeClass
public
void
beforeTest
()
{
setTestInfo
(
ApiModule
.
Polar_Schedule
,
"API_editCampSchedule"
,
LoginAccount
.
ADU_PROD
,
Terminal
.
B
,
"adu"
);
super
.
beforeTest
();
// 获取选择的训练营ID
campId
=
super
.
campId
;
//1.2获取训练营活动的指定教练ID
chiefCoachId
=
super
.
chiefCoachId
;
//获取目标时间段内 最大有效课时数
String
[]
weekDaysArray
=
{
"TUESDAY"
,
"THURSDAY"
,
"SATURDAY"
,
"SUNDAY"
};
List
<
String
>
weekdaysList
=
Arrays
.
asList
(
weekDaysArray
);
int
loopNum
=
campScheduleTools
.
queryExpectedLoopNum
(
CommUtil
.
oneKeyGetAddDay
(
3
),
super
.
openEndDate
,
weekdaysList
);
//创建训练营排课:按次数 星期:2,4,6,7
campScheduleTools
.
oneKeyCreateCampRuleSchedule
(
campId
,
chiefCoachId
,
super
.
courseId
,
super
.
traineeLowerLimit
,
super
.
traineeUpperLimit
,
"1140"
,
super
.
openEndDate
,
true
,
String
.
valueOf
(
loopNum
));
//查询排课日程:根据训练营和关联课程查询
campScheduleTools
.
getCampRuleScheduleList
(
campId
,
super
.
courseId
,
""
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
==
1
,
"排课创建成功后,日程中没查询到对应数据"
);
ruldId
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
getJSONObject
(
0
).
getString
(
"ruleId"
);
scheduleClassHourEditBefore
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
getJSONObject
(
0
).
getJSONObject
(
"campVO"
).
getIntValue
(
"scheduleClassHour"
);
}
@Test
(
description
=
"编辑当前课次"
)
public
void
testEditCurrentCampSchedule
()
{
//获取下周日课次ID
scheduleIdsN
=
campScheduleTools
.
getCampTableDate
(
13
);
if
(
scheduleIdsN
.
size
()
!=
0
&&
scheduleIdsN
!=
null
)
{
scheduleIdsN
.
stream
().
forEach
(
scheduleId
->
{
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"applyRestRule"
,
false
);
body
.
put
(
"scheduleId"
,
scheduleId
);
body
.
put
(
"startTime"
,
startStamp
);
//修改上课时间
body
.
put
(
"chiefCoachId"
,
chiefCoachId
);
body
.
put
(
"minMemberNum"
,
super
.
traineeLowerLimit
);
body
.
put
(
"maxMemberNum"
,
super
.
traineeUpperLimit
);
body
.
put
(
"venueAreaIds"
,
new
ArrayList
<>());
body
.
put
(
"assistCoachIds"
,
super
.
assistCoachIds
);
//有空改为有数据2个教练
body
.
put
(
"spanMinutes"
,
50
);
body
.
put
(
"force"
,
true
);
//有冲突时忽略冲突
body
.
put
(
"retainBooking"
,
true
);
//保留学员预约
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//编辑成功后check对应课次详情修改内容是否同步成功
campScheduleTools
.
getCampScheduleItemDetail
(
scheduleId
);
String
detailResult
=
dataApi
.
getApi_response
();
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.chiefCoachId"
),
chiefCoachId
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.startTime"
),
startStamp
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
detailResult
,
"$.result.assistCoachIds"
).
size
()
==
2
,
"助教修改后添加2个教练没生效"
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
detailResult
,
"$.result.venueAreaIds"
).
size
()
==
0
,
"课次创建时场地为空,查看课次详情不为空"
);
});
}
}
@Test
(
description
=
"编辑当前及后续课次"
,
priority
=
1
)
public
void
testEditCurrentAndSubsequentSchedule
()
{
//获取存量场地
List
<
String
>
venueAreaIds
=
groupScheduleTools
.
getStockArea
(
"流星花园秘密基地"
);
//获取下下周二的课次ID
//获取下下周二的开始时间和结束时间
String
targetStartDate
=
CommUtil
.
getXStartOfDateNextXWeek
(
1
,
2
);
String
targetendDate
=
CommUtil
.
getXEndOfDateNextXWeek
(-
5
,
2
);
Set
<
String
>
scheduleId22
;
campScheduleTools
.
getCampScheduleTable
(
targetStartDate
,
targetendDate
);
int
count
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result.timetableGroups"
).
size
();
if
(
count
>
0
)
{
JSONArray
array
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result.timetableGroups"
);
scheduleId22
=
array
.
toJavaList
(
JSONObject
.
class
).
stream
()
.
flatMap
(
e
->
e
.
getJSONArray
(
"timetableList"
).
toJavaList
(
JSONObject
.
class
).
stream
())
//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.
map
(
e
->
e
.
getString
(
"scheduleId"
))
//获取scheduleId
.
collect
(
Collectors
.
toSet
());
if
(
scheduleId22
.
size
()
!=
0
&&
scheduleId22
!=
null
)
{
scheduleId22
.
stream
().
forEach
(
scheduleId
->
{
//删除下下周二的课次
campScheduleTools
.
delCampScheduleItem
(
scheduleId
,
false
);
});
}
}
//获取下周六的课次ID
Set
<
String
>
scheduleIds6
=
campScheduleTools
.
getCampTableDate
(
12
);
if
(
scheduleIds6
.
size
()
!=
0
&&
scheduleIds6
!=
null
)
{
scheduleIds6
.
stream
().
forEach
(
scheduleId
->
{
//编辑下周六及后续课次
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
body
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
body
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
body
.
put
(
"applyRestRule"
,
true
);
body
.
put
(
"scheduleId"
,
scheduleId
);
//获取下周六某个时间点的开始时间戳
String
startStamp
=
CommUtil
.
getWholeHourTimeStamp
(
12
,
"19:00"
);
body
.
put
(
"startTime"
,
startStamp
);
//上课时间不做修改
body
.
put
(
"chiefCoachId"
,
chiefCoachId
);
body
.
put
(
"minMemberNum"
,
super
.
traineeLowerLimit
);
body
.
put
(
"maxMemberNum"
,
super
.
traineeUpperLimit
);
body
.
put
(
"venueAreaIds"
,
venueAreaIds
);
//场地有空改为有数据
body
.
put
(
"assistCoachIds"
,
new
ArrayList
<>());
body
.
put
(
"spanMinutes"
,
50
);
body
.
put
(
"force"
,
true
);
//有冲突时忽略冲突
body
.
put
(
"retainBooking"
,
true
);
//保留学员预约
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
body
.
toString
(),
headers
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//check当前课次信息是否被同步修改
campScheduleTools
.
getCampScheduleItemDetail
(
scheduleId
);
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.startTime"
),
startStamp
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result.venueAreaIds"
).
containsAll
(
venueAreaIds
),
"场地有空改为有数据,但是课次详情中显示不正确哦"
);
});
}
//后续检查点check
//1.查询排课日程:根据训练营查询,应该对应训练营可以查到2条数据,原日程和修改后生成的日程
campScheduleTools
.
getCampRuleScheduleList
(
campId
,
""
,
""
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
==
2
,
"编辑当前及后续课次成功后,日程中没查询到2条对应数据"
);
//1.1获取到新生成的排课日程ID
//过滤出刚创建的课次
JSONArray
array
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
);
newRuldId
=
array
.
toJavaList
(
JSONObject
.
class
).
stream
()
.
filter
(
e
->
!
e
.
getString
(
"ruleId"
).
equals
(
ruldId
))
//过滤出新规则
.
map
(
e
->
e
.
getString
(
"ruleId"
))
//获取新规则ID
.
findFirst
().
orElse
(
null
);
//1.2查看新规则
array
.
toJavaList
(
JSONObject
.
class
).
stream
().
forEach
(
obj
->{
if
(
newRuldId
.
equals
(
obj
.
getString
(
"ruleId"
))){
sDateBefore
=
obj
.
getString
(
"startDate"
);
eDateBefore
=
obj
.
getString
(
"endDate"
);
scheduleClassHourEditAfter
=
Integer
.
parseInt
(
obj
.
getJSONObject
(
"campVO"
).
getString
(
"scheduleClassHour"
));
flag
=
obj
.
getJSONArray
(
"venueAreaIds"
).
containsAll
(
venueAreaIds
);
}
});
Assert
.
assertTrue
(
flag
==
true
,
"新规则的场地数据为空了"
);
Assert
.
assertTrue
(
scheduleClassHourEditBefore
+
1
==
scheduleClassHourEditAfter
,
"编辑当前及后续课次后,训练营已排课次数+1(独立出去的课次 又生成新的一个课次;之前删除的课次,也生成新的课次了)"
);
Assert
.
assertEquals
(
sDateBefore
,
CommUtil
.
getXStartOfDateNextXWeek
(
5
,
1
),
"新规则的开始日期不对,应该是下周六的时间"
);
Assert
.
assertEquals
(
eDateBefore
.
substring
(
0
,
9
),
super
.
openEndDate
.
substring
(
0
,
9
),
"新规则的结束日期不对"
);
//2.断言check:获取下周四的课次,check是否还是原来的数据(不会受到影响)
Set
<
String
>
scheduleIds4
=
campScheduleTools
.
getCampTableDate
(
10
);
if
(
scheduleIds4
.
size
()
!=
0
&&
scheduleIds4
!=
null
)
{
scheduleIds4
.
stream
().
forEach
(
scheduleId
->
{
campScheduleTools
.
getCampScheduleItemDetail
(
scheduleId
);
String
detailResult
=
dataApi
.
getApi_response
();
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
detailResult
,
"$.result.assistCoachIds"
).
size
()
==
0
,
"课次创建时助教为空,查看课次详情不为空"
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
detailResult
,
"$.result.venueAreaIds"
).
size
()
==
0
,
"课次创建时场地为空,查看课次详情不为空"
);
});
}
// 3.check下周日的课次(以独立出去的课次是否受到影响:不受影响)
if
(
scheduleIdsN
.
size
()
!=
0
&&
scheduleIdsN
!=
null
)
{
scheduleIdsN
.
stream
().
forEach
(
scheduleId
->
{
campScheduleTools
.
getCampScheduleItemDetail
(
scheduleId
);
String
detailResult
=
dataApi
.
getApi_response
();
Assert
.
assertEquals
(
XMJSONPath
.
readPath
(
detailResult
,
"$.result.startTime"
),
startStamp
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
detailResult
,
"$.result.assistCoachIds"
).
size
()
==
2
,
"助教修改后添加2个教练没生效"
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
detailResult
,
"$.result.venueAreaIds"
).
size
()
==
0
,
"课次创建时为空,查看课次详情不为空"
);
});
}
//4.check 下周日是否又生成一条新的课次
Set
<
String
>
scheduleIds77
=
campScheduleTools
.
getCampTableDate
(
13
);
Assert
.
assertTrue
(
scheduleIds77
.
size
()==(
scheduleIdsN
.
size
()+
1
));
scheduleIds77
.
removeAll
(
scheduleIdsN
);
// System.out.println(JSON.toJSONString(scheduleIds77));
if
(
scheduleIds77
.
size
()
!=
0
&&
scheduleIds77
!=
null
)
{
scheduleIds77
.
stream
().
forEach
(
scheduleId
->
{
campScheduleTools
.
getCampScheduleItemDetail
(
scheduleId
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result.venueAreaIds"
).
containsAll
(
venueAreaIds
),
"场地有空改为有数据,但是课次详情中显示不正确哦"
);
});
}
//5.check 下下周二是否生成一条新的课次
campScheduleTools
.
getCampScheduleTable
(
targetStartDate
,
targetendDate
);
Assert
.
assertTrue
(
Integer
.
valueOf
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.totalCount"
))==
1
,
"课次被删除后,编辑当前及后续,后续删除的课次没重新生成新的课次"
);
}
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
public
void
delData
()
{
/* if (null != ruldId || !ruldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(ruldId);
}
if (null != newRuldId || !newRuldId.isEmpty()) {
campScheduleTools.delCampRuleSchedule(newRuldId);
}*/
if
(
null
!=
campId
||
!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
//训练营被删除后,对应的排课日程会被自动删除check
campScheduleTools
.
getCampRuleScheduleList
(
campId
,
""
,
""
);
Assert
.
assertTrue
(
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
()
==
0
,
"训练营被删除后,对应的排课日程会被自动删除,目前还有相关数据请检查"
);
}
}
}
\ No newline at end of file
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestGetCampScheduleItemDetail.java
View file @
079e6625
...
...
@@ -90,9 +90,6 @@ public class TestGetCampScheduleItemDetail extends SelectTargetTrainingCampAndGe
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
public
void
delData
()
{
if
(
null
!=
ruldId
||
!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
}
if
(
null
!=
campId
||
!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
...
...
src/main/java/com/xiaomai/cases/polar/schedule/camp/TestGetCampScheduleTable.java
View file @
079e6625
...
...
@@ -17,7 +17,6 @@ import org.testng.annotations.Test;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 测试获取训练营排课课表
...
...
@@ -113,11 +112,8 @@ public class TestGetCampScheduleTable extends SelectTargetTrainingCampAndGetInfo
Assert
.
assertTrue
(
resultCount
>=
total
,
"查询到的课表数据和预期不一致"
);
}
@AfterClass
(
description
=
"删除此case创建的训练营排课日程"
)
@AfterClass
(
description
=
"删除此case创建的训练营排课日程
,只操作删除对应的训练营活动即可
"
)
public
void
delData
()
{
if
(
null
!=
ruldId
||!
ruldId
.
isEmpty
())
{
campScheduleTools
.
delCampRuleSchedule
(
ruldId
);
}
if
(
null
!=
campId
||!
campId
.
isEmpty
())
{
this
.
getTrainingTools
().
deleteTraining
(
campId
);
}
...
...
src/main/java/com/xiaomai/cases/polar/schedule/group/TestEditGroupSchedule.java
View file @
079e6625
...
...
@@ -52,7 +52,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
body
.
put
(
"applyRestRule"
,
false
);
body
.
put
(
"scheduleId"
,
scheduleId
);
//获取下周四某个时间点的开始时间戳
String
startStamp
=
getWholeHourTimeStamp
(
10
,
"13:30"
);
String
startStamp
=
CommUtil
.
getWholeHourTimeStamp
(
10
,
"13:30"
);
body
.
put
(
"startTime"
,
startStamp
);
body
.
put
(
"chiefCoachId"
,
chiefCoachIdS
);
...
...
@@ -100,7 +100,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
body
.
put
(
"applyRestRule"
,
true
);
//改的时日程当前及后续
body
.
put
(
"scheduleId"
,
scheduleId
);
//获取下周二某个时间点的开始时间戳
String
startStamp1
=
getWholeHourTimeStamp
(
8
,
"13:00"
);
String
startStamp1
=
CommUtil
.
getWholeHourTimeStamp
(
8
,
"13:00"
);
body
.
put
(
"startTime"
,
startStamp1
);
body
.
put
(
"chiefCoachId"
,
chiefCoachIdS
);
...
...
@@ -123,7 +123,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
//查看下周三课次是否同步被修改
Set
<
String
>
scheduleIdX
=
groupScheduleTools
.
getTableDate
(
9
);
String
startStamp2
=
getWholeHourTimeStamp
(
9
,
"13:00"
);
String
startStamp2
=
CommUtil
.
getWholeHourTimeStamp
(
9
,
"13:00"
);
if
(!
scheduleIdX
.
isEmpty
())
{
scheduleIdX
.
stream
().
forEach
(
scheduleId1
->
{
//编辑成功后check同规则中下周三课次详情修改内容是否同步成功
...
...
@@ -136,7 +136,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
}
//获取下周一的课次ID,查看下周一课次是否还是原来的(没被修改,还是原来的规则)
Set
<
String
>
scheduleId1
=
groupScheduleTools
.
getTableDate
(
7
);
String
startStamp3
=
getWholeHourTimeStamp
(
7
,
"13:00"
);
String
startStamp3
=
CommUtil
.
getWholeHourTimeStamp
(
7
,
"13:00"
);
if
(!
scheduleId1
.
isEmpty
())
{
scheduleId1
.
stream
().
forEach
(
scheduleId0
->
{
//编辑成功后check同规则中下周一课次详情
...
...
@@ -158,19 +158,7 @@ public class TestEditGroupSchedule extends UniversalDataScheduling {
}
/**
*
* @param n 整数
* @param time 整点时间 比如13:00
* @return
*/
public
String
getWholeHourTimeStamp
(
int
n
,
String
time
){
Date
getWeekStartDayData
=
CommUtil
.
getStartOfDateWeek
(
now
);
Date
getNextWeekXDayData
=
CommUtil
.
addNDays
(
getWeekStartDayData
,
n
);
String
getNextWeekXDayDataS
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
getNextWeekXDayData
.
getTime
());
return
CommUtil
.
getStringTimestampByStrTime
(
getNextWeekXDayDataS
+
" "
+
time
);
}
/**
* 编辑后通过查看课次详情check数据是否同步被修改
...
...
src/main/java/com/xiaomai/utils/CommUtil.java
View file @
079e6625
...
...
@@ -12,7 +12,10 @@ import java.lang.reflect.Method;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.DayOfWeek
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.temporal.TemporalAdjusters
;
import
java.util.*
;
public
class
CommUtil
{
...
...
@@ -214,6 +217,22 @@ public class CommUtil {
return
getStringTimestamp
(
getNextWeekStartDay
,
"yyyy-MM-dd HH:mm:ss"
);
}
/**
* 获取下下周的某一天的开始时间
* @param n,7是下下周一,8是下下周2
* @return
*/
public
static
String
oneKeyGetNextNextWeekXStartDay
(
int
n
){
Date
getWeekStartDayData
=
getStartOfDateWeek
(
now
);
//获取本周的第一天
Date
getNextWeekStartDayData
=
addNDays
(
getWeekStartDayData
,
7
);
//下周第一天
Date
getNextNextWeekStartDayData
=
addNDays
(
getNextWeekStartDayData
,
n
);
String
getNextNextWeekXStartDay
=
getFormatTimeStr
(
getNextNextWeekStartDayData
,
"yyyy-MM-dd HH:mm:ss"
);
//时间格式转化为string
return
getStringTimestamp
(
getNextNextWeekXStartDay
,
"yyyy-MM-dd HH:mm:ss"
);
}
public
static
Date
getEndOfDay
(
Date
date
)
{
assert
date
!=
null
;
return
new
DateTime
(
date
).
withTime
(
23
,
59
,
59
,
999
).
toDate
();
...
...
@@ -259,6 +278,20 @@ public class CommUtil {
return
wholeHourTimestamp
;
}
/**
*
* @param n 整数
* @param time 整点时间 比如13:00
* @return
*/
public
static
String
getWholeHourTimeStamp
(
int
n
,
String
time
){
Date
getWeekStartDayData
=
CommUtil
.
getStartOfDateWeek
(
now
);
Date
getNextWeekXDayData
=
CommUtil
.
addNDays
(
getWeekStartDayData
,
n
);
String
getNextWeekXDayDataS
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
getNextWeekXDayData
.
getTime
());
return
CommUtil
.
getStringTimestampByStrTime
(
getNextWeekXDayDataS
+
" "
+
time
);
}
public
static
String
getStringTimestampByStrTime
(
String
time
)
{
...
...
@@ -286,6 +319,34 @@ public class CommUtil {
}
/**
* 获取指定周的某一天的开始时间00,比如下周的第一天,下周的第二天
* @param day ,0就是周的第一天,1是周二,2是周三,3是周四,4是周五,5是周六,6是周日
* @param week 周为单位,1是当前周加1周即为下周,2就是下下周,0就是代表本周
* @return
*/
public
static
String
getXStartOfDateNextXWeek
(
int
day
,
int
week
)
{
Date
getNextXWeekStartDayData
=
new
DateTime
(
now
).
withDayOfWeek
(
1
).
plusWeeks
(
week
).
withTimeAtStartOfDay
().
toDate
();
Date
getNextXWeekStartXDayData
=
addNDays
(
getNextXWeekStartDayData
,
day
);
String
getNextXWeekStartXDayDataS
=
getFormatTimeStr
(
getNextXWeekStartXDayData
,
"yyyy-MM-dd HH:mm:ss"
);
//时间格式转化为string
return
getStringTimestamp
(
getNextXWeekStartXDayDataS
,
"yyyy-MM-dd HH:mm:ss"
);
}
/**
* 获取指定周的某一天的结束时间23:59,比如下周的最后一天天,下下周的第二天
* @param day 0表示某周的最后一天,-1表示某周的周六,-2周五,-3周四,-4周三,-5周二,-6周一
* @param week 周为单位,1是当前周加1周即为下周,2就是下下周,0就是代表本周
* @return
*/
public
static
String
getXEndOfDateNextXWeek
(
int
day
,
int
week
)
{
Date
getNextXWeekEndDayData
=
new
DateTime
(
now
).
withDayOfWeek
(
7
).
plusWeeks
(
2
).
withTime
(
23
,
59
,
59
,
0
).
toDate
();
Date
getNextXWeekEndXDayData
=
addNDays
(
getNextXWeekEndDayData
,
day
);
String
getNextXWeekEndXDayDataS
=
getFormatTimeStr
(
getNextXWeekEndXDayData
,
"yyyy-MM-dd HH:mm:ss"
);
//时间格式转化为string
return
getStringTimestamp
(
getNextXWeekEndXDayDataS
,
"yyyy-MM-dd HH:mm:ss"
);
}
public
static
void
main
(
String
[]
args
)
{
getWholeHourTimestamp
();
Date
getWeekStartDayData
=
getStartOfDateWeek
(
now
);
//获取本周的第一天
...
...
@@ -311,6 +372,12 @@ public class CommUtil {
LocalDateTime
future
=
now
.
plusSeconds
(
2
);
System
.
out
.
println
(
"未来2秒时间: "
+
future
);
System
.
out
.
println
(
"%%%%%"
+
getXEndOfDateNextXWeek
(-
1
,
2
));
}
...
...
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