|
|
@ -105,8 +105,8 @@ public class SchedulerServiceTest extends BaseServiceTestTool { |
|
|
|
private static final int processDefinitionVersion = 3; |
|
|
|
private static final int processDefinitionVersion = 3; |
|
|
|
private static final int scheduleId = 3; |
|
|
|
private static final int scheduleId = 3; |
|
|
|
private static final long environmentCode = 4L; |
|
|
|
private static final long environmentCode = 4L; |
|
|
|
private static final String startTime = "2220-01-01 12:13:14"; |
|
|
|
private static final String startTime = "2020-01-01 12:13:14"; |
|
|
|
private static final String endTime = "2220-02-01 12:13:14"; |
|
|
|
private static final String endTime = "2020-02-01 12:13:14"; |
|
|
|
private static final String crontab = "0 0 * * * ? *"; |
|
|
|
private static final String crontab = "0 0 * * * ? *"; |
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
@BeforeEach |
|
|
@ -175,8 +175,6 @@ public class SchedulerServiceTest extends BaseServiceTestTool { |
|
|
|
ScheduleCreateRequest scheduleCreateRequest = new ScheduleCreateRequest(); |
|
|
|
ScheduleCreateRequest scheduleCreateRequest = new ScheduleCreateRequest(); |
|
|
|
scheduleCreateRequest.setProcessDefinitionCode(processDefinitionCode); |
|
|
|
scheduleCreateRequest.setProcessDefinitionCode(processDefinitionCode); |
|
|
|
scheduleCreateRequest.setEnvironmentCode(environmentCode); |
|
|
|
scheduleCreateRequest.setEnvironmentCode(environmentCode); |
|
|
|
scheduleCreateRequest.setStartTime(startTime); |
|
|
|
|
|
|
|
scheduleCreateRequest.setEndTime(endTime); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// error process definition not exists
|
|
|
|
// error process definition not exists
|
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
@ -210,24 +208,16 @@ public class SchedulerServiceTest extends BaseServiceTestTool { |
|
|
|
Assertions.assertEquals(Status.QUERY_ENVIRONMENT_BY_CODE_ERROR.getCode(), |
|
|
|
Assertions.assertEquals(Status.QUERY_ENVIRONMENT_BY_CODE_ERROR.getCode(), |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// error schedule parameter start time before current time
|
|
|
|
|
|
|
|
String badStartTime = "2020-01-01 12:13:14"; |
|
|
|
|
|
|
|
scheduleCreateRequest.setStartTime(badStartTime); |
|
|
|
|
|
|
|
Mockito.when(environmentMapper.queryByEnvironmentCode(environmentCode)).thenReturn(this.getEnvironment()); |
|
|
|
|
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
|
|
|
|
() -> schedulerService.createSchedulesV2(user, scheduleCreateRequest)); |
|
|
|
|
|
|
|
Assertions.assertEquals(Status.START_TIME_BEFORE_CURRENT_TIME_ERROR.getCode(), |
|
|
|
|
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// error schedule parameter same start time and end time
|
|
|
|
// error schedule parameter same start time and end time
|
|
|
|
scheduleCreateRequest.setStartTime(endTime); |
|
|
|
Mockito.when(environmentMapper.queryByEnvironmentCode(environmentCode)).thenReturn(this.getEnvironment()); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> schedulerService.createSchedulesV2(user, scheduleCreateRequest)); |
|
|
|
() -> schedulerService.createSchedulesV2(user, scheduleCreateRequest)); |
|
|
|
Assertions.assertEquals(Status.SCHEDULE_START_TIME_END_TIME_SAME.getCode(), |
|
|
|
Assertions.assertEquals(Status.SCHEDULE_START_TIME_END_TIME_SAME.getCode(), |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// error schedule parameter start time after than end time
|
|
|
|
// error schedule parameter same start time after than end time
|
|
|
|
badStartTime = "2222-01-01 12:13:14"; |
|
|
|
scheduleCreateRequest.setEndTime(endTime); |
|
|
|
|
|
|
|
String badStartTime = "2022-01-01 12:13:14"; |
|
|
|
scheduleCreateRequest.setStartTime(badStartTime); |
|
|
|
scheduleCreateRequest.setStartTime(badStartTime); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> schedulerService.createSchedulesV2(user, scheduleCreateRequest)); |
|
|
|
() -> schedulerService.createSchedulesV2(user, scheduleCreateRequest)); |
|
|
@ -371,25 +361,17 @@ public class SchedulerServiceTest extends BaseServiceTestTool { |
|
|
|
() -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); |
|
|
|
() -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); |
|
|
|
Assertions.assertEquals(Status.SCHEDULE_NOT_EXISTS.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.SCHEDULE_NOT_EXISTS.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// error schedule parameter start time before current time
|
|
|
|
|
|
|
|
String badStartTime = "2020-01-01 12:13:14"; |
|
|
|
|
|
|
|
scheduleUpdateRequest.setStartTime(badStartTime); |
|
|
|
|
|
|
|
scheduleUpdateRequest.setEndTime(endTime); |
|
|
|
|
|
|
|
Mockito.when(scheduleMapper.selectById(scheduleId)).thenReturn(this.getSchedule()); |
|
|
|
|
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
|
|
|
|
() -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); |
|
|
|
|
|
|
|
Assertions.assertEquals(Status.START_TIME_BEFORE_CURRENT_TIME_ERROR.getCode(), |
|
|
|
|
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// error schedule parameter same start time and end time
|
|
|
|
// error schedule parameter same start time and end time
|
|
|
|
|
|
|
|
scheduleUpdateRequest.setEndTime(endTime); |
|
|
|
scheduleUpdateRequest.setStartTime(endTime); |
|
|
|
scheduleUpdateRequest.setStartTime(endTime); |
|
|
|
|
|
|
|
Mockito.when(scheduleMapper.selectById(scheduleId)).thenReturn(this.getSchedule()); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); |
|
|
|
() -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); |
|
|
|
Assertions.assertEquals(Status.SCHEDULE_START_TIME_END_TIME_SAME.getCode(), |
|
|
|
Assertions.assertEquals(Status.SCHEDULE_START_TIME_END_TIME_SAME.getCode(), |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// error schedule parameter start time after than end time
|
|
|
|
// error schedule parameter same start time after than end time
|
|
|
|
badStartTime = "2222-01-01 12:13:14"; |
|
|
|
String badStartTime = "2022-01-01 12:13:14"; |
|
|
|
scheduleUpdateRequest.setStartTime(badStartTime); |
|
|
|
scheduleUpdateRequest.setStartTime(badStartTime); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); |
|
|
|
() -> schedulerService.updateSchedulesV2(user, scheduleId, scheduleUpdateRequest)); |
|
|
|