Esempio n. 1
0
        public virtual void testTransientXmlValue()
        {
            // given
            BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("foo").startEvent().exclusiveGateway("gtw").sequenceFlowId("flow1").condition("cond", "${x.stringProperty == \"bar\"}").userTask("userTask1").endEvent().moveToLastGateway().sequenceFlowId("flow2").userTask("userTask2").endEvent().done();

            deployment(modelInstance);

            XmlSerializable bean = new XmlSerializable("bar", 42, true);
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            ObjectValue xmlValue  = serializedObjectValue(bean.toExpectedXmlString(), true).serializationDataFormat(XML_FORMAT_NAME).objectTypeName(typeof(XmlSerializable).FullName).create();
            VariableMap variables = Variables.createVariables().putValueTyped("x", xmlValue);

            // when
            runtimeService.startProcessInstanceByKey("foo", variables);

            // then
            IList <VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();

            assertEquals(0, variableInstances.Count);

            Task task = taskService.createTaskQuery().singleResult();

            assertNotNull(task);
            assertEquals("userTask1", task.TaskDefinitionKey);
        }
Esempio n. 2
0
        public virtual void testSerializationAsXml()
        {
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            XmlSerializable bean = new XmlSerializable("a String", 42, true);

            // request object to be serialized as XML
            runtimeService.setVariable(instance.Id, "simpleBean", objectValue(bean).serializationDataFormat(XML_FORMAT_NAME).create());

            // validate untyped value
            object value = runtimeService.getVariable(instance.Id, "simpleBean");

            assertEquals(bean, value);

            // validate typed value
            ObjectValue typedValue = runtimeService.getVariableTyped(instance.Id, "simpleBean");

            assertEquals(ValueType.OBJECT, typedValue.Type);

            assertTrue(typedValue.Deserialized);

            assertEquals(bean, typedValue.Value);
            assertEquals(bean, typedValue.getValue(typeof(XmlSerializable)));
            assertEquals(typeof(XmlSerializable), typedValue.ObjectType);

            assertEquals(XML_FORMAT_NAME, typedValue.SerializationDataFormat);
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            assertEquals(typeof(XmlSerializable).FullName, typedValue.ObjectTypeName);
            SpinXmlElement serializedValue = Spin.XML(typedValue.ValueSerialized);

            assertEquals(bean.StringProperty, serializedValue.childElement("stringProperty").textContent());
            assertEquals(bean.BooleanProperty, bool.Parse(serializedValue.childElement("booleanProperty").textContent()));
            assertEquals(bean.IntProperty, int.Parse(serializedValue.childElement("intProperty").textContent()));
        }
Esempio n. 3
0
            public Void execute(CommandContext commandContext)
            {
                XmlSerializable bean = new XmlSerializable("a String", 42, true);

                outerInstance.runtimeService.setVariable(instance.Id, "simpleBean", bean);

                object returnedBean = outerInstance.runtimeService.getVariable(instance.Id, "simpleBean");

                assertSame(bean, returnedBean);

                return(null);
            }
Esempio n. 4
0
        public virtual void testGetSerializedVariableValue()
        {
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            XmlSerializable bean = new XmlSerializable("a String", 42, true);

            runtimeService.setVariable(instance.Id, "simpleBean", objectValue(bean).serializationDataFormat(XML_FORMAT_NAME).create());

            ObjectValue typedValue = runtimeService.getVariableTyped(instance.Id, "simpleBean", false);

            SpinXmlElement serializedValue = Spin.XML(typedValue.ValueSerialized);

            assertEquals(bean.StringProperty, serializedValue.childElement("stringProperty").textContent());
            assertEquals(bean.BooleanProperty, bool.Parse(serializedValue.childElement("booleanProperty").textContent()));
            assertEquals(bean.IntProperty, int.Parse(serializedValue.childElement("intProperty").textContent()));
        }
Esempio n. 5
0
        public virtual void testFailForNonExistingSerializationFormat()
        {
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            XmlSerializable XmlSerializable = new XmlSerializable();

            try
            {
                runtimeService.setVariable(instance.Id, "simpleBean", objectValue(XmlSerializable).serializationDataFormat("non existing data format"));
                fail("Exception expected");
            }
            catch (ProcessEngineException e)
            {
                assertTextPresent("Cannot find serializer for value", e.Message);
                // happy path
            }
        }
Esempio n. 6
0
        public virtual void testSetTypedNullForExistingVariable()
        {
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            // initially the variable has a value
            XmlSerializable javaSerializable = new XmlSerializable();

            runtimeService.setVariable(instance.Id, "varName", objectValue(javaSerializable).serializationDataFormat(XML_FORMAT_NAME).create());

            // get value via untyped api
            assertEquals(javaSerializable, runtimeService.getVariable(instance.Id, "varName"));

            // set the variable to null via typed Api
            runtimeService.setVariable(instance.Id, "varName", objectValue(null));

            // variable is still of type object
            ObjectValue typedValue = runtimeService.getVariableTyped(instance.Id, "varName");

            assertObjectValueDeserializedNull(typedValue);
        }
Esempio n. 7
0
        public virtual void testSetUntypedNullForExistingVariable()
        {
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            // initially the variable has a value
            XmlSerializable @object = new XmlSerializable();

            runtimeService.setVariable(instance.Id, "varName", objectValue(@object).serializationDataFormat(XML_FORMAT_NAME).create());

            // get value via untyped api
            assertEquals(@object, runtimeService.getVariable(instance.Id, "varName"));

            // set the variable to null via untyped Api
            runtimeService.setVariable(instance.Id, "varName", null);

            // variable is now untyped null
            TypedValue nullValue = runtimeService.getVariableTyped(instance.Id, "varName");

            assertUntypedNullValue(nullValue);
        }
Esempio n. 8
0
        public virtual void testSetSerializedVariableValueMismatchingTypeName()
        {
            ProcessInstance instance  = runtimeService.startProcessInstanceByKey("oneTaskProcess");
            XmlSerializable bean      = new XmlSerializable("a String", 42, true);
            string          beanAsXml = bean.toExpectedXmlString();

            SerializedObjectValueBuilder serializedValue = serializedObjectValue(beanAsXml).serializationDataFormat(XML_FORMAT_NAME).objectTypeName("Insensible type name.");     // < not a valid type name

            runtimeService.setVariable(instance.Id, "simpleBean", serializedValue);

            try
            {
                runtimeService.getVariable(instance.Id, "simpleBean");
                fail("Exception expected.");
            }
            catch (ProcessEngineException)
            {
                // happy path
            }
        }
Esempio n. 9
0
        public virtual void testSetSerializedVariableValueNoTypeName()
        {
            ProcessInstance instance  = runtimeService.startProcessInstanceByKey("oneTaskProcess");
            XmlSerializable bean      = new XmlSerializable("a String", 42, true);
            string          beanAsXml = bean.toExpectedXmlString();

            SerializedObjectValueBuilder serializedValue = serializedObjectValue(beanAsXml).serializationDataFormat(XML_FORMAT_NAME);

            // no type name

            try
            {
                runtimeService.setVariable(instance.Id, "simpleBean", serializedValue);
                fail("Exception expected.");
            }
            catch (Exception e)
            {
                assertTextPresent("no 'objectTypeName' provided for non-null value", e.Message);
            }
        }
Esempio n. 10
0
        public virtual void testSetSerializedVariableValueNullNoTypeName()
        {
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            SerializedObjectValueBuilder serializedValue = serializedObjectValue().serializationDataFormat(XML_FORMAT_NAME);

            // no objectTypeName specified

            runtimeService.setVariable(instance.Id, "simpleBean", serializedValue);

            // null can be retrieved
            XmlSerializable returnedBean = (XmlSerializable)runtimeService.getVariable(instance.Id, "simpleBean");

            assertNull(returnedBean);

            // validate typed value metadata
            ObjectValue typedValue = runtimeService.getVariableTyped(instance.Id, "simpleBean");

            assertNull(typedValue.Value);
            assertNull(typedValue.ValueSerialized);
            assertEquals(XML_FORMAT_NAME, typedValue.SerializationDataFormat);
            assertNull(typedValue.ObjectTypeName);
        }
Esempio n. 11
0
        public virtual void testSetSerializedVariableValueNull()
        {
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method:
            SerializedObjectValueBuilder serializedValue = serializedObjectValue().serializationDataFormat(XML_FORMAT_NAME).objectTypeName(typeof(XmlSerializable).FullName);

            runtimeService.setVariable(instance.Id, "simpleBean", serializedValue);

            // null can be retrieved
            XmlSerializable returnedBean = (XmlSerializable)runtimeService.getVariable(instance.Id, "simpleBean");

            assertNull(returnedBean);

            // validate typed value metadata
            ObjectValue typedValue = runtimeService.getVariableTyped(instance.Id, "simpleBean");

            assertNull(typedValue.Value);
            assertNull(typedValue.ValueSerialized);
            assertEquals(XML_FORMAT_NAME, typedValue.SerializationDataFormat);
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method:
            assertEquals(typeof(XmlSerializable).FullName, typedValue.ObjectTypeName);
        }
Esempio n. 12
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            XmlSerializable other = (XmlSerializable)obj;

            if (booleanProperty != other.booleanProperty)
            {
                return(false);
            }
            if (intProperty != other.intProperty)
            {
                return(false);
            }
            if (string.ReferenceEquals(stringProperty, null))
            {
                if (!string.ReferenceEquals(other.stringProperty, null))
                {
                    return(false);
                }
            }
            else if (!stringProperty.Equals(other.stringProperty))
            {
                return(false);
            }
            return(true);
        }