Exemplo n.º 1
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()));
        }
Exemplo n.º 2
0
        public virtual void testSpin_XML_Available()
        {
            SpinXmlElement spinXmlEl = executeExpression("${ XML('" + xmlString + "') }");

            assertNotNull(spinXmlEl);
            assertEquals("elementName", spinXmlEl.name());
        }
Exemplo n.º 3
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()));
        }
Exemplo n.º 4
0
        public virtual void testGetUntypedXmlValue()
        {
            // given
            XmlValue    xmlValue  = xmlValue(xmlString).create();
            VariableMap variables = Variables.createVariables().putValueTyped(variableName, xmlValue);

            string processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).Id;

            // when
            SpinXmlElement value = (SpinXmlElement)runtimeService.getVariable(processInstanceId, variableName);

            // then
            assertTrue(value.hasAttr("attrName"));
            assertEquals("attrValue", value.attr("attrName").value());
            assertTrue(value.childElements().Empty);
            assertEquals(xml().Name, value.DataFormatName);
        }
Exemplo n.º 5
0
        public virtual void testGetTypedXmlValue()
        {
            // given
            XmlValue    xmlValue  = xmlValue(xmlString).create();
            VariableMap variables = Variables.createVariables().putValueTyped(variableName, xmlValue);

            string processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).Id;

            // when
            XmlValue typedValue = runtimeService.getVariableTyped(processInstanceId, variableName);

            // then
            SpinXmlElement value = typedValue.Value;

            assertTrue(value.hasAttr("attrName"));
            assertEquals("attrValue", value.attr("attrName").value());
            assertTrue(value.childElements().Empty);

            assertTrue(typedValue.Deserialized);
            assertEquals(XML, typedValue.Type);
            assertEquals(XML_FORMAT_NAME, typedValue.SerializationDataFormat);
            assertEquals(xmlString, typedValue.ValueSerialized);
        }