diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java index 463ff28aa45..14457bf375c 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java @@ -1607,7 +1607,7 @@ protected void processCreatedEventSubProcess(EventSubProcess eventSubProcess, Ex BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(eventSubProcessExecution.getProcessDefinitionId()); Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef()); if (signal != null) { - signalEventDefinition.setSignalRef(signal.getName()); + signalEventDefinition.setSignalRef(signal.getId()); } ExecutionEntity signalExecution = processEngineConfiguration.getExecutionEntityManager().createChildExecution(eventSubProcessExecution.getParent()); diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java index d50533f862a..97071b2032c 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java @@ -454,7 +454,7 @@ protected void handleSignalEventSubscription(EventDefinition eventDefinition, St BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(parentExecution.getProcessDefinitionId()); Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef()); if (signal != null) { - signalEventDefinition.setSignalRef(signal.getName()); + signalEventDefinition.setSignalRef(signal.getId()); } ExecutionEntity signalExecution = processEngineConfiguration.getExecutionEntityManager().createChildExecution(parentExecution); diff --git a/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/runtime/migration/ProcessInstanceMigrationEventSubProcessTest.java b/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/runtime/migration/ProcessInstanceMigrationEventSubProcessTest.java index e9eb62e6800..e6f51a43803 100644 --- a/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/runtime/migration/ProcessInstanceMigrationEventSubProcessTest.java +++ b/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/runtime/migration/ProcessInstanceMigrationEventSubProcessTest.java @@ -58,6 +58,41 @@ protected void tearDown() { deleteDeployments(); } + @Test + public void testSignalScope_WhenSignalIdNotEqualSignalName_GivenMultiInstanceMigration(){ + //create process Definition + ProcessDefinition originalProcessDef = deployProcessDefinition("mainProcessDeployment", + "org/flowable/engine/test/api/runtime/migration/originalProcess.bpmn"); + + ProcessDefinition migrationProcessDef = deployProcessDefinition("mainProcessDeployment", + "org/flowable/engine/test/api/runtime/migration/migrationProcess.bpmn"); + + //create multi-proc instances + ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(originalProcessDef.getKey()); + ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey(originalProcessDef.getKey()); + + //choose a migration state + ProcessInstanceMigrationBuilder processInstanceMigrationBuilder = processMigrationService.createProcessInstanceMigrationBuilder() + .migrateToProcessDefinition(migrationProcessDef.getId()) + .addActivityMigrationMapping(ActivityMigrationMapping.createMappingFor("userTask", "userTask")) + .addActivityMigrationMapping(ActivityMigrationMapping.createMappingFor("sendSignalTask", "subProcessTask")); + + + ProcessInstanceMigrationValidationResult processInstanceMigrationValidationResult = processInstanceMigrationBuilder + .validateMigration(processInstance.getId()); + + assertThat(processInstanceMigrationValidationResult.isMigrationValid()).isTrue(); + + //migration + processInstanceMigrationBuilder.migrate(processInstance.getId()); + processInstanceMigrationBuilder.migrate(processInstance2.getId()); + + List currentSubscriptionList = runtimeService.createEventSubscriptionQuery().list(); + assertThat(currentSubscriptionList).extracting(EventSubscription::getConfiguration).doesNotContainNull(); + + + } + @Test public void testMigrateSimpleActivityToActivityInsideSignalEventSubProcessInNewDefinition() { ProcessDefinition procDefOneTask = deployProcessDefinition("my deploy", diff --git a/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/event/signal/SignalEventTest.java b/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/event/signal/SignalEventTest.java index f00977674c8..d725840580c 100644 --- a/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/event/signal/SignalEventTest.java +++ b/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/event/signal/SignalEventTest.java @@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.tuple; import static org.assertj.core.data.MapEntry.entry; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; @@ -43,12 +44,43 @@ import org.flowable.validation.validator.Problems; import org.junit.jupiter.api.Test; + + + /** * @author Tijs Rademakers * @author Joram Barrez */ public class SignalEventTest extends PluggableFlowableTestCase { + + @Test + @Deployment(resources = {"org/flowable/engine/test/bpmn/event/signal/mainProcessV2.bpmn"}) + public void testSignalScope_WhenSignalIdNotEqualSignalName_GivenMultipleProcessInstances() { + + List processInstances = new ArrayList<>(); + processInstances.add(runtimeService.startProcessInstanceByKey("mainProcess")); + processInstances.add(runtimeService.startProcessInstanceByKey("mainProcess")); + processInstances.add(runtimeService.startProcessInstanceByKey("mainProcess")); + + List currentSubscriptionList = runtimeService.createEventSubscriptionQuery().list(); + + assertThat(currentSubscriptionList).hasSize(processInstances.size()); + assertThat(currentSubscriptionList).extracting(EventSubscription::getConfiguration).doesNotContainNull(); + } + + @Test + @Deployment(resources = {"org/flowable/engine/test/bpmn/event/signal/mainProcessV2.bpmn"}) + public void testSignalScope_WhenSignalIdNotEqualSignalName_GivenSingleProcessInstance() { + + ProcessInstance processInstances = runtimeService.startProcessInstanceByKey("mainProcess"); + + List currentSubscriptionList = runtimeService.createEventSubscriptionQuery().list(); + + assertThat(currentSubscriptionList).hasSize(1); + assertThat(currentSubscriptionList).extracting(EventSubscription::getConfiguration).doesNotContainNull(); + } + @Test @Deployment(resources = { "org/flowable/engine/test/bpmn/event/signal/SignalEventTests.catchAlertSignal.bpmn20.xml", "org/flowable/engine/test/bpmn/event/signal/SignalEventTests.throwAlertSignal.bpmn20.xml" }) diff --git a/modules/flowable-engine/src/test/resources/org/flowable/engine/test/api/runtime/migration/migrationProcess.bpmn b/modules/flowable-engine/src/test/resources/org/flowable/engine/test/api/runtime/migration/migrationProcess.bpmn new file mode 100644 index 00000000000..bc546b11132 --- /dev/null +++ b/modules/flowable-engine/src/test/resources/org/flowable/engine/test/api/runtime/migration/migrationProcess.bpmn @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/flowable-engine/src/test/resources/org/flowable/engine/test/api/runtime/migration/originalProcess.bpmn b/modules/flowable-engine/src/test/resources/org/flowable/engine/test/api/runtime/migration/originalProcess.bpmn new file mode 100644 index 00000000000..c0348c5b0d6 --- /dev/null +++ b/modules/flowable-engine/src/test/resources/org/flowable/engine/test/api/runtime/migration/originalProcess.bpmn @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/flowable-engine/src/test/resources/org/flowable/engine/test/bpmn/event/signal/mainProcessV2.bpmn b/modules/flowable-engine/src/test/resources/org/flowable/engine/test/bpmn/event/signal/mainProcessV2.bpmn new file mode 100644 index 00000000000..6f06ac4a5d4 --- /dev/null +++ b/modules/flowable-engine/src/test/resources/org/flowable/engine/test/bpmn/event/signal/mainProcessV2.bpmn @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file