Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testClassDelegateHandling()
        public virtual void testClassDelegateHandling()
        {
            ExtensionElements       extensionElements = SpecUtil.createElement(modelInstance, caseTask, null, typeof(ExtensionElements));
            CamundaVariableListener variableListener  = SpecUtil.createElement(modelInstance, extensionElements, null, typeof(CamundaVariableListener));
            CamundaField            field             = SpecUtil.createElement(modelInstance, variableListener, null, typeof(CamundaField));

            field.CamundaName        = "fieldName";
            field.CamundaStringValue = "a string value";

            variableListener.CamundaClass = "a.class.Name";

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.camunda.bpm.engine.delegate.VariableListener<?>> listeners = activity.getVariableListenersLocal(org.camunda.bpm.engine.delegate.CaseVariableListener_Fields.CREATE);
            IList <VariableListener <object> > listeners = activity.getVariableListenersLocal([email protected]_Fields.CREATE);

            Assert.assertEquals(1, listeners.Count);

            ClassDelegateCaseVariableListener listener = (ClassDelegateCaseVariableListener)listeners[0];

            Assert.assertEquals("a.class.Name", listener.ClassName);
            Assert.assertEquals(1, listener.FieldDeclarations.Count);
            Assert.assertEquals("fieldName", listener.FieldDeclarations[0].Name);
            object fieldValue = listener.FieldDeclarations[0].Value;

            assertTrue(fieldValue is Expression);
            Expression expressionValue = (Expression)fieldValue;

            assertEquals("a string value", expressionValue.ExpressionText);

            Assert.assertEquals(listener, activity.getVariableListenersLocal([email protected]_Fields.UPDATE)[0]);
            Assert.assertEquals(listener, activity.getVariableListenersLocal([email protected]_Fields.DELETE)[0]);
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testExpressionDelegateHandling()
        public virtual void testExpressionDelegateHandling()
        {
            ExtensionElements       extensionElements = SpecUtil.createElement(modelInstance, caseTask, null, typeof(ExtensionElements));
            CamundaVariableListener variableListener  = SpecUtil.createElement(modelInstance, extensionElements, null, typeof(CamundaVariableListener));

            variableListener.CamundaExpression = "${expression}";
            variableListener.CamundaEvent      = [email protected]_Fields.CREATE;

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.camunda.bpm.engine.delegate.VariableListener<?>> listeners = activity.getVariableListenersLocal(org.camunda.bpm.engine.delegate.CaseVariableListener_Fields.CREATE);
            IList <VariableListener <object> > listeners = activity.getVariableListenersLocal([email protected]_Fields.CREATE);

            Assert.assertEquals(1, listeners.Count);

            ExpressionCaseVariableListener listener = (ExpressionCaseVariableListener)listeners[0];

            Assert.assertEquals("${expression}", listener.ExpressionText);

            Assert.assertEquals(0, activity.getVariableListenersLocal([email protected]_Fields.UPDATE).Count);
            Assert.assertEquals(0, activity.getVariableListenersLocal([email protected]_Fields.DELETE).Count);
        }
Пример #3
0
        protected internal virtual CaseVariableListener initializeVariableListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaVariableListener listener)
        {
            ICollection <CamundaField> fields            = listener.CamundaFields;
            IList <FieldDeclaration>   fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);

            ExpressionManager expressionManager = context.ExpressionManager;

            string        className          = listener.CamundaClass;
            string        expression         = listener.CamundaExpression;
            string        delegateExpression = listener.CamundaDelegateExpression;
            CamundaScript scriptElement      = listener.CamundaScript;

            CaseVariableListener variableListener = null;

            if (!string.ReferenceEquals(className, null))
            {
                variableListener = new ClassDelegateCaseVariableListener(className, fieldDeclarations);
            }
            else if (!string.ReferenceEquals(expression, null))
            {
                Expression expressionExp = expressionManager.createExpression(expression);
                variableListener = new ExpressionCaseVariableListener(expressionExp);
            }
            else if (!string.ReferenceEquals(delegateExpression, null))
            {
                Expression delegateExp = expressionManager.createExpression(delegateExpression);
                variableListener = new DelegateExpressionCaseVariableListener(delegateExp, fieldDeclarations);
            }
            else if (scriptElement != null)
            {
                ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
                if (executableScript != null)
                {
                    variableListener = new ScriptCaseVariableListener(executableScript);
                }
            }

            return(variableListener);
        }