|
|
@ -26,10 +26,7 @@ import org.apache.dolphinscheduler.common.enums.Priority; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.*; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
|
|
@ -140,8 +137,19 @@ public class TaskDefinitionServiceImplTest { |
|
|
|
Mockito.when(taskDefinitionLogMapper.insert(Mockito.any(TaskDefinitionLog.class))).thenReturn(1); |
|
|
|
Mockito.when(taskDefinitionLogMapper.insert(Mockito.any(TaskDefinitionLog.class))).thenReturn(1); |
|
|
|
Mockito.when(taskDefinitionLogMapper.queryMaxVersionForDefinition(taskCode)).thenReturn(1); |
|
|
|
Mockito.when(taskDefinitionLogMapper.queryMaxVersionForDefinition(taskCode)).thenReturn(1); |
|
|
|
Mockito.when(taskPluginManager.checkTaskParameters(Mockito.any())).thenReturn(true); |
|
|
|
Mockito.when(taskPluginManager.checkTaskParameters(Mockito.any())).thenReturn(true); |
|
|
|
result = taskDefinitionService.updateTaskDefinition(loginUser, projectCode, taskCode, taskDefinitionJson); |
|
|
|
Mockito.when(processTaskRelationMapper.queryByTaskCode(3)).thenReturn(getProcessTaskRelationList2()); |
|
|
|
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
|
|
|
Mockito.when(processTaskRelationMapper |
|
|
|
|
|
|
|
.updateProcessTaskRelationTaskVersion(Mockito.any(ProcessTaskRelation.class))).thenReturn(1); |
|
|
|
|
|
|
|
result = taskDefinitionService.updateTaskDefinition(user, PROJECT_CODE, TASK_CODE, taskDefinitionJson); |
|
|
|
|
|
|
|
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
|
|
|
|
|
|
|
// failure
|
|
|
|
|
|
|
|
Mockito.when(processTaskRelationMapper |
|
|
|
|
|
|
|
.updateProcessTaskRelationTaskVersion(Mockito.any(ProcessTaskRelation.class))).thenReturn(2); |
|
|
|
|
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
|
|
|
|
() -> taskDefinitionService.updateTaskDefinition(user, PROJECT_CODE, TASK_CODE, taskDefinitionJson)); |
|
|
|
|
|
|
|
Assertions.assertEquals(Status.PROCESS_TASK_RELATION_BATCH_UPDATE_ERROR.getCode(), |
|
|
|
|
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -336,4 +344,25 @@ public class TaskDefinitionServiceImplTest { |
|
|
|
Map<String, Object> failResult = taskDefinitionService.releaseTaskDefinition(loginUser, projectCode, taskCode, ReleaseState.getEnum(2)); |
|
|
|
Map<String, Object> failResult = taskDefinitionService.releaseTaskDefinition(loginUser, projectCode, taskCode, ReleaseState.getEnum(2)); |
|
|
|
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, failResult.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, failResult.get(Constants.STATUS)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<ProcessTaskRelation> getProcessTaskRelationList2() { |
|
|
|
|
|
|
|
List<ProcessTaskRelation> processTaskRelationList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessTaskRelation processTaskRelation = new ProcessTaskRelation(); |
|
|
|
|
|
|
|
processTaskRelation.setProjectCode(PROJECT_CODE); |
|
|
|
|
|
|
|
processTaskRelation.setProcessDefinitionCode(PROCESS_DEFINITION_CODE); |
|
|
|
|
|
|
|
processTaskRelation.setPreTaskCode(TASK_CODE); |
|
|
|
|
|
|
|
processTaskRelation.setPostTaskCode(TASK_CODE + 1L); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processTaskRelationList.add(processTaskRelation); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessTaskRelation processTaskRelation2 = new ProcessTaskRelation(); |
|
|
|
|
|
|
|
processTaskRelation2.setProjectCode(PROJECT_CODE); |
|
|
|
|
|
|
|
processTaskRelation2.setProcessDefinitionCode(PROCESS_DEFINITION_CODE); |
|
|
|
|
|
|
|
processTaskRelation2.setPreTaskCode(TASK_CODE - 1); |
|
|
|
|
|
|
|
processTaskRelation2.setPostTaskCode(TASK_CODE); |
|
|
|
|
|
|
|
processTaskRelationList.add(processTaskRelation2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return processTaskRelationList; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|