Ejemplo n.º 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]);
        }
Ejemplo n.º 2
0
        protected internal virtual FixedValue getFixedValue(CamundaField field)
        {
            CamundaString strg = field.CamundaString;

            string value = null;

            if (strg != null)
            {
                value = strg.TextContent;
            }

            if (string.ReferenceEquals(value, null))
            {
                value = field.CamundaStringValue;
            }

            if (!string.ReferenceEquals(value, null))
            {
                return(new FixedValue(value));
            }

            return(null);
        }
Ejemplo n.º 3
0
        protected internal virtual Expression getExpressionValue(CamundaField field, ExpressionManager expressionManager)
        {
            CamundaExpression expression = field.CamundaExpressionChild;

            string value = null;

            if (expression != null)
            {
                value = expression.TextContent;
            }

            if (string.ReferenceEquals(value, null))
            {
                value = field.CamundaExpression;
            }

            if (!string.ReferenceEquals(value, null))
            {
                return(expressionManager.createExpression(value));
            }

            return(null);
        }
Ejemplo n.º 4
0
        protected internal virtual FieldDeclaration initializeFieldDeclaration(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaField field)
        {
            string name = field.CamundaName;
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            string type = typeof(Expression).FullName;

            object value = getFixedValue(field);

            if (value == null)
            {
                ExpressionManager expressionManager = context.ExpressionManager;
                value = getExpressionValue(field, expressionManager);
            }

            return(new FieldDeclaration(name, type, value));
        }