use of org.camunda.bpm.engine.runtime.MessageCorrelationResult in project camunda-bpm-platform by camunda.
the class MessageCorrelationByLocalVariablesTest method testReceiveTaskMessageCorrelationAll.
@Test
public void testReceiveTaskMessageCorrelationAll() {
// given
BpmnModelInstance model = Bpmn.createExecutableProcess("Process_1").startEvent().subProcess("SubProcess_1").embeddedSubProcess().startEvent().receiveTask("MessageReceiver_1").message(TEST_MESSAGE_NAME).camundaInputParameter("localVar", "${loopVar}").camundaInputParameter("constVar", // to test array of parameters
"someValue").userTask("UserTask_1").endEvent().subProcessDone().multiInstance().camundaCollection("${vars}").camundaElementVariable("loopVar").multiInstanceDone().endEvent().done();
testHelper.deploy(model);
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("vars", Arrays.asList(1, 2, 1));
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("Process_1", variables);
// when correlated ALL by local variables
String messageName = TEST_MESSAGE_NAME;
Map<String, Object> correlationKeys = new HashMap<String, Object>();
int correlationKey = 1;
correlationKeys.put("localVar", correlationKey);
correlationKeys.put("constVar", "someValue");
List<MessageCorrelationResult> messageCorrelationResults = engineRule.getRuntimeService().createMessageCorrelation(messageName).localVariablesEqual(correlationKeys).setVariables(Variables.createVariables().putValue("newVar", "newValue")).correlateAllWithResult();
// then two messages correlated, one message task is still waiting
for (MessageCorrelationResult result : messageCorrelationResults) {
checkExecutionMessageCorrelationResult(result, processInstance, "MessageReceiver_1");
}
// uncorrelated executions
List<Execution> uncorrelatedExecutions = engineRule.getRuntimeService().createExecutionQuery().activityId("MessageReceiver_1").list();
assertEquals(1, uncorrelatedExecutions.size());
}
use of org.camunda.bpm.engine.runtime.MessageCorrelationResult in project camunda-bpm-platform by camunda.
the class MessageCorrelationByLocalVariablesTest method testMessageBoundaryEventMessageCorrelation.
@Test
public void testMessageBoundaryEventMessageCorrelation() {
// given
BpmnModelInstance model = Bpmn.createExecutableProcess("Process_1").startEvent().subProcess("SubProcess_1").embeddedSubProcess().startEvent().userTask("UserTask_1").camundaInputParameter("localVar", "${loopVar}").camundaInputParameter("constVar", // to test array of parameters
"someValue").boundaryEvent("MessageReceiver_1").message(TEST_MESSAGE_NAME).userTask("UserTask_2").endEvent().subProcessDone().multiInstance().camundaCollection("${vars}").camundaElementVariable("loopVar").multiInstanceDone().endEvent().done();
testHelper.deploy(model);
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("vars", Arrays.asList(1, 2, 3));
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("Process_1", variables);
// when correlated by local variables
String messageName = TEST_MESSAGE_NAME;
Map<String, Object> correlationKeys = new HashMap<String, Object>();
int correlationKey = 1;
correlationKeys.put("localVar", correlationKey);
correlationKeys.put("constVar", "someValue");
Map<String, Object> messagePayload = new HashMap<String, Object>();
messagePayload.put("newVar", "newValue");
MessageCorrelationResult messageCorrelationResult = engineRule.getRuntimeService().createMessageCorrelation(messageName).localVariablesEqual(correlationKeys).setVariables(messagePayload).correlateWithResult();
// then one message is correlated, two others continue waiting
checkExecutionMessageCorrelationResult(messageCorrelationResult, processInstance, "UserTask_1");
// uncorrelated executions
List<Execution> uncorrelatedExecutions = engineRule.getRuntimeService().createExecutionQuery().activityId("UserTask_1").list();
assertEquals(2, uncorrelatedExecutions.size());
}
use of org.camunda.bpm.engine.runtime.MessageCorrelationResult in project camunda-bpm-platform by camunda.
the class MessageCorrelationByLocalVariablesTest method testIntermediateCatchEventMessageCorrelation.
@Test
public void testIntermediateCatchEventMessageCorrelation() {
// given
BpmnModelInstance model = Bpmn.createExecutableProcess("Process_1").startEvent().subProcess("SubProcess_1").embeddedSubProcess().startEvent().intermediateCatchEvent("MessageReceiver_1").message(TEST_MESSAGE_NAME).camundaInputParameter("localVar", "${loopVar}").userTask("UserTask_1").endEvent().subProcessDone().multiInstance().camundaCollection("${vars}").camundaElementVariable("loopVar").multiInstanceDone().endEvent().done();
testHelper.deploy(model);
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("vars", Arrays.asList(1, 2, 3));
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("Process_1", variables);
// when correlated by local variables
String messageName = TEST_MESSAGE_NAME;
int correlationKey = 1;
MessageCorrelationResult messageCorrelationResult = engineRule.getRuntimeService().createMessageCorrelation(messageName).localVariableEquals("localVar", correlationKey).setVariables(Variables.createVariables().putValue("newVar", "newValue")).correlateWithResult();
// then one message is correlated, two others continue waiting
checkExecutionMessageCorrelationResult(messageCorrelationResult, processInstance, "MessageReceiver_1");
// uncorrelated executions
List<Execution> uncorrelatedExecutions = engineRule.getRuntimeService().createExecutionQuery().activityId("MessageReceiver_1").list();
assertEquals(2, uncorrelatedExecutions.size());
}
Aggregations