Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testReceiveTaskMessageCorrelation()
        public virtual void testReceiveTaskMessageCorrelation()
        {
            //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", "someValue").userTask("UserTask_1").endEvent().subProcessDone().multiInstance().camundaCollection("${vars}").camundaElementVariable("loopVar").multiInstanceDone().endEvent().done();

            testHelper.deploy(model);

            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["vars"] = Arrays.asList(1, 2, 3);
            ProcessInstance processInstance = engineRule.RuntimeService.startProcessInstanceByKey("Process_1", variables);

            //when correlated by local variables
            string messageName = TEST_MESSAGE_NAME;
            IDictionary <string, object> correlationKeys = new Dictionary <string, object>();
            int correlationKey = 1;

            correlationKeys["localVar"] = correlationKey;
            correlationKeys["constVar"] = "someValue";

            MessageCorrelationResult messageCorrelationResult = engineRule.RuntimeService.createMessageCorrelation(messageName).localVariablesEqual(correlationKeys).setVariables(Variables.createVariables().putValue("newVar", "newValue")).correlateWithResult();

            //then one message is correlated, two other continue waiting
            checkExecutionMessageCorrelationResult(messageCorrelationResult, processInstance, "MessageReceiver_1");

            //uncorrelated executions
            IList <Execution> uncorrelatedExecutions = engineRule.RuntimeService.createExecutionQuery().activityId("MessageReceiver_1").list();

            assertEquals(2, uncorrelatedExecutions.Count);
        }
Example #2
0
        public virtual ProcessInstance correlateStartMessage()
        {
            startMessageOnly();
            MessageCorrelationResult result = correlateWithResult();

            return(result.ProcessInstance);
        }
Example #3
0
        protected internal virtual void checkExecutionMessageCorrelationResult(MessageCorrelationResult result, ProcessInstance processInstance, string activityId)
        {
            assertNotNull(result);
            assertEquals(MessageCorrelationResultType.Execution, result.ResultType);
            assertEquals(processInstance.Id, result.Execution.ProcessInstanceId);
            ExecutionEntity entity = (ExecutionEntity)result.Execution;

            assertEquals(activityId, entity.ActivityId);
        }
Example #4
0
        private void createMessageCorrelationBuilderMock()
        {
            mockMessageCorrelationBuilder = mock(typeof(MessageCorrelationBuilder));
            mockMessageCorrelationResult  = mock(typeof(MessageCorrelationResult));

            when(mockRuntimeService.createMessageCorrelation(anyString())).thenReturn(mockMessageCorrelationBuilder);
            when(mockMessageCorrelationBuilder.correlateWithResult()).thenReturn(mockMessageCorrelationResult);
            when(mockMessageCorrelationBuilder.processInstanceId(anyString())).thenReturn(mockMessageCorrelationBuilder);
            when(mockMessageCorrelationBuilder.processInstanceBusinessKey(anyString())).thenReturn(mockMessageCorrelationBuilder);
            when(mockMessageCorrelationBuilder.processInstanceVariableEquals(anyString(), any())).thenReturn(mockMessageCorrelationBuilder);
            when(mockMessageCorrelationBuilder.setVariables(Matchers.any <IDictionary <string, object> >())).thenReturn(mockMessageCorrelationBuilder);
            when(mockMessageCorrelationBuilder.setVariable(anyString(), any())).thenReturn(mockMessageCorrelationBuilder);
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBothInstanceAndLocalVariableMessageCorrelation()
        public virtual void testBothInstanceAndLocalVariableMessageCorrelation()
        {
            //given
            BpmnModelInstance model = Bpmn.createExecutableProcess("Process_1").startEvent().subProcess("SubProcess_1").embeddedSubProcess().startEvent().receiveTask("MessageReceiver_1").message(TEST_MESSAGE_NAME).userTask("UserTask_1").endEvent().subProcessDone().multiInstance().camundaCollection("${vars}").camundaElementVariable("loopVar").multiInstanceDone().endEvent().done();

            model = modify(model).activityBuilder("MessageReceiver_1").camundaInputParameter("localVar", "${loopVar}").camundaInputParameter("constVar", "someValue").done();

            testHelper.deploy(model);

            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["vars"] = Arrays.asList(1, 2, 3);
            variables["processInstanceVar"] = "processInstanceVarValue";
            ProcessInstance processInstance = engineRule.RuntimeService.startProcessInstanceByKey("Process_1", variables);

            //second process instance with another process instance variable value
            variables         = new Dictionary <string, object>();
            variables["vars"] = Arrays.asList(1, 2, 3);
            variables["processInstanceVar"] = "anotherProcessInstanceVarValue";
            engineRule.RuntimeService.startProcessInstanceByKey("Process_1", variables);

            //when correlated by local variables
            string messageName = TEST_MESSAGE_NAME;
            IDictionary <string, object> correlationKeys = new Dictionary <string, object>();
            int correlationKey = 1;

            correlationKeys["localVar"] = correlationKey;
            correlationKeys["constVar"] = "someValue";
            IDictionary <string, object> processInstanceKeys = new Dictionary <string, object>();
            string processInstanceVarValue = "processInstanceVarValue";

            processInstanceKeys["processInstanceVar"] = processInstanceVarValue;
            IDictionary <string, object> messagePayload = new Dictionary <string, object>();

            messagePayload["newVar"] = "newValue";

            MessageCorrelationResult messageCorrelationResult = engineRule.RuntimeService.createMessageCorrelation(messageName).processInstanceVariablesEqual(processInstanceKeys).localVariablesEqual(correlationKeys).setVariables(messagePayload).correlateWithResult();

            //then exactly one message is correlated = one receive task is passed by, two + three others continue waiting
            checkExecutionMessageCorrelationResult(messageCorrelationResult, processInstance, "MessageReceiver_1");

            //uncorrelated executions
            IList <Execution> uncorrelatedExecutions = engineRule.RuntimeService.createExecutionQuery().activityId("MessageReceiver_1").list();

            assertEquals(5, uncorrelatedExecutions.Count);
        }
Example #6
0
 public virtual IList <MessageCorrelationResult> correlateAllWithResult()
 {
     if (startMessagesOnly)
     {
         ensureCorrelationVariablesNotSet();
         ensureProcessDefinitionAndTenantIdNotSet();
         // only one result can be expected
         MessageCorrelationResult result = execute(new CorrelateMessageCmd(this, false, false, startMessagesOnly));
         return(Arrays.asList(result));
     }
     else
     {
         ensureProcessDefinitionIdNotSet();
         ensureProcessInstanceAndTenantIdNotSet();
         return((System.Collections.IList)execute(new CorrelateAllMessageCmd(this, false, false)));
     }
 }
Example #7
0
        protected internal virtual IList <MessageCorrelationResultDto> correlate(CorrelationMessageDto messageDto, MessageCorrelationBuilder correlation)
        {
            IList <MessageCorrelationResultDto> resultDtos = new List <MessageCorrelationResultDto>();

            if (!messageDto.All)
            {
                MessageCorrelationResult result = correlation.correlateWithResult();
                resultDtos.Add(MessageCorrelationResultDto.fromMessageCorrelationResult(result));
            }
            else
            {
                IList <MessageCorrelationResult> results = correlation.correlateAllWithResult();
                foreach (MessageCorrelationResult result in results)
                {
                    resultDtos.Add(MessageCorrelationResultDto.fromMessageCorrelationResult(result));
                }
            }
            return(resultDtos);
        }