Browse Source

[Improvement][UT] Add UT for end time check when force success task (#15562)

3.2.2-prepare
Rick Cheng 11 months ago committed by GitHub
parent
commit
718a01bb42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java

4
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java

@ -343,7 +343,7 @@ public class TaskInstanceServiceTest {
} }
@Test @Test
public void forceTaskSuccess() { public void testForceTaskSuccess() {
User user = getAdminUser(); User user = getAdminUser();
long projectCode = 1L; long projectCode = 1L;
Project project = getProject(projectCode); Project project = getProject(projectCode);
@ -392,12 +392,14 @@ public class TaskInstanceServiceTest {
// test success // test success
task.setState(TaskExecutionStatus.FAILURE); task.setState(TaskExecutionStatus.FAILURE);
task.setEndTime(null);
when(taskInstanceMapper.updateById(task)).thenReturn(1); when(taskInstanceMapper.updateById(task)).thenReturn(1);
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(user, project, projectCode, FORCED_SUCCESS)).thenReturn(result); when(projectService.checkProjectAndAuth(user, project, projectCode, FORCED_SUCCESS)).thenReturn(result);
Result successRes = taskInstanceService.forceTaskSuccess(user, projectCode, taskId); Result successRes = taskInstanceService.forceTaskSuccess(user, projectCode, taskId);
Assertions.assertEquals(Status.SUCCESS.getCode(), successRes.getCode().intValue()); Assertions.assertEquals(Status.SUCCESS.getCode(), successRes.getCode().intValue());
Assertions.assertNotNull(task.getEndTime());
} }

Loading…
Cancel
Save