|
|
@ -28,7 +28,10 @@ import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationCon |
|
|
|
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_UPDATE; |
|
|
|
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_UPDATE; |
|
|
|
import static org.apache.dolphinscheduler.common.constants.Constants.EMPTY_STRING; |
|
|
|
import static org.apache.dolphinscheduler.common.constants.Constants.EMPTY_STRING; |
|
|
|
import static org.mockito.ArgumentMatchers.isA; |
|
|
|
import static org.mockito.ArgumentMatchers.isA; |
|
|
|
|
|
|
|
import static org.mockito.Mockito.doNothing; |
|
|
|
|
|
|
|
import static org.mockito.Mockito.doThrow; |
|
|
|
import static org.mockito.Mockito.times; |
|
|
|
import static org.mockito.Mockito.times; |
|
|
|
|
|
|
|
import static org.mockito.Mockito.when; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.api.dto.workflow.WorkflowCreateRequest; |
|
|
|
import org.apache.dolphinscheduler.api.dto.workflow.WorkflowCreateRequest; |
|
|
|
import org.apache.dolphinscheduler.api.dto.workflow.WorkflowFilterRequest; |
|
|
|
import org.apache.dolphinscheduler.api.dto.workflow.WorkflowFilterRequest; |
|
|
@ -212,7 +215,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryProcessDefinitionList() { |
|
|
|
public void testQueryProcessDefinitionList() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
@ -220,18 +223,18 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
|
|
|
|
|
|
|
|
// project not found
|
|
|
|
// project not found
|
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Map<String, Object> map = processDefinitionService.queryProcessDefinitionList(user, projectCode); |
|
|
|
Map<String, Object> map = processDefinitionService.queryProcessDefinitionList(user, projectCode); |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth success
|
|
|
|
// project check auth success
|
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
List<ProcessDefinition> resourceList = new ArrayList<>(); |
|
|
|
List<ProcessDefinition> resourceList = new ArrayList<>(); |
|
|
|
resourceList.add(getProcessDefinition()); |
|
|
|
resourceList.add(getProcessDefinition()); |
|
|
|
Mockito.when(processDefinitionMapper.queryAllDefinitionList(project.getCode())).thenReturn(resourceList); |
|
|
|
when(processDefinitionMapper.queryAllDefinitionList(project.getCode())).thenReturn(resourceList); |
|
|
|
Map<String, Object> checkSuccessRes = |
|
|
|
Map<String, Object> checkSuccessRes = |
|
|
|
processDefinitionService.queryProcessDefinitionList(user, projectCode); |
|
|
|
processDefinitionService.queryProcessDefinitionList(user, projectCode); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, checkSuccessRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, checkSuccessRes.get(Constants.STATUS)); |
|
|
@ -239,15 +242,11 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryProcessDefinitionListPaging() { |
|
|
|
public void testQueryProcessDefinitionListPaging() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// project not found
|
|
|
|
// project not found
|
|
|
|
try { |
|
|
|
try { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(null); |
|
|
|
doThrow(new ServiceException(Status.PROJECT_NOT_EXIST)).when(projectService) |
|
|
|
Mockito.doThrow(new ServiceException(Status.PROJECT_NOT_EXIST)).when(projectService) |
|
|
|
.checkProjectAndAuthThrowException(user, projectCode, WORKFLOW_DEFINITION); |
|
|
|
.checkProjectAndAuthThrowException(user, null, WORKFLOW_DEFINITION); |
|
|
|
|
|
|
|
processDefinitionService.queryProcessDefinitionListPaging(user, projectCode, "", "", 1, 5, 0); |
|
|
|
processDefinitionService.queryProcessDefinitionListPaging(user, projectCode, "", "", 1, 5, 0); |
|
|
|
} catch (ServiceException serviceException) { |
|
|
|
} catch (ServiceException serviceException) { |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_EXIST.getCode(), serviceException.getCode()); |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_EXIST.getCode(), serviceException.getCode()); |
|
|
@ -256,9 +255,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
user.setId(1); |
|
|
|
user.setId(1); |
|
|
|
Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, project, |
|
|
|
doNothing().when(projectService).checkProjectAndAuthThrowException(user, projectCode, WORKFLOW_DEFINITION); |
|
|
|
WORKFLOW_DEFINITION); |
|
|
|
|
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); |
|
|
|
|
|
|
|
long processDefinitionCode1 = 1L; |
|
|
|
long processDefinitionCode1 = 1L; |
|
|
|
long processDefinitionCode2 = 2L; |
|
|
|
long processDefinitionCode2 = 2L; |
|
|
|
List<ProcessDefinition> processDefinitions = Arrays.asList( |
|
|
|
List<ProcessDefinition> processDefinitions = Arrays.asList( |
|
|
@ -272,15 +269,15 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
.pageSize(10) |
|
|
|
.pageSize(10) |
|
|
|
.totalCount(30) |
|
|
|
.totalCount(30) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
Mockito.when(processDefinitionDao.listingProcessDefinition( |
|
|
|
when(processDefinitionDao.listingProcessDefinition( |
|
|
|
Mockito.eq(0), |
|
|
|
Mockito.eq(0), |
|
|
|
Mockito.eq(10), |
|
|
|
Mockito.eq(10), |
|
|
|
Mockito.eq(""), |
|
|
|
Mockito.eq(""), |
|
|
|
Mockito.eq(1), |
|
|
|
Mockito.eq(1), |
|
|
|
Mockito.eq(project.getCode()))).thenReturn(pageListingResult); |
|
|
|
Mockito.eq(projectCode))).thenReturn(pageListingResult); |
|
|
|
String user1 = "user1"; |
|
|
|
String user1 = "user1"; |
|
|
|
String user2 = "user2"; |
|
|
|
String user2 = "user2"; |
|
|
|
Mockito.when(userMapper.queryUserWithProcessDefinitionCode(processDefinitionCodes)) |
|
|
|
when(userMapper.queryUserWithProcessDefinitionCode(processDefinitionCodes)) |
|
|
|
.thenReturn(Arrays.asList( |
|
|
|
.thenReturn(Arrays.asList( |
|
|
|
UserWithProcessDefinitionCode.builder() |
|
|
|
UserWithProcessDefinitionCode.builder() |
|
|
|
.processDefinitionCode(processDefinitionCode1) |
|
|
|
.processDefinitionCode(processDefinitionCode1) |
|
|
@ -296,10 +293,16 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Schedule schedule2 = new Schedule(); |
|
|
|
Schedule schedule2 = new Schedule(); |
|
|
|
schedule2.setProcessDefinitionCode(processDefinitionCode2); |
|
|
|
schedule2.setProcessDefinitionCode(processDefinitionCode2); |
|
|
|
schedule2.setReleaseState(ReleaseState.ONLINE); |
|
|
|
schedule2.setReleaseState(ReleaseState.ONLINE); |
|
|
|
Mockito.when(schedulerService.queryScheduleByProcessDefinitionCodes(processDefinitionCodes)) |
|
|
|
when(schedulerService.queryScheduleByProcessDefinitionCodes(processDefinitionCodes)) |
|
|
|
.thenReturn(Arrays.asList(schedule1, schedule2)); |
|
|
|
.thenReturn(Arrays.asList(schedule1, schedule2)); |
|
|
|
PageInfo<ProcessDefinition> pageInfo = processDefinitionService.queryProcessDefinitionListPaging( |
|
|
|
PageInfo<ProcessDefinition> pageInfo = processDefinitionService.queryProcessDefinitionListPaging( |
|
|
|
user, project.getCode(), "", "", 1, 0, 10); |
|
|
|
user, |
|
|
|
|
|
|
|
projectCode, |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
1, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
10); |
|
|
|
Assertions.assertNotNull(pageInfo); |
|
|
|
Assertions.assertNotNull(pageInfo); |
|
|
|
ProcessDefinition pd1 = pageInfo.getTotalList().stream() |
|
|
|
ProcessDefinition pd1 = pageInfo.getTotalList().stream() |
|
|
|
.filter(pd -> pd.getCode() == processDefinitionCode1).findFirst().orElse(null); |
|
|
|
.filter(pd -> pd.getCode() == processDefinitionCode1).findFirst().orElse(null); |
|
|
@ -309,7 +312,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryProcessDefinitionByCode() { |
|
|
|
public void testQueryProcessDefinitionByCode() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
@ -317,26 +320,26 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Map<String, Object> map = processDefinitionService.queryProcessDefinitionByCode(user, 1L, 1L); |
|
|
|
Map<String, Object> map = processDefinitionService.queryProcessDefinitionByCode(user, 1L, 1L); |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth success, instance not exist
|
|
|
|
// project check auth success, instance not exist
|
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
DagData dagData = new DagData(getProcessDefinition(), null, null); |
|
|
|
DagData dagData = new DagData(getProcessDefinition(), null, null); |
|
|
|
Mockito.when(processService.genDagData(Mockito.any())).thenReturn(dagData); |
|
|
|
when(processService.genDagData(Mockito.any())).thenReturn(dagData); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> instanceNotexitRes = |
|
|
|
Map<String, Object> instanceNotexitRes = |
|
|
|
processDefinitionService.queryProcessDefinitionByCode(user, projectCode, 1L); |
|
|
|
processDefinitionService.queryProcessDefinitionByCode(user, projectCode, 1L); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotexitRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotexitRes.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
// instance exit
|
|
|
|
// instance exit
|
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(getProcessDefinition()); |
|
|
|
when(processDefinitionMapper.queryByCode(46L)).thenReturn(getProcessDefinition()); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Map<String, Object> successRes = |
|
|
|
Map<String, Object> successRes = |
|
|
|
processDefinitionService.queryProcessDefinitionByCode(user, projectCode, 46L); |
|
|
|
processDefinitionService.queryProcessDefinitionByCode(user, projectCode, 46L); |
|
|
@ -345,7 +348,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryProcessDefinitionByName() { |
|
|
|
public void testQueryProcessDefinitionByName() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
@ -353,7 +356,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Map<String, Object> map = |
|
|
|
Map<String, Object> map = |
|
|
|
processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test_def"); |
|
|
|
processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test_def"); |
|
|
@ -361,19 +364,19 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// project check auth success, instance not exist
|
|
|
|
// project check auth success, instance not exist
|
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Mockito.when(processDefinitionMapper.queryByDefineName(project.getCode(), "test_def")).thenReturn(null); |
|
|
|
when(processDefinitionMapper.queryByDefineName(project.getCode(), "test_def")).thenReturn(null); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> instanceNotExitRes = |
|
|
|
Map<String, Object> instanceNotExitRes = |
|
|
|
processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test_def"); |
|
|
|
processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test_def"); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotExitRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, instanceNotExitRes.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
// instance exit
|
|
|
|
// instance exit
|
|
|
|
Mockito.when(processDefinitionMapper.queryByDefineName(project.getCode(), "test")) |
|
|
|
when(processDefinitionMapper.queryByDefineName(project.getCode(), "test")) |
|
|
|
.thenReturn(getProcessDefinition()); |
|
|
|
.thenReturn(getProcessDefinition()); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Map<String, Object> successRes = |
|
|
|
Map<String, Object> successRes = |
|
|
|
processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test"); |
|
|
|
processDefinitionService.queryProcessDefinitionByName(user, projectCode, "test"); |
|
|
@ -384,7 +387,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
public void testBatchCopyProcessDefinition() { |
|
|
|
public void testBatchCopyProcessDefinition() { |
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.doReturn(result) |
|
|
|
Mockito.doReturn(result) |
|
|
@ -398,7 +401,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_BATCH_COPY)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_BATCH_COPY)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Map<String, Object> map1 = processDefinitionService.batchCopyProcessDefinition( |
|
|
|
Map<String, Object> map1 = processDefinitionService.batchCopyProcessDefinition( |
|
|
|
user, projectCode, String.valueOf(project.getId()), 2L); |
|
|
|
user, projectCode, String.valueOf(project.getId()), 2L); |
|
|
@ -406,7 +409,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// project check auth success, target project name not equal project name, check auth target project fail
|
|
|
|
// project check auth success, target project name not equal project name, check auth target project fail
|
|
|
|
Project project1 = getProject(projectCodeOther); |
|
|
|
Project project1 = getProject(projectCodeOther); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCodeOther)).thenReturn(project1); |
|
|
|
when(projectMapper.queryByCode(projectCodeOther)).thenReturn(project1); |
|
|
|
Mockito.doReturn(result) |
|
|
|
Mockito.doReturn(result) |
|
|
|
.when(projectService) |
|
|
|
.when(projectService) |
|
|
|
.checkProjectAndAuth(user, project1, projectCodeOther, WORKFLOW_BATCH_COPY); |
|
|
|
.checkProjectAndAuth(user, project1, projectCodeOther, WORKFLOW_BATCH_COPY); |
|
|
@ -425,8 +428,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Assertions.fail(); |
|
|
|
Assertions.fail(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Mockito.when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); |
|
|
|
when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); |
|
|
|
Mockito.when(processService.saveProcessDefine(user, definition, Boolean.TRUE, Boolean.TRUE)).thenReturn(2); |
|
|
|
when(processService.saveProcessDefine(user, definition, Boolean.TRUE, Boolean.TRUE)).thenReturn(2); |
|
|
|
Map<String, Object> map3 = processDefinitionService.batchCopyProcessDefinition( |
|
|
|
Map<String, Object> map3 = processDefinitionService.batchCopyProcessDefinition( |
|
|
|
user, projectCodeOther, String.valueOf(processDefinitionCode), projectCode); |
|
|
|
user, projectCodeOther, String.valueOf(processDefinitionCode), projectCode); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, map3.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, map3.get(Constants.STATUS)); |
|
|
@ -435,17 +438,17 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testBatchMoveProcessDefinition() { |
|
|
|
public void testBatchMoveProcessDefinition() { |
|
|
|
Project project1 = getProject(projectCode); |
|
|
|
Project project1 = getProject(projectCode); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project1); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(project1); |
|
|
|
|
|
|
|
|
|
|
|
Project project2 = getProject(projectCodeOther); |
|
|
|
Project project2 = getProject(projectCodeOther); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCodeOther)).thenReturn(project2); |
|
|
|
when(projectMapper.queryByCode(projectCodeOther)).thenReturn(project2); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project1, projectCode, TASK_DEFINITION_MOVE)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project1, projectCode, TASK_DEFINITION_MOVE)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project2, projectCodeOther, TASK_DEFINITION_MOVE)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project2, projectCodeOther, TASK_DEFINITION_MOVE)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition definition = getProcessDefinition(); |
|
|
|
ProcessDefinition definition = getProcessDefinition(); |
|
|
@ -462,9 +465,9 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Assertions.fail(); |
|
|
|
Assertions.fail(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Mockito.when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); |
|
|
|
when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); |
|
|
|
Mockito.when(processService.saveProcessDefine(user, definition, Boolean.TRUE, Boolean.TRUE)).thenReturn(2); |
|
|
|
when(processService.saveProcessDefine(user, definition, Boolean.TRUE, Boolean.TRUE)).thenReturn(2); |
|
|
|
Mockito.when(processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode)) |
|
|
|
when(processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode)) |
|
|
|
.thenReturn(getProcessTaskRelation()); |
|
|
|
.thenReturn(getProcessTaskRelation()); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
|
|
|
@ -475,8 +478,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void deleteProcessDefinitionByCodeTest() { |
|
|
|
public void deleteProcessDefinitionByCodeTest() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
Mockito.doNothing().when(metricsCleanUpService).cleanUpWorkflowMetricsByDefinitionCode(46L); |
|
|
|
doNothing().when(metricsCleanUpService).cleanUpWorkflowMetricsByDefinitionCode(46L); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
@ -486,24 +489,24 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
Mockito.when(processDefinitionDao.queryByCode(6L)).thenReturn(Optional.of(getProcessDefinition())); |
|
|
|
when(processDefinitionDao.queryByCode(6L)).thenReturn(Optional.of(getProcessDefinition())); |
|
|
|
Mockito.doThrow(new ServiceException(Status.PROJECT_NOT_FOUND)).when(projectService) |
|
|
|
doThrow(new ServiceException(Status.PROJECT_NOT_FOUND)).when(projectService) |
|
|
|
.checkProjectAndAuthThrowException(user, project, WORKFLOW_DEFINITION_DELETE); |
|
|
|
.checkProjectAndAuthThrowException(user, project, WORKFLOW_DEFINITION_DELETE); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 6L)); |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 6L)); |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth success, instance not exist
|
|
|
|
// project check auth success, instance not exist
|
|
|
|
Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, project, |
|
|
|
doNothing().when(projectService).checkProjectAndAuthThrowException(user, project, |
|
|
|
WORKFLOW_DEFINITION_DELETE); |
|
|
|
WORKFLOW_DEFINITION_DELETE); |
|
|
|
Mockito.when(processDefinitionDao.queryByCode(1L)).thenReturn(Optional.empty()); |
|
|
|
when(processDefinitionDao.queryByCode(1L)).thenReturn(Optional.empty()); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 1L)); |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 1L)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
// user no auth
|
|
|
|
// user no auth
|
|
|
|
Mockito.when(processDefinitionDao.queryByCode(46L)).thenReturn(Optional.of(processDefinition)); |
|
|
|
when(processDefinitionDao.queryByCode(46L)).thenReturn(Optional.of(processDefinition)); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
Assertions.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), ((ServiceException) exception).getCode()); |
|
|
@ -511,17 +514,17 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
// process definition online
|
|
|
|
// process definition online
|
|
|
|
user.setUserType(UserType.ADMIN_USER); |
|
|
|
user.setUserType(UserType.ADMIN_USER); |
|
|
|
processDefinition.setReleaseState(ReleaseState.ONLINE); |
|
|
|
processDefinition.setReleaseState(ReleaseState.ONLINE); |
|
|
|
Mockito.when(processDefinitionDao.queryByCode(46L)).thenReturn(Optional.of(processDefinition)); |
|
|
|
when(processDefinitionDao.queryByCode(46L)).thenReturn(Optional.of(processDefinition)); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_STATE_ONLINE.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_STATE_ONLINE.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// scheduler list elements > 1
|
|
|
|
// scheduler list elements > 1
|
|
|
|
processDefinition.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
processDefinition.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
Mockito.when(processDefinitionDao.queryByCode(46L)).thenReturn(Optional.of(processDefinition)); |
|
|
|
when(processDefinitionDao.queryByCode(46L)).thenReturn(Optional.of(processDefinition)); |
|
|
|
Mockito.when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(getSchedule()); |
|
|
|
when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(getSchedule()); |
|
|
|
Mockito.when(scheduleMapper.deleteById(46)).thenReturn(1); |
|
|
|
when(scheduleMapper.deleteById(46)).thenReturn(1); |
|
|
|
Mockito.when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) |
|
|
|
when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) |
|
|
|
.thenReturn(Collections.emptySet()); |
|
|
|
.thenReturn(Collections.emptySet()); |
|
|
|
processDefinitionService.deleteProcessDefinitionByCode(user, 46L); |
|
|
|
processDefinitionService.deleteProcessDefinitionByCode(user, 46L); |
|
|
|
Mockito.verify(metricsCleanUpService, times(1)).cleanUpWorkflowMetricsByDefinitionCode(46L); |
|
|
|
Mockito.verify(metricsCleanUpService, times(1)).cleanUpWorkflowMetricsByDefinitionCode(46L); |
|
|
@ -529,7 +532,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
// scheduler online
|
|
|
|
// scheduler online
|
|
|
|
Schedule schedule = getSchedule(); |
|
|
|
Schedule schedule = getSchedule(); |
|
|
|
schedule.setReleaseState(ReleaseState.ONLINE); |
|
|
|
schedule.setReleaseState(ReleaseState.ONLINE); |
|
|
|
Mockito.when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(schedule); |
|
|
|
when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(schedule); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
Assertions.assertEquals(Status.SCHEDULE_STATE_ONLINE.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.SCHEDULE_STATE_ONLINE.getCode(), ((ServiceException) exception).getCode()); |
|
|
@ -537,7 +540,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
// process used by other task, sub process
|
|
|
|
// process used by other task, sub process
|
|
|
|
user.setUserType(UserType.ADMIN_USER); |
|
|
|
user.setUserType(UserType.ADMIN_USER); |
|
|
|
TaskMainInfo taskMainInfo = getTaskMainInfo().get(0); |
|
|
|
TaskMainInfo taskMainInfo = getTaskMainInfo().get(0); |
|
|
|
Mockito.when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) |
|
|
|
when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) |
|
|
|
.thenReturn(ImmutableSet.copyOf(getTaskMainInfo())); |
|
|
|
.thenReturn(ImmutableSet.copyOf(getTaskMainInfo())); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
@ -546,9 +549,9 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// delete success
|
|
|
|
// delete success
|
|
|
|
schedule.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
schedule.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
Mockito.when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(getSchedule()); |
|
|
|
when(scheduleMapper.queryByProcessDefinitionCode(46L)).thenReturn(getSchedule()); |
|
|
|
Mockito.when(scheduleMapper.deleteById(schedule.getId())).thenReturn(1); |
|
|
|
when(scheduleMapper.deleteById(schedule.getId())).thenReturn(1); |
|
|
|
Mockito.when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) |
|
|
|
when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), processDefinition.getCode())) |
|
|
|
.thenReturn(Collections.emptySet()); |
|
|
|
.thenReturn(Collections.emptySet()); |
|
|
|
Assertions.assertDoesNotThrow(() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
Assertions.assertDoesNotThrow(() -> processDefinitionService.deleteProcessDefinitionByCode(user, 46L)); |
|
|
|
Mockito.verify(metricsCleanUpService, times(2)).cleanUpWorkflowMetricsByDefinitionCode(46L); |
|
|
|
Mockito.verify(metricsCleanUpService, times(2)).cleanUpWorkflowMetricsByDefinitionCode(46L); |
|
|
@ -556,7 +559,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void batchDeleteProcessDefinitionByCodeTest() { |
|
|
|
public void batchDeleteProcessDefinitionByCodeTest() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
@ -567,7 +570,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
ProcessDefinition process = getProcessDefinition(); |
|
|
|
ProcessDefinition process = getProcessDefinition(); |
|
|
|
List<ProcessDefinition> processDefinitionList = new ArrayList<>(); |
|
|
|
List<ProcessDefinition> processDefinitionList = new ArrayList<>(); |
|
|
|
processDefinitionList.add(process); |
|
|
|
processDefinitionList.add(process); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); |
|
|
|
when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); |
|
|
|
Throwable exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
Throwable exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.batchDeleteProcessDefinitionByCodes(user, projectCode, twoCodes)); |
|
|
|
() -> processDefinitionService.batchDeleteProcessDefinitionByCodes(user, projectCode, twoCodes)); |
|
|
|
String formatter = MessageFormat.format(Status.BATCH_DELETE_PROCESS_DEFINE_BY_CODES_ERROR.getMsg(), |
|
|
|
String formatter = MessageFormat.format(Status.BATCH_DELETE_PROCESS_DEFINE_BY_CODES_ERROR.getMsg(), |
|
|
@ -579,8 +582,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
final String singleCodes = "11"; |
|
|
|
final String singleCodes = "11"; |
|
|
|
definitionCodes = Lists.newArrayList(singleCodes.split(Constants.COMMA)).stream().map(Long::parseLong) |
|
|
|
definitionCodes = Lists.newArrayList(singleCodes.split(Constants.COMMA)).stream().map(Long::parseLong) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); |
|
|
|
when(processDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(processDefinitionList); |
|
|
|
Mockito.when(processDefinitionDao.queryByCode(processDefinitionCode)).thenReturn(Optional.of(process)); |
|
|
|
when(processDefinitionDao.queryByCode(processDefinitionCode)).thenReturn(Optional.of(process)); |
|
|
|
|
|
|
|
|
|
|
|
// process definition online
|
|
|
|
// process definition online
|
|
|
|
user.setUserType(UserType.ADMIN_USER); |
|
|
|
user.setUserType(UserType.ADMIN_USER); |
|
|
@ -596,11 +599,11 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// delete success
|
|
|
|
// delete success
|
|
|
|
process.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
process.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
Mockito.when(processDefinitionDao.queryByCode(processDefinitionCode)).thenReturn(Optional.of(process)); |
|
|
|
when(processDefinitionDao.queryByCode(processDefinitionCode)).thenReturn(Optional.of(process)); |
|
|
|
Mockito.when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), process.getCode())) |
|
|
|
when(workFlowLineageService.queryTaskDepOnProcess(project.getCode(), process.getCode())) |
|
|
|
.thenReturn(Collections.emptySet()); |
|
|
|
.thenReturn(Collections.emptySet()); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.doNothing().when(metricsCleanUpService).cleanUpWorkflowMetricsByDefinitionCode(11L); |
|
|
|
doNothing().when(metricsCleanUpService).cleanUpWorkflowMetricsByDefinitionCode(11L); |
|
|
|
Map<String, Object> deleteSuccess = |
|
|
|
Map<String, Object> deleteSuccess = |
|
|
|
processDefinitionService.batchDeleteProcessDefinitionByCodes(user, projectCode, singleCodes); |
|
|
|
processDefinitionService.batchDeleteProcessDefinitionByCodes(user, projectCode, singleCodes); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, deleteSuccess.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, deleteSuccess.get(Constants.STATUS)); |
|
|
@ -609,14 +612,14 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testReleaseProcessDefinition() { |
|
|
|
public void testReleaseProcessDefinition() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_ONLINE_OFFLINE)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_ONLINE_OFFLINE)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Map<String, Object> map = processDefinitionService.releaseProcessDefinition(user, projectCode, |
|
|
|
Map<String, Object> map = processDefinitionService.releaseProcessDefinition(user, projectCode, |
|
|
|
processDefinitionCode, ReleaseState.OFFLINE); |
|
|
|
processDefinitionCode, ReleaseState.OFFLINE); |
|
|
@ -624,14 +627,14 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// project check auth success, processes definition online
|
|
|
|
// project check auth success, processes definition online
|
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(getProcessDefinition()); |
|
|
|
when(processDefinitionMapper.queryByCode(46L)).thenReturn(getProcessDefinition()); |
|
|
|
List<ProcessTaskRelation> processTaskRelationList = new ArrayList<>(); |
|
|
|
List<ProcessTaskRelation> processTaskRelationList = new ArrayList<>(); |
|
|
|
ProcessTaskRelation processTaskRelation = new ProcessTaskRelation(); |
|
|
|
ProcessTaskRelation processTaskRelation = new ProcessTaskRelation(); |
|
|
|
processTaskRelation.setProjectCode(projectCode); |
|
|
|
processTaskRelation.setProjectCode(projectCode); |
|
|
|
processTaskRelation.setProcessDefinitionCode(46L); |
|
|
|
processTaskRelation.setProcessDefinitionCode(46L); |
|
|
|
processTaskRelation.setPostTaskCode(123L); |
|
|
|
processTaskRelation.setPostTaskCode(123L); |
|
|
|
processTaskRelationList.add(processTaskRelation); |
|
|
|
processTaskRelationList.add(processTaskRelation); |
|
|
|
Mockito.when(processService.findRelationByCode(46L, 1)).thenReturn(processTaskRelationList); |
|
|
|
when(processService.findRelationByCode(46L, 1)).thenReturn(processTaskRelationList); |
|
|
|
Map<String, Object> onlineRes = |
|
|
|
Map<String, Object> onlineRes = |
|
|
|
processDefinitionService.releaseProcessDefinition(user, projectCode, 46, ReleaseState.ONLINE); |
|
|
|
processDefinitionService.releaseProcessDefinition(user, projectCode, 46, ReleaseState.ONLINE); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, onlineRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, onlineRes.get(Constants.STATUS)); |
|
|
@ -649,13 +652,13 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testVerifyProcessDefinitionName() { |
|
|
|
public void testVerifyProcessDefinitionName() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_CREATE)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_CREATE)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Map<String, Object> map = processDefinitionService.verifyProcessDefinitionName(user, |
|
|
|
Map<String, Object> map = processDefinitionService.verifyProcessDefinitionName(user, |
|
|
|
projectCode, "test_pdf", 0); |
|
|
|
projectCode, "test_pdf", 0); |
|
|
@ -663,13 +666,13 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// project check auth success, process not exist
|
|
|
|
// project check auth success, process not exist
|
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(processDefinitionMapper.verifyByDefineName(project.getCode(), "test_pdf")).thenReturn(null); |
|
|
|
when(processDefinitionMapper.verifyByDefineName(project.getCode(), "test_pdf")).thenReturn(null); |
|
|
|
Map<String, Object> processNotExistRes = |
|
|
|
Map<String, Object> processNotExistRes = |
|
|
|
processDefinitionService.verifyProcessDefinitionName(user, projectCode, "test_pdf", 0); |
|
|
|
processDefinitionService.verifyProcessDefinitionName(user, projectCode, "test_pdf", 0); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, processNotExistRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, processNotExistRes.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
// process exist
|
|
|
|
// process exist
|
|
|
|
Mockito.when(processDefinitionMapper.verifyByDefineName(project.getCode(), "test_pdf")) |
|
|
|
when(processDefinitionMapper.verifyByDefineName(project.getCode(), "test_pdf")) |
|
|
|
.thenReturn(getProcessDefinition()); |
|
|
|
.thenReturn(getProcessDefinition()); |
|
|
|
Map<String, Object> processExistRes = processDefinitionService.verifyProcessDefinitionName(user, |
|
|
|
Map<String, Object> processExistRes = processDefinitionService.verifyProcessDefinitionName(user, |
|
|
|
projectCode, "test_pdf", 0); |
|
|
|
projectCode, "test_pdf", 0); |
|
|
@ -690,15 +693,15 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testGetTaskNodeListByDefinitionCode() { |
|
|
|
public void testGetTaskNodeListByDefinitionCode() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, null)).thenReturn(result); |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, null)).thenReturn(result); |
|
|
|
// process definition not exist
|
|
|
|
// process definition not exist
|
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(null); |
|
|
|
when(processDefinitionMapper.queryByCode(46L)).thenReturn(null); |
|
|
|
Map<String, Object> processDefinitionNullRes = |
|
|
|
Map<String, Object> processDefinitionNullRes = |
|
|
|
processDefinitionService.getTaskNodeListByDefinitionCode(user, projectCode, 46L); |
|
|
|
processDefinitionService.getTaskNodeListByDefinitionCode(user, projectCode, 46L); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionNullRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionNullRes.get(Constants.STATUS)); |
|
|
@ -706,8 +709,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
// success
|
|
|
|
// success
|
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(processService.genDagData(Mockito.any())).thenReturn(new DagData(processDefinition, null, null)); |
|
|
|
when(processService.genDagData(Mockito.any())).thenReturn(new DagData(processDefinition, null, null)); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); |
|
|
|
when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); |
|
|
|
Map<String, Object> dataNotValidRes = |
|
|
|
Map<String, Object> dataNotValidRes = |
|
|
|
processDefinitionService.getTaskNodeListByDefinitionCode(user, projectCode, 46L); |
|
|
|
processDefinitionService.getTaskNodeListByDefinitionCode(user, projectCode, 46L); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, dataNotValidRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, dataNotValidRes.get(Constants.STATUS)); |
|
|
@ -715,18 +718,18 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testGetTaskNodeListByDefinitionCodes() { |
|
|
|
public void testGetTaskNodeListByDefinitionCodes() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, null)).thenReturn(result); |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, null)).thenReturn(result); |
|
|
|
// process definition not exist
|
|
|
|
// process definition not exist
|
|
|
|
String defineCodes = "46"; |
|
|
|
String defineCodes = "46"; |
|
|
|
Set<Long> defineCodeSet = Lists.newArrayList(defineCodes.split(Constants.COMMA)).stream().map(Long::parseLong) |
|
|
|
Set<Long> defineCodeSet = Lists.newArrayList(defineCodes.split(Constants.COMMA)).stream().map(Long::parseLong) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCodes(defineCodeSet)).thenReturn(null); |
|
|
|
when(processDefinitionMapper.queryByCodes(defineCodeSet)).thenReturn(null); |
|
|
|
Map<String, Object> processNotExistRes = |
|
|
|
Map<String, Object> processNotExistRes = |
|
|
|
processDefinitionService.getNodeListMapByDefinitionCodes(user, projectCode, defineCodes); |
|
|
|
processDefinitionService.getNodeListMapByDefinitionCodes(user, projectCode, defineCodes); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processNotExistRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST, processNotExistRes.get(Constants.STATUS)); |
|
|
@ -736,12 +739,12 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
List<ProcessDefinition> processDefinitionList = new ArrayList<>(); |
|
|
|
List<ProcessDefinition> processDefinitionList = new ArrayList<>(); |
|
|
|
processDefinitionList.add(processDefinition); |
|
|
|
processDefinitionList.add(processDefinition); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(processDefinitionMapper.queryByCodes(defineCodeSet)).thenReturn(processDefinitionList); |
|
|
|
when(processDefinitionMapper.queryByCodes(defineCodeSet)).thenReturn(processDefinitionList); |
|
|
|
Mockito.when(processService.genDagData(Mockito.any())).thenReturn(new DagData(processDefinition, null, null)); |
|
|
|
when(processService.genDagData(Mockito.any())).thenReturn(new DagData(processDefinition, null, null)); |
|
|
|
Project project1 = getProject(projectCode); |
|
|
|
Project project1 = getProject(projectCode); |
|
|
|
List<Project> projects = new ArrayList<>(); |
|
|
|
List<Project> projects = new ArrayList<>(); |
|
|
|
projects.add(project1); |
|
|
|
projects.add(project1); |
|
|
|
Mockito.when(projectMapper.queryProjectCreatedAndAuthorizedByUserId(user.getId())).thenReturn(projects); |
|
|
|
when(projectMapper.queryProjectCreatedAndAuthorizedByUserId(user.getId())).thenReturn(projects); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> successRes = |
|
|
|
Map<String, Object> successRes = |
|
|
|
processDefinitionService.getNodeListMapByDefinitionCodes(user, projectCode, defineCodes); |
|
|
|
processDefinitionService.getNodeListMapByDefinitionCodes(user, projectCode, defineCodes); |
|
|
@ -752,14 +755,14 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
public void testQueryAllProcessDefinitionByProjectCode() { |
|
|
|
public void testQueryAllProcessDefinitionByProjectCode() { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(project); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
List<ProcessDefinition> processDefinitionList = new ArrayList<>(); |
|
|
|
List<ProcessDefinition> processDefinitionList = new ArrayList<>(); |
|
|
|
processDefinitionList.add(processDefinition); |
|
|
|
processDefinitionList.add(processDefinition); |
|
|
|
Mockito.when(processDefinitionMapper.queryAllDefinitionList(projectCode)).thenReturn(processDefinitionList); |
|
|
|
when(processDefinitionMapper.queryAllDefinitionList(projectCode)).thenReturn(processDefinitionList); |
|
|
|
Map<String, Object> successRes = |
|
|
|
Map<String, Object> successRes = |
|
|
|
processDefinitionService.queryAllProcessDefinitionByProjectCode(user, projectCode); |
|
|
|
processDefinitionService.queryAllProcessDefinitionByProjectCode(user, projectCode); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); |
|
|
@ -770,8 +773,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Project project1 = getProject(projectCode); |
|
|
|
Project project1 = getProject(projectCode); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectMapper.queryByCode(1)).thenReturn(project1); |
|
|
|
when(projectMapper.queryByCode(1)).thenReturn(project1); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project1, projectCode, WORKFLOW_TREE_VIEW)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project1, projectCode, WORKFLOW_TREE_VIEW)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
// process definition not exist
|
|
|
|
// process definition not exist
|
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
@ -781,10 +784,10 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// task instance not existproject
|
|
|
|
// task instance not existproject
|
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
putMsg(result, Status.SUCCESS, projectCode); |
|
|
|
Mockito.when(projectMapper.queryByCode(1)).thenReturn(project1); |
|
|
|
when(projectMapper.queryByCode(1)).thenReturn(project1); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project1, 1, WORKFLOW_TREE_VIEW)).thenReturn(result); |
|
|
|
when(projectService.checkProjectAndAuth(user, project1, 1, WORKFLOW_TREE_VIEW)).thenReturn(result); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); |
|
|
|
when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processService.genDagGraph(processDefinition)).thenReturn(new DAG<>()); |
|
|
|
when(processService.genDagGraph(processDefinition)).thenReturn(new DAG<>()); |
|
|
|
Map<String, Object> taskNullRes = |
|
|
|
Map<String, Object> taskNullRes = |
|
|
|
processDefinitionService.viewTree(user, processDefinition.getProjectCode(), 46, 10); |
|
|
|
processDefinitionService.viewTree(user, processDefinition.getProjectCode(), 46, 10); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, taskNullRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, taskNullRes.get(Constants.STATUS)); |
|
|
@ -798,14 +801,14 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testSubProcessViewTree() { |
|
|
|
public void testSubProcessViewTree() { |
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
ProcessDefinition processDefinition = getProcessDefinition(); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); |
|
|
|
when(processDefinitionMapper.queryByCode(46L)).thenReturn(processDefinition); |
|
|
|
|
|
|
|
|
|
|
|
Project project1 = getProject(1); |
|
|
|
Project project1 = getProject(1); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
result.put(Constants.STATUS, Status.SUCCESS); |
|
|
|
result.put(Constants.STATUS, Status.SUCCESS); |
|
|
|
Mockito.when(projectMapper.queryByCode(1)).thenReturn(project1); |
|
|
|
when(projectMapper.queryByCode(1)).thenReturn(project1); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project1, 1, WORKFLOW_TREE_VIEW)).thenReturn(result); |
|
|
|
when(projectService.checkProjectAndAuth(user, project1, 1, WORKFLOW_TREE_VIEW)).thenReturn(result); |
|
|
|
Mockito.when(processService.genDagGraph(processDefinition)).thenReturn(new DAG<>()); |
|
|
|
when(processService.genDagGraph(processDefinition)).thenReturn(new DAG<>()); |
|
|
|
Map<String, Object> taskNotNuLLRes = |
|
|
|
Map<String, Object> taskNotNuLLRes = |
|
|
|
processDefinitionService.viewTree(user, processDefinition.getProjectCode(), 46, 10); |
|
|
|
processDefinitionService.viewTree(user, processDefinition.getProjectCode(), 46, 10); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, taskNotNuLLRes.get(Constants.STATUS)); |
|
|
|
Assertions.assertEquals(Status.SUCCESS, taskNotNuLLRes.get(Constants.STATUS)); |
|
|
@ -816,8 +819,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
Mockito.when(projectService.hasProjectAndWritePerm(user, project, result)).thenReturn(true); |
|
|
|
when(projectService.hasProjectAndWritePerm(user, project, result)).thenReturn(true); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
processDefinitionService.updateProcessDefinition(user, projectCode, "test", 1, |
|
|
|
processDefinitionService.updateProcessDefinition(user, projectCode, "test", 1, |
|
|
@ -835,16 +838,16 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
processDefinitionService.batchExportProcessDefinitionByCodes(user, projectCode, "1", null); |
|
|
|
processDefinitionService.batchExportProcessDefinitionByCodes(user, projectCode, "1", null); |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(); |
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(); |
|
|
|
processDefinition.setId(1); |
|
|
|
processDefinition.setId(1); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(project); |
|
|
|
HttpServletResponse response = Mockito.mock(HttpServletResponse.class); |
|
|
|
HttpServletResponse response = Mockito.mock(HttpServletResponse.class); |
|
|
|
|
|
|
|
|
|
|
|
DagData dagData = new DagData(getProcessDefinition(), null, null); |
|
|
|
DagData dagData = new DagData(getProcessDefinition(), null, null); |
|
|
|
Mockito.when(processService.genDagData(Mockito.any())).thenReturn(dagData); |
|
|
|
when(processService.genDagData(Mockito.any())).thenReturn(dagData); |
|
|
|
processDefinitionService.batchExportProcessDefinitionByCodes(user, projectCode, "1", response); |
|
|
|
processDefinitionService.batchExportProcessDefinitionByCodes(user, projectCode, "1", response); |
|
|
|
Assertions.assertNotNull(processDefinitionService.exportProcessDagData(processDefinition)); |
|
|
|
Assertions.assertNotNull(processDefinitionService.exportProcessDagData(processDefinition)); |
|
|
|
} |
|
|
|
} |
|
|
@ -869,25 +872,25 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
new MockMultipartFile("import_sql.zip", byteArrayOutputStream.toByteArray()); |
|
|
|
new MockMultipartFile("import_sql.zip", byteArrayOutputStream.toByteArray()); |
|
|
|
|
|
|
|
|
|
|
|
DataSource dataSource = Mockito.mock(DataSource.class); |
|
|
|
DataSource dataSource = Mockito.mock(DataSource.class); |
|
|
|
Mockito.when(dataSource.getId()).thenReturn(1); |
|
|
|
when(dataSource.getId()).thenReturn(1); |
|
|
|
Mockito.when(dataSource.getType()).thenReturn(DbType.MYSQL); |
|
|
|
when(dataSource.getType()).thenReturn(DbType.MYSQL); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(dataSourceMapper.queryDataSourceByNameAndUserId(user.getId(), "mysql_1")).thenReturn(dataSource); |
|
|
|
when(dataSourceMapper.queryDataSourceByNameAndUserId(user.getId(), "mysql_1")).thenReturn(dataSource); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
result.put(Constants.STATUS, Status.SUCCESS); |
|
|
|
result.put(Constants.STATUS, Status.SUCCESS); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_IMPORT)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_IMPORT)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
Mockito.when(processService.saveTaskDefine(Mockito.same(user), Mockito.eq(projectCode), Mockito.notNull(), |
|
|
|
when(processService.saveTaskDefine(Mockito.same(user), Mockito.eq(projectCode), Mockito.notNull(), |
|
|
|
Mockito.anyBoolean())).thenReturn(2); |
|
|
|
Mockito.anyBoolean())).thenReturn(2); |
|
|
|
Mockito.when(processService.saveProcessDefine(Mockito.same(user), Mockito.notNull(), Mockito.notNull(), |
|
|
|
when(processService.saveProcessDefine(Mockito.same(user), Mockito.notNull(), Mockito.notNull(), |
|
|
|
Mockito.anyBoolean())).thenReturn(1); |
|
|
|
Mockito.anyBoolean())).thenReturn(1); |
|
|
|
Mockito.when( |
|
|
|
when( |
|
|
|
processService.saveTaskRelation(Mockito.same(user), Mockito.eq(projectCode), Mockito.anyLong(), |
|
|
|
processService.saveTaskRelation(Mockito.same(user), Mockito.eq(projectCode), Mockito.anyLong(), |
|
|
|
Mockito.eq(1), Mockito.notNull(), Mockito.notNull(), Mockito.anyBoolean())) |
|
|
|
Mockito.eq(1), Mockito.notNull(), Mockito.notNull(), Mockito.anyBoolean())) |
|
|
|
.thenReturn(0); |
|
|
|
.thenReturn(0); |
|
|
|
result = processDefinitionService.importSqlProcessDefinition(user, projectCode, mockMultipartFile); |
|
|
|
result = processDefinitionService.importSqlProcessDefinition(user, projectCode, mockMultipartFile); |
|
|
|
|
|
|
|
|
|
|
|
Assertions.assertEquals(result.get(Constants.STATUS), Status.SUCCESS); |
|
|
|
Assertions.assertEquals(result.get(Constants.STATUS), Status.SUCCESS); |
|
|
@ -920,8 +923,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// project permission error
|
|
|
|
// project permission error
|
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(project); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(project); |
|
|
|
Mockito.doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM)).when(projectService) |
|
|
|
doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM)).when(projectService) |
|
|
|
.checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); |
|
|
|
.checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); |
|
|
|
() -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); |
|
|
@ -930,7 +933,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// description too long
|
|
|
|
// description too long
|
|
|
|
workflowCreateRequest.setDescription(taskDefinitionJson); |
|
|
|
workflowCreateRequest.setDescription(taskDefinitionJson); |
|
|
|
Mockito.doThrow(new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR)).when(projectService) |
|
|
|
doThrow(new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR)).when(projectService) |
|
|
|
.checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); |
|
|
|
.checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); |
|
|
|
() -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); |
|
|
@ -938,15 +941,15 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
workflowCreateRequest.setDescription(EMPTY_STRING); |
|
|
|
workflowCreateRequest.setDescription(EMPTY_STRING); |
|
|
|
|
|
|
|
|
|
|
|
// duplicate process definition name
|
|
|
|
// duplicate process definition name
|
|
|
|
Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); |
|
|
|
doNothing().when(projectService).checkProjectAndAuthThrowException(user, project, WORKFLOW_CREATE); |
|
|
|
Mockito.when(processDefinitionMapper.verifyByDefineName(project.getCode(), name)) |
|
|
|
when(processDefinitionMapper.verifyByDefineName(project.getCode(), name)) |
|
|
|
.thenReturn(this.getProcessDefinition()); |
|
|
|
.thenReturn(this.getProcessDefinition()); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); |
|
|
|
() -> processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINITION_NAME_EXIST.getCode(), |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINITION_NAME_EXIST.getCode(), |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(processDefinitionMapper.verifyByDefineName(project.getCode(), name)).thenReturn(null); |
|
|
|
when(processDefinitionMapper.verifyByDefineName(project.getCode(), name)).thenReturn(null); |
|
|
|
|
|
|
|
|
|
|
|
// test success
|
|
|
|
// test success
|
|
|
|
workflowCreateRequest.setDescription(description); |
|
|
|
workflowCreateRequest.setDescription(description); |
|
|
@ -954,8 +957,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
workflowCreateRequest.setReleaseState(releaseState); |
|
|
|
workflowCreateRequest.setReleaseState(releaseState); |
|
|
|
workflowCreateRequest.setWarningGroupId(warningGroupId); |
|
|
|
workflowCreateRequest.setWarningGroupId(warningGroupId); |
|
|
|
workflowCreateRequest.setExecutionType(executionType); |
|
|
|
workflowCreateRequest.setExecutionType(executionType); |
|
|
|
Mockito.when(processDefinitionLogMapper.insert(Mockito.any())).thenReturn(1); |
|
|
|
when(processDefinitionLogMapper.insert(Mockito.any())).thenReturn(1); |
|
|
|
Mockito.when(processDefinitionMapper.insert(Mockito.any())).thenReturn(1); |
|
|
|
when(processDefinitionMapper.insert(Mockito.any())).thenReturn(1); |
|
|
|
ProcessDefinition processDefinition = |
|
|
|
ProcessDefinition processDefinition = |
|
|
|
processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest); |
|
|
|
processDefinitionService.createSingleProcessDefinition(user, workflowCreateRequest); |
|
|
|
|
|
|
|
|
|
|
@ -976,8 +979,8 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
workflowFilterRequest.setProjectName(project.getName()); |
|
|
|
workflowFilterRequest.setProjectName(project.getName()); |
|
|
|
|
|
|
|
|
|
|
|
// project permission error
|
|
|
|
// project permission error
|
|
|
|
Mockito.when(projectMapper.queryByName(project.getName())).thenReturn(project); |
|
|
|
when(projectMapper.queryByName(project.getName())).thenReturn(project); |
|
|
|
Mockito.doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) |
|
|
|
doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) |
|
|
|
.when(projectService).checkProjectAndAuthThrowException(user, project, WORKFLOW_DEFINITION); |
|
|
|
.when(projectService).checkProjectAndAuthThrowException(user, project, WORKFLOW_DEFINITION); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
() -> processDefinitionService.filterProcessDefinition(user, workflowFilterRequest)); |
|
|
|
() -> processDefinitionService.filterProcessDefinition(user, workflowFilterRequest)); |
|
|
@ -993,10 +996,10 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_EXIST.getCode(), ((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// project permission error
|
|
|
|
// project permission error
|
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)) |
|
|
|
when(processDefinitionMapper.queryByCode(processDefinitionCode)) |
|
|
|
.thenReturn(this.getProcessDefinition()); |
|
|
|
.thenReturn(this.getProcessDefinition()); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(this.getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(this.getProject(projectCode)); |
|
|
|
Mockito.doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) |
|
|
|
doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) |
|
|
|
.when(projectService) |
|
|
|
.when(projectService) |
|
|
|
.checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_DEFINITION); |
|
|
|
.checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_DEFINITION); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
@ -1005,7 +1008,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// success
|
|
|
|
// success
|
|
|
|
Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, this.getProject(projectCode), |
|
|
|
doNothing().when(projectService).checkProjectAndAuthThrowException(user, this.getProject(projectCode), |
|
|
|
WORKFLOW_DEFINITION); |
|
|
|
WORKFLOW_DEFINITION); |
|
|
|
ProcessDefinition processDefinition = |
|
|
|
ProcessDefinition processDefinition = |
|
|
|
processDefinitionService.getProcessDefinition(user, processDefinitionCode); |
|
|
|
processDefinitionService.getProcessDefinition(user, processDefinitionCode); |
|
|
@ -1027,7 +1030,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
// error old process definition in release state
|
|
|
|
// error old process definition in release state
|
|
|
|
processDefinition = this.getProcessDefinition(); |
|
|
|
processDefinition = this.getProcessDefinition(); |
|
|
|
processDefinition.setReleaseState(ReleaseState.ONLINE); |
|
|
|
processDefinition.setReleaseState(ReleaseState.ONLINE); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); |
|
|
|
when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService |
|
|
|
.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); |
|
|
|
.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT.getCode(), |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT.getCode(), |
|
|
@ -1035,9 +1038,9 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// error project permission
|
|
|
|
// error project permission
|
|
|
|
processDefinition = this.getProcessDefinition(); |
|
|
|
processDefinition = this.getProcessDefinition(); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); |
|
|
|
when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(this.getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(this.getProject(projectCode)); |
|
|
|
Mockito.doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) |
|
|
|
doThrow(new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode)) |
|
|
|
.when(projectService) |
|
|
|
.when(projectService) |
|
|
|
.checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_DEFINITION); |
|
|
|
.checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_DEFINITION); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, |
|
|
@ -1047,7 +1050,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
// error description too long
|
|
|
|
// error description too long
|
|
|
|
workflowUpdateRequest.setDescription(taskDefinitionJson); |
|
|
|
workflowUpdateRequest.setDescription(taskDefinitionJson); |
|
|
|
Mockito.doThrow(new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR)).when(projectService) |
|
|
|
doThrow(new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR)).when(projectService) |
|
|
|
.checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_UPDATE); |
|
|
|
.checkProjectAndAuthThrowException(user, this.getProject(projectCode), WORKFLOW_UPDATE); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService |
|
|
|
.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); |
|
|
|
.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); |
|
|
@ -1055,31 +1058,31 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
workflowUpdateRequest.setDescription(EMPTY_STRING); |
|
|
|
workflowUpdateRequest.setDescription(EMPTY_STRING); |
|
|
|
|
|
|
|
|
|
|
|
// error new definition name already exists
|
|
|
|
// error new definition name already exists
|
|
|
|
Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(user, this.getProject(projectCode), |
|
|
|
doNothing().when(projectService).checkProjectAndAuthThrowException(user, this.getProject(projectCode), |
|
|
|
WORKFLOW_UPDATE); |
|
|
|
WORKFLOW_UPDATE); |
|
|
|
Mockito.when(processDefinitionMapper.verifyByDefineName(projectCode, workflowUpdateRequest.getName())) |
|
|
|
when(processDefinitionMapper.verifyByDefineName(projectCode, workflowUpdateRequest.getName())) |
|
|
|
.thenReturn(this.getProcessDefinition()); |
|
|
|
.thenReturn(this.getProcessDefinition()); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService |
|
|
|
.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); |
|
|
|
.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINITION_NAME_EXIST.getCode(), |
|
|
|
Assertions.assertEquals(Status.PROCESS_DEFINITION_NAME_EXIST.getCode(), |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); |
|
|
|
when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processDefinitionMapper.verifyByDefineName(projectCode, workflowUpdateRequest.getName())) |
|
|
|
when(processDefinitionMapper.verifyByDefineName(projectCode, workflowUpdateRequest.getName())) |
|
|
|
.thenReturn(null); |
|
|
|
.thenReturn(null); |
|
|
|
// error update process definition mapper
|
|
|
|
// error update process definition mapper
|
|
|
|
workflowUpdateRequest.setName(name); |
|
|
|
workflowUpdateRequest.setName(name); |
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); |
|
|
|
when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(processDefinition); |
|
|
|
Mockito.when(processDefinitionLogMapper.insert(Mockito.any())).thenReturn(1); |
|
|
|
when(processDefinitionLogMapper.insert(Mockito.any())).thenReturn(1); |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService |
|
|
|
exception = Assertions.assertThrows(ServiceException.class, () -> processDefinitionService |
|
|
|
.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); |
|
|
|
.updateSingleProcessDefinition(user, processDefinitionCode, workflowUpdateRequest)); |
|
|
|
Assertions.assertEquals(Status.UPDATE_PROCESS_DEFINITION_ERROR.getCode(), |
|
|
|
Assertions.assertEquals(Status.UPDATE_PROCESS_DEFINITION_ERROR.getCode(), |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
((ServiceException) exception).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// success
|
|
|
|
// success
|
|
|
|
Mockito.when(processDefinitionLogMapper.queryMaxVersionForDefinition(processDefinition.getCode())) |
|
|
|
when(processDefinitionLogMapper.queryMaxVersionForDefinition(processDefinition.getCode())) |
|
|
|
.thenReturn(processDefinition.getVersion()); |
|
|
|
.thenReturn(processDefinition.getVersion()); |
|
|
|
Mockito.when(processDefinitionMapper.updateById(isA(ProcessDefinition.class))).thenReturn(1); |
|
|
|
when(processDefinitionMapper.updateById(isA(ProcessDefinition.class))).thenReturn(1); |
|
|
|
ProcessDefinition processDefinitionUpdate = |
|
|
|
ProcessDefinition processDefinitionUpdate = |
|
|
|
processDefinitionService.updateSingleProcessDefinition(user, processDefinitionCode, |
|
|
|
processDefinitionService.updateSingleProcessDefinition(user, processDefinitionCode, |
|
|
|
workflowUpdateRequest); |
|
|
|
workflowUpdateRequest); |
|
|
@ -1098,7 +1101,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testViewVariables() { |
|
|
|
public void testViewVariables() { |
|
|
|
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); |
|
|
|
|
|
|
|
|
|
|
|
Project project = getProject(projectCode); |
|
|
|
Project project = getProject(projectCode); |
|
|
|
|
|
|
|
|
|
|
@ -1108,7 +1111,7 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); |
|
|
|
|
|
|
|
|
|
|
|
// project check auth fail
|
|
|
|
// project check auth fail
|
|
|
|
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_DEFINITION)) |
|
|
|
.thenReturn(result); |
|
|
|
.thenReturn(result); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = |
|
|
|
Map<String, Object> map = |
|
|
|