Search in sources :

Example 6 with MismatchingMessageCorrelationException

use of org.camunda.bpm.engine.MismatchingMessageCorrelationException in project camunda-bpm-platform by camunda.

the class ReceiveTaskTest method testNotSupportsCorrelateMessageOnParallelMultiReceiveTask.

@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTask.bpmn20.xml")
public void testNotSupportsCorrelateMessageOnParallelMultiReceiveTask() {
    // given: a process instance waiting in two receive tasks
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
    // expect: there are two message event subscriptions
    List<EventSubscription> subscriptions = getEventSubscriptionList();
    assertEquals(2, subscriptions.size());
    // then: we can not correlate an event
    try {
        runtimeService.correlateMessage(subscriptions.get(0).getEventName());
        fail("should throw a mismatch");
    } catch (MismatchingMessageCorrelationException e) {
    // expected
    }
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) MismatchingMessageCorrelationException(org.camunda.bpm.engine.MismatchingMessageCorrelationException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with MismatchingMessageCorrelationException

use of org.camunda.bpm.engine.MismatchingMessageCorrelationException in project camunda-bpm-platform by camunda.

the class MessageCorrelationTest method testFailCorrelateMessageStartEventWithWrongProcessDefinitionId.

@Test
public void testFailCorrelateMessageStartEventWithWrongProcessDefinitionId() {
    testRule.deploy(Bpmn.createExecutableProcess("process").startEvent().message("a").userTask().endEvent().done());
    testRule.deploy(Bpmn.createExecutableProcess("process").startEvent().message("b").userTask().endEvent().done());
    ProcessDefinition latestProcessDefinition = repositoryService.createProcessDefinitionQuery().latestVersion().singleResult();
    try {
        runtimeService.createMessageCorrelation("a").processDefinitionId(latestProcessDefinition.getId()).correlateStartMessage();
        fail("expected exception");
    } catch (MismatchingMessageCorrelationException e) {
        testRule.assertTextPresent("Cannot correlate message 'a'", e.getMessage());
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) MismatchingMessageCorrelationException(org.camunda.bpm.engine.MismatchingMessageCorrelationException) Test(org.junit.Test)

Aggregations

MismatchingMessageCorrelationException (org.camunda.bpm.engine.MismatchingMessageCorrelationException)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 Test (org.junit.Test)3 CorrelationHandler (org.camunda.bpm.engine.impl.runtime.CorrelationHandler)2 CorrelationHandlerResult (org.camunda.bpm.engine.impl.runtime.CorrelationHandlerResult)2 CorrelationSet (org.camunda.bpm.engine.impl.runtime.CorrelationSet)2 RestException (org.camunda.bpm.engine.rest.exception.RestException)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 MessageCorrelationResultDto (org.camunda.bpm.engine.rest.dto.message.MessageCorrelationResultDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 EventSubscription (org.camunda.bpm.engine.runtime.EventSubscription)1 Execution (org.camunda.bpm.engine.runtime.Execution)1 MessageCorrelationBuilder (org.camunda.bpm.engine.runtime.MessageCorrelationBuilder)1 MessageCorrelationResult (org.camunda.bpm.engine.runtime.MessageCorrelationResult)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.anyString (org.mockito.Matchers.anyString)1