Пример #1
0
        // variableOnParts
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void sentryTransformWithVariableOnPart()
        public virtual void sentryTransformWithVariableOnPart()
        {
            // given
            ExtensionElements     extensionElements = createElement(sentry, "extensionElements", typeof(ExtensionElements));
            CamundaVariableOnPart variableOnPart    = createElement(extensionElements, null, typeof(CamundaVariableOnPart));

            createElement(variableOnPart, null, typeof(CamundaVariableTransitionEvent));
            variableOnPart.VariableEvent = VariableTransition.create;
            variableOnPart.VariableName  = "aVariable";

            CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);

            // then
            assertNotNull(sentryDeclaration);
            IList <CmmnVariableOnPartDeclaration> variableOnParts = sentryDeclaration.VariableOnParts;

            assertNotNull(variableOnParts);
            assertFalse(variableOnParts.Count == 0);
            assertEquals(1, variableOnParts.Count);

            CmmnVariableOnPartDeclaration transformedVariableOnPart = variableOnParts[0];

            assertEquals("aVariable", transformedVariableOnPart.VariableName);
            assertEquals(VariableTransition.create.name(), transformedVariableOnPart.VariableEvent);
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void sentryTransformWithMultipleVariableEvent()
        public virtual void sentryTransformWithMultipleVariableEvent()
        {
            // given
            ExtensionElements              extensionElements = createElement(sentry, "extensionElements", typeof(ExtensionElements));
            CamundaVariableOnPart          variableOnPart    = createElement(extensionElements, null, typeof(CamundaVariableOnPart));
            CamundaVariableTransitionEvent transitionEvent   = createElement(variableOnPart, null, typeof(CamundaVariableTransitionEvent));

            transitionEvent.TextContent = "create";
            CamundaVariableTransitionEvent additionalTransitionEvent = createElement(variableOnPart, null, typeof(CamundaVariableTransitionEvent));

            additionalTransitionEvent.TextContent = "delete";
            variableOnPart.VariableName           = "aVariable";

            CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);

            // then
            assertNotNull(sentryDeclaration);
            IList <CmmnVariableOnPartDeclaration> variableOnParts = sentryDeclaration.VariableOnParts;

            assertNotNull(variableOnParts);
            assertFalse(variableOnParts.Count == 0);
            assertEquals(1, variableOnParts.Count);

            CmmnVariableOnPartDeclaration transformedVariableOnPart = variableOnParts[0];

            assertEquals("aVariable", transformedVariableOnPart.VariableName);
            // when there are multiple variable events then, only first variable event is considered.
            assertEquals(VariableTransition.create.name(), transformedVariableOnPart.VariableEvent);
        }
Пример #3
0
        protected internal virtual void initializeVariableOnPart(CamundaVariableOnPart variableOnPart, CmmnSentryDeclaration sentryDeclaration, CmmnHandlerContext context)
        {
            VariableTransition variableTransition;

            try
            {
                variableTransition = variableOnPart.VariableEvent;
            }
            catch (System.ArgumentException)
            {
                throw LOG.nonMatchingVariableEvents(sentryDeclaration.Id);
            }
            catch (System.NullReferenceException)
            {
                throw LOG.nonMatchingVariableEvents(sentryDeclaration.Id);
            }

            string variableName      = variableOnPart.VariableName;
            string variableEventName = variableTransition.name();

            if (!string.ReferenceEquals(variableName, null))
            {
                if (!sentryDeclaration.hasVariableOnPart(variableEventName, variableName))
                {
                    CmmnVariableOnPartDeclaration variableOnPartDeclaration = new CmmnVariableOnPartDeclaration();
                    variableOnPartDeclaration.VariableEvent = variableEventName;
                    variableOnPartDeclaration.VariableName  = variableName;
                    sentryDeclaration.addVariableOnParts(variableOnPartDeclaration);
                }
            }
            else
            {
                throw LOG.emptyVariableName(sentryDeclaration.Id);
            }
        }