Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #862: Made start form key retrieval more robust #864

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ class ProcessDefinitionService(
this.processDefinitions.clear()
}
this.processDefinitions.addAll(newDefinitions)
return newDefinitions.map { it.asCommand(applicationName = collectorProperties.applicationName, formKey = formService.getStartFormKey(it.id)) }
return newDefinitions.map { it.asCommand(applicationName = collectorProperties.applicationName, formKey = getStartFormKey(it, formService)) }
}

private fun getStartFormKey(processDefinitionEntity: ProcessDefinitionEntity, formService: FormService): String? {
return if (processDefinitionEntity.hasStartFormKey) {
formService.getStartFormKey(processDefinitionEntity.id)
} else {
null
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,52 @@ class ProcessDefinitionServiceITest {
assertThat(definitions[0].candidateStarterGroups).containsExactlyElementsOf(listOf("muppetshow"))
}

@Test
fun `should not deliver process starter if no start form is available`() {

val processId = "my-id"
val startEventId = "start"
val modelInstance = Bpmn
.createExecutableProcess(processId)
.startEvent(startEventId)
.endEvent("end")
.done().apply {
getModelElementById<ModelElementInstance>(processId).setAttributeValue("name", "My Process")
getModelElementById<ModelElementInstance>(processId).setAttributeValueNs(NS_CAMUNDA, "candidateStarterGroups", "muppetshow")
}

repositoryService
.createDeployment()
.addModelInstance("process-without-start-form.bpmn", modelInstance)
.deploy()


val definitions = processDefinitionService.getProcessDefinitions(processEngine.processEngineConfiguration as ProcessEngineConfigurationImpl)

assertThat(definitions).isNotEmpty
assertThat(definitions[0].processName).isEqualTo("My Process")
assertThat(definitions[0].processDefinitionKey).isEqualTo("my-id")
assertThat(definitions[0].processDefinitionVersion).isEqualTo(1)
assertThat(definitions[0].formKey).isNull()
assertThat(definitions[0].candidateStarterGroups).containsExactlyElementsOf(listOf("muppetshow"))
}

@Test
fun `should not deliver process starter if only two message start events are available`() {
repositoryService
.createDeployment()
.addClasspathResource("itest/message_start_event.bpmn")
.deploy()

val definitions = processDefinitionService.getProcessDefinitions(processEngine.processEngineConfiguration as ProcessEngineConfigurationImpl)

assertThat(definitions).isNotEmpty
assertThat(definitions[0].processName).isEqualTo("My Process")
assertThat(definitions[0].processDefinitionKey).isEqualTo("my-id")
assertThat(definitions[0].processDefinitionVersion).isEqualTo(1)
assertThat(definitions[0].formKey).isNull()
}

/**
* Internal test application.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0xgy7na" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.10.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
<bpmn:process id="my-id" name="My Process" isExecutable="true" camunda:historyTimeToLive="0">
<bpmn:endEvent id="Event_0b6e9a9">
<bpmn:incoming>Flow_0rqm55e</bpmn:incoming>
<bpmn:incoming>Flow_1k4xpiz</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0rqm55e" sourceRef="StartEvent_1" targetRef="Event_0b6e9a9" />
<bpmn:sequenceFlow id="Flow_1k4xpiz" sourceRef="Event_0tam437" targetRef="Event_0b6e9a9" />
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_0rqm55e</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_1nlj1v7" messageRef="Message_2t2ssos" />
</bpmn:startEvent>
<bpmn:startEvent id="Event_0tam437">
<bpmn:outgoing>Flow_1k4xpiz</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_1ft2zip" messageRef="Message_22tfs8s" />
</bpmn:startEvent>
</bpmn:process>
<bpmn:message id="Message_2t2ssos" name="start_message" />
<bpmn:message id="Message_22tfs8s" name="another_message" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="my-id">
<bpmndi:BPMNShape id="Event_0b6e9a9_di" bpmnElement="Event_0b6e9a9">
<dc:Bounds x="272" y="79" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0qcrckj_di" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="79" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_02sa6i2_di" bpmnElement="Event_0tam437">
<dc:Bounds x="179" y="152" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0rqm55e_di" bpmnElement="Flow_0rqm55e">
<di:waypoint x="215" y="97" />
<di:waypoint x="272" y="97" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1k4xpiz_di" bpmnElement="Flow_1k4xpiz">
<di:waypoint x="215" y="170" />
<di:waypoint x="244" y="170" />
<di:waypoint x="244" y="97" />
<di:waypoint x="272" y="97" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>