feat: wire process form removal actions

This commit is contained in:
2026-06-18 08:55:17 +08:00
parent d82ef94da8
commit 1d8a4fec60
8 changed files with 225 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Date;
import org.flowable.engine.HistoryService;
import org.flowable.engine.IdentityService;
import org.flowable.engine.RepositoryService;
@@ -119,6 +121,41 @@ class FlowControllerTest {
verify(runtimeService).activateProcessInstanceById("pi-3");
}
@Test
void 删除已结束历史流程实例_转调historyDelete() throws Exception {
when(runtimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
when(processInstanceQuery.processInstanceId("PI-DONE")).thenReturn(processInstanceQuery);
when(processInstanceQuery.singleResult()).thenReturn(null);
HistoricProcessInstance hpi = org.mockito.Mockito.mock(HistoricProcessInstance.class);
when(hpi.getBusinessKey()).thenReturn("BK-DONE");
when(hpi.getEndTime()).thenReturn(new Date());
when(historyService.createHistoricProcessInstanceQuery()).thenReturn(historicProcessInstanceQuery);
when(historicProcessInstanceQuery.processInstanceId("PI-DONE")).thenReturn(historicProcessInstanceQuery);
when(historicProcessInstanceQuery.singleResult()).thenReturn(hpi);
mvc.perform(post("/api/flow/process/PI-DONE/delete-history"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.deleted").value(true))
.andExpect(jsonPath("$.businessKey").value("BK-DONE"));
verify(historyService).deleteHistoricProcessInstance("PI-DONE");
}
@Test
void 删除运行中流程实例_拒绝且不删历史() throws Exception {
ProcessInstance pi = org.mockito.Mockito.mock(ProcessInstance.class);
when(runtimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
when(processInstanceQuery.processInstanceId("PI-RUN")).thenReturn(processInstanceQuery);
when(processInstanceQuery.singleResult()).thenReturn(pi);
mvc.perform(post("/api/flow/process/PI-RUN/delete-history"))
.andExpect(status().isConflict())
.andExpect(jsonPath("$.msg").value("流程未结束,不能删除审批表单"));
verify(historyService, never()).deleteHistoricProcessInstance(anyString());
}
@Test
void 撤回流程_移动回起始节点并挂起实例() throws Exception {
Task task = org.mockito.Mockito.mock(Task.class);