use of org.camunda.bpm.engine.runtime.MessageCorrelationResult in project camunda-bpm-platform by camunda.
the class MockProvider method createMessageCorrelationResult.
public static MessageCorrelationResult createMessageCorrelationResult(MessageCorrelationResultType type) {
MessageCorrelationResult result = mock(MessageCorrelationResult.class);
when(result.getResultType()).thenReturn(type);
if (result.getResultType().equals(MessageCorrelationResultType.Execution)) {
Execution ex = createMockExecution();
when(result.getExecution()).thenReturn(ex);
} else {
ProcessInstance instance = createMockInstance();
when(result.getProcessInstance()).thenReturn(instance);
}
return result;
}
use of org.camunda.bpm.engine.runtime.MessageCorrelationResult in project camunda-bpm-platform by camunda.
the class MessageCorrelationTest method testMatchingStartEventAndExecutionCorrelateAllWithResult.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testMatchingStartEventAndExecution.bpmn20.xml" })
@Test
public void testMatchingStartEventAndExecutionCorrelateAllWithResult() {
// given
ProcessInstance procInstance1 = runtimeService.startProcessInstanceByKey("process");
ProcessInstance procInstance2 = runtimeService.startProcessInstanceByKey("process");
// when correlated all with result
List<MessageCorrelationResult> resultList = runtimeService.createMessageCorrelation("newInvoiceMessage").correlateAllWithResult();
// then result should contains three entries
// two of type execution und one of type process definition
assertEquals(3, resultList.size());
int executionResultCount = 0;
int procDefResultCount = 0;
for (MessageCorrelationResult result : resultList) {
if (result.getResultType().equals(MessageCorrelationResultType.Execution)) {
assertNotNull(result);
assertEquals(MessageCorrelationResultType.Execution, result.getResultType());
assertTrue(procInstance1.getId().equalsIgnoreCase(result.getExecution().getProcessInstanceId()) || procInstance2.getId().equalsIgnoreCase(result.getExecution().getProcessInstanceId()));
ExecutionEntity entity = (ExecutionEntity) result.getExecution();
assertEquals("messageCatch", entity.getActivityId());
executionResultCount++;
} else {
checkProcessDefinitionMessageCorrelationResult(result, "theStart", "process");
procDefResultCount++;
}
}
assertEquals(2, executionResultCount);
assertEquals(1, procDefResultCount);
}
use of org.camunda.bpm.engine.runtime.MessageCorrelationResult in project camunda-bpm-platform by camunda.
the class MessageCorrelationTest method testMessageCorrelationResultWithResultTypeProcessDefinition.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testMatchingStartEventAndExecution.bpmn20.xml" })
@Test
public void testMessageCorrelationResultWithResultTypeProcessDefinition() {
// given
String msgName = "newInvoiceMessage";
// when
// correlate message with result
MessageCorrelationResult result = runtimeService.createMessageCorrelation(msgName).correlateWithResult();
// then
// message correlation result contains information from receiver
checkProcessDefinitionMessageCorrelationResult(result, "theStart", "process");
}
use of org.camunda.bpm.engine.runtime.MessageCorrelationResult in project camunda-bpm-platform by camunda.
the class MessageCorrelationTest method testMessageCorrelationResultWithResultTypeExecution.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testMatchingStartEventAndExecution.bpmn20.xml" })
@Test
public void testMessageCorrelationResultWithResultTypeExecution() {
// given
String msgName = "newInvoiceMessage";
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
assertNotNull(runtimeService.createExecutionQuery().messageEventSubscriptionName(msgName).singleResult());
// when
// correlate message with result
MessageCorrelationResult result = runtimeService.createMessageCorrelation(msgName).correlateWithResult();
// then
// message correlation result contains information from receiver
checkExecutionMessageCorrelationResult(result, processInstance, "messageCatch");
}
use of org.camunda.bpm.engine.runtime.MessageCorrelationResult in project camunda-bpm-platform by camunda.
the class MessageCorrelationTest method testMessageCorrelateAllResultListWithResultTypeExecution.
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testCatchingMessageEventCorrelation.bpmn20.xml")
@Test
public void testMessageCorrelateAllResultListWithResultTypeExecution() {
// given
ProcessInstance procInstance1 = runtimeService.startProcessInstanceByKey("process");
ProcessInstance procInstance2 = runtimeService.startProcessInstanceByKey("process");
// when correlated all with result
List<MessageCorrelationResult> resultList = runtimeService.createMessageCorrelation("newInvoiceMessage").correlateAllWithResult();
assertEquals(2, resultList.size());
// then result should contains executions on which messages was correlated
for (MessageCorrelationResult result : resultList) {
assertNotNull(result);
assertEquals(MessageCorrelationResultType.Execution, result.getResultType());
assertTrue(procInstance1.getId().equalsIgnoreCase(result.getExecution().getProcessInstanceId()) || procInstance2.getId().equalsIgnoreCase(result.getExecution().getProcessInstanceId()));
ExecutionEntity entity = (ExecutionEntity) result.getExecution();
assertEquals("messageCatch", entity.getActivityId());
}
}
Aggregations