feat(flow+gateway): by-key 取最新版源 XML(修 process-select options=model 语义缺口)
live 验收发现:/api/process-select/options 在本库 143 项全部 source='model',
option.id=act_re_model id(非 procDefId)→ by-id source 端点永远 found:false;
option.key 才是真流程 key。补 by-key 姊妹端点,打开器改用 key 载入。
- flowable-service ProcessDiagramController:
+ GET /api/flow/process-definitions/by-key/{key}/source
(processDefinitionKey(key).latestVersion().singleResult(),null→found:false)。
by-id 与 by-key 逻辑抽共享私有 sourceResponse(procDefId, def),不复制粘贴;
by-id 行为不变(仍以入参 procDefId 读部署 BPMN,既有 7 测试零修改)。
- 网关:FlowableClient.procDefSourceByKey(key)(uri 变量严格编码,禁拼接)
+ ProcessModelerController GET /api/workflow/process-definitions/by-key/{key}/source
(同超管门,非超管 403)。by-id/by-key 段数不同无路由歧义。
测试(mvn -pl flowable-service,platform-flow-gateway,platform-auth -am test 全绿,既有零修改):
- ProcessDiagramControllerTest 7→9(+2:by-key 命中取最新版 v2 净化XML+idMap / key 不存在 found:false)
- FlowableClientTest 11→12(+1:纯中文 key「总包合同交底」uri 变量严格编码,断言 %E6%80%BB 且无裸中文)
- ProcessModelerControllerTest 4→6(+2:by-key 超管 200 透传 / 非超管 403 不触发下游)
- 三模块 Reactor 均 SUCCESS。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -198,6 +198,50 @@ class ProcessDiagramControllerTest {
|
||||
.andExpect(jsonPath("$.found").value(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sourceByKey_按key命中返最新版净化XML与idMap及版本() throws Exception {
|
||||
// process-select options 的 source='model' 项 id 是 act_re_model id(非 procDefId),by-id 永远 found:false;
|
||||
// 打开器改用 option.key(真流程 key)走本端点。latestVersion() 在两版本(v1/v2)里取 v2。
|
||||
ProcessDefinition v2 = org.mockito.Mockito.mock(ProcessDefinition.class);
|
||||
when(v2.getId()).thenReturn("总包合同交底:2:aa22");
|
||||
when(v2.getKey()).thenReturn("总包合同交底");
|
||||
when(v2.getVersion()).thenReturn(2);
|
||||
when(repositoryService.createProcessDefinitionQuery()).thenReturn(processDefinitionQuery);
|
||||
when(processDefinitionQuery.processDefinitionKey("总包合同交底")).thenReturn(processDefinitionQuery);
|
||||
when(processDefinitionQuery.latestVersion()).thenReturn(processDefinitionQuery);
|
||||
when(processDefinitionQuery.singleResult()).thenReturn(v2);
|
||||
|
||||
String xml = "<definitions>"
|
||||
+ "<process id=\"总包合同交底\" name=\"总包合同交底\">"
|
||||
+ "<userTask id=\"sid-A\"/>"
|
||||
+ "<sequenceFlow id=\"f1\" sourceRef=\"总包合同交底\" targetRef=\"sid-A\"/>"
|
||||
+ "</process></definitions>";
|
||||
when(repositoryService.getProcessModel("总包合同交底:2:aa22"))
|
||||
.thenReturn(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
|
||||
|
||||
mvc.perform(get("/api/flow/process-definitions/by-key/{key}/source", "总包合同交底"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.found").value(true))
|
||||
.andExpect(jsonPath("$.procDefId").value("总包合同交底:2:aa22"))
|
||||
.andExpect(jsonPath("$.procDefKey").value("总包合同交底"))
|
||||
.andExpect(jsonPath("$.version").value(2))
|
||||
.andExpect(jsonPath("$.idMap['总包合同交底']").isNotEmpty())
|
||||
.andExpect(jsonPath("$.bpmnXml",
|
||||
org.hamcrest.Matchers.not(org.hamcrest.Matchers.containsString("id=\"总包合同交底\""))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sourceByKey_key不存在返found_false() throws Exception {
|
||||
when(repositoryService.createProcessDefinitionQuery()).thenReturn(processDefinitionQuery);
|
||||
when(processDefinitionQuery.processDefinitionKey("无此流程")).thenReturn(processDefinitionQuery);
|
||||
when(processDefinitionQuery.latestVersion()).thenReturn(processDefinitionQuery);
|
||||
when(processDefinitionQuery.singleResult()).thenReturn(null);
|
||||
|
||||
mvc.perform(get("/api/flow/process-definitions/by-key/{key}/source", "无此流程"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.found").value(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void source_读取XML异常返found_false不抛500() throws Exception {
|
||||
ProcessDefinition def = org.mockito.Mockito.mock(ProcessDefinition.class);
|
||||
|
||||
Reference in New Issue
Block a user