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())); }
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())); }