Skip to content

Commit

Permalink
Merge 860021f into 5c1edd2
Browse files Browse the repository at this point in the history
  • Loading branch information
Radeity authored Apr 22, 2023
2 parents 5c1edd2 + 860021f commit cc36c5b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public Result queryTaskListByProcessId(@Parameter(hidden = true) @RequestAttribu
@Parameter(name = "globalParams", description = "PROCESS_GLOBAL_PARAMS", schema = @Schema(implementation = String.class, example = "[]")),
@Parameter(name = "locations", description = "PROCESS_INSTANCE_LOCATIONS", schema = @Schema(implementation = String.class)),
@Parameter(name = "timeout", description = "PROCESS_TIMEOUT", schema = @Schema(implementation = int.class, example = "0")),
@Parameter(name = "tenantCode", description = "TENANT_CODE", schema = @Schema(implementation = String.class, example = "default"))
})
@PutMapping(value = "/{id}")
@ResponseStatus(HttpStatus.OK)
Expand All @@ -190,11 +189,9 @@ public Result updateProcessInstance(@Parameter(hidden = true) @RequestAttribute(
@RequestParam(value = "syncDefine", required = true) Boolean syncDefine,
@RequestParam(value = "globalParams", required = false, defaultValue = "[]") String globalParams,
@RequestParam(value = "locations", required = false) String locations,
@RequestParam(value = "timeout", required = false, defaultValue = "0") int timeout,
@RequestParam(value = "tenantCode", required = true) String tenantCode) {
@RequestParam(value = "timeout", required = false, defaultValue = "0") int timeout) {
Map<String, Object> result = processInstanceService.updateProcessInstance(loginUser, projectCode, id,
taskRelationJson, taskDefinitionJson, scheduleTime, syncDefine, globalParams, locations, timeout,
tenantCode);
taskRelationJson, taskDefinitionJson, scheduleTime, syncDefine, globalParams, locations, timeout);
return returnDataList(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ Map<String, Object> querySubProcessInstanceByTaskId(User loginUser,
* @param globalParams global params
* @param locations locations for nodes
* @param timeout timeout
* @param tenantCode tenantCode
* @return update result code
*/
Map<String, Object> updateProcessInstance(User loginUser,
Expand All @@ -160,8 +159,7 @@ Map<String, Object> updateProcessInstance(User loginUser,
Boolean syncDefine,
String globalParams,
String locations,
int timeout,
String tenantCode);
int timeout);

/**
* query parent process instance detail info by sub process instance id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ public Map<String, Object> querySubProcessInstanceByTaskId(User loginUser, long
* @param globalParams global params
* @param locations locations for nodes
* @param timeout timeout
* @param tenantCode tenantCode
* @return update result code
*/
@Transactional
Expand All @@ -616,7 +615,7 @@ public Map<String, Object> updateProcessInstance(User loginUser, long projectCod
String taskRelationJson,
String taskDefinitionJson, String scheduleTime, Boolean syncDefine,
String globalParams,
String locations, int timeout, String tenantCode) {
String locations, int timeout) {
Project project = projectMapper.queryByCode(projectCode);
// check user access for project
Map<String, Object> result =
Expand Down Expand Up @@ -655,7 +654,7 @@ public Map<String, Object> updateProcessInstance(User loginUser, long projectCod
timezoneId = commandParamMap.get(Constants.SCHEDULE_TIMEZONE);
}

setProcessInstance(processInstance, tenantCode, scheduleTime, globalParams, timeout, timezoneId);
setProcessInstance(processInstance, scheduleTime, globalParams, timeout, timezoneId);
List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class);
if (taskDefinitionLogs.isEmpty()) {
log.warn("Parameter taskDefinitionJson is empty");
Expand Down Expand Up @@ -736,7 +735,7 @@ public Map<String, Object> updateProcessInstance(User loginUser, long projectCod
/**
* update process instance attributes
*/
private void setProcessInstance(ProcessInstance processInstance, String tenantCode, String scheduleTime,
private void setProcessInstance(ProcessInstance processInstance, String scheduleTime,
String globalParams, int timeout, String timezone) {
Date schedule = processInstance.getScheduleTime();
if (scheduleTime != null) {
Expand All @@ -749,7 +748,6 @@ private void setProcessInstance(ProcessInstance processInstance, String tenantCo
globalParams = curingGlobalParamsService.curingGlobalParams(processInstance.getId(), globalParamMap,
globalParamList, processInstance.getCmdTypeIfComplement(), schedule, timezone);
processInstance.setTimeout(timeout);
processInstance.setTenantCode(tenantCode);
processInstance.setGlobalParams(globalParams);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testUpdateProcessInstance() throws Exception {
Mockito.when(processInstanceService
.updateProcessInstance(Mockito.any(), Mockito.anyLong(), Mockito.anyInt(), Mockito.anyString(),
Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(),
Mockito.anyString(), Mockito.anyInt(), Mockito.anyString()))
Mockito.anyString(), Mockito.anyInt()))
.thenReturn(mockResult);

String json =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ public void testUpdateProcessInstance() {
when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(loginUser, project, projectCode, INSTANCE_UPDATE)).thenReturn(result);
Map<String, Object> projectAuthFailRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1,
shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0, "");
shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0);
Assertions.assertEquals(Status.PROJECT_NOT_FOUND, projectAuthFailRes.get(Constants.STATUS));

// process instance null
Expand All @@ -566,15 +566,15 @@ public void testUpdateProcessInstance() {
when(processService.findProcessInstanceDetailById(1)).thenReturn(Optional.empty());
Assertions.assertThrows(ServiceException.class, () -> {
processInstanceService.updateProcessInstance(loginUser, projectCode, 1,
shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0, "");
shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0);
});
// process instance not finish
when(processService.findProcessInstanceDetailById(1)).thenReturn(Optional.ofNullable(processInstance));
processInstance.setState(WorkflowExecutionStatus.RUNNING_EXECUTION);
putMsg(result, Status.SUCCESS, projectCode);
Map<String, Object> processInstanceNotFinishRes =
processInstanceService.updateProcessInstance(loginUser, projectCode, 1,
shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0, "");
shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0);
Assertions.assertEquals(Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR,
processInstanceNotFinishRes.get(Constants.STATUS));

Expand Down Expand Up @@ -602,7 +602,7 @@ public void testUpdateProcessInstance() {
when(taskPluginManager.checkTaskParameters(Mockito.any())).thenReturn(true);
Map<String, Object> processInstanceFinishRes =
processInstanceService.updateProcessInstance(loginUser, projectCode, 1,
taskRelationJson, taskDefinitionJson, "2020-02-21 00:00:00", true, "", "", 0, "root");
taskRelationJson, taskDefinitionJson, "2020-02-21 00:00:00", true, "", "", 0);
Assertions.assertEquals(Status.SUCCESS, processInstanceFinishRes.get(Constants.STATUS));

// success
Expand All @@ -612,7 +612,7 @@ public void testUpdateProcessInstance() {
when(processService.saveProcessDefine(loginUser, processDefinition, Boolean.FALSE, Boolean.FALSE))
.thenReturn(1);
Map<String, Object> successRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1,
taskRelationJson, taskDefinitionJson, "2020-02-21 00:00:00", Boolean.FALSE, "", "", 0, "root");
taskRelationJson, taskDefinitionJson, "2020-02-21 00:00:00", Boolean.FALSE, "", "", 0);
Assertions.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
}

Expand Down

0 comments on commit cc36c5b

Please sign in to comment.