Search in sources :

Example 6 with MessageCorrelationResult

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;
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Execution(org.camunda.bpm.engine.runtime.Execution) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) MessageCorrelationResult(org.camunda.bpm.engine.runtime.MessageCorrelationResult)

Example 7 with MessageCorrelationResult

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);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) MessageCorrelationResult(org.camunda.bpm.engine.runtime.MessageCorrelationResult) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with MessageCorrelationResult

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");
}
Also used : MessageCorrelationResult(org.camunda.bpm.engine.runtime.MessageCorrelationResult) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with MessageCorrelationResult

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");
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) MessageCorrelationResult(org.camunda.bpm.engine.runtime.MessageCorrelationResult) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 10 with MessageCorrelationResult

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());
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) MessageCorrelationResult(org.camunda.bpm.engine.runtime.MessageCorrelationResult) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

MessageCorrelationResult (org.camunda.bpm.engine.runtime.MessageCorrelationResult)13 Test (org.junit.Test)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)9 Execution (org.camunda.bpm.engine.runtime.Execution)6 HashMap (java.util.HashMap)5 Deployment (org.camunda.bpm.engine.test.Deployment)5 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)5 ArrayList (java.util.ArrayList)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 List (java.util.List)1 MismatchingMessageCorrelationException (org.camunda.bpm.engine.MismatchingMessageCorrelationException)1 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)1 CorrelationHandler (org.camunda.bpm.engine.impl.runtime.CorrelationHandler)1 CorrelationHandlerResult (org.camunda.bpm.engine.impl.runtime.CorrelationHandlerResult)1 CorrelationSet (org.camunda.bpm.engine.impl.runtime.CorrelationSet)1 MessageCorrelationResultDto (org.camunda.bpm.engine.rest.dto.message.MessageCorrelationResultDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 RestException (org.camunda.bpm.engine.rest.exception.RestException)1 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)1 MessageCorrelationBuilder (org.camunda.bpm.engine.runtime.MessageCorrelationBuilder)1