use of org.camunda.spin.xml.SpinXmlElement in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testGetSerializedVariableValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetSerializedVariableValue() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
XmlSerializable bean = new XmlSerializable("a String", 42, true);
runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(bean).serializationDataFormat(XML_FORMAT_NAME).create());
ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean", false);
SpinXmlElement serializedValue = Spin.XML(typedValue.getValueSerialized());
assertEquals(bean.getStringProperty(), serializedValue.childElement("stringProperty").textContent());
assertEquals(bean.getBooleanProperty(), Boolean.parseBoolean(serializedValue.childElement("booleanProperty").textContent()));
assertEquals(bean.getIntProperty(), Integer.parseInt(serializedValue.childElement("intProperty").textContent()));
}
use of org.camunda.spin.xml.SpinXmlElement in project camunda-bpm-platform by camunda.
the class XmlValueTest method testGetTypedXmlValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetTypedXmlValue() {
// given
XmlValue xmlValue = xmlValue(xmlString).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, xmlValue);
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// when
XmlValue typedValue = runtimeService.getVariableTyped(processInstanceId, variableName);
// then
SpinXmlElement value = typedValue.getValue();
assertTrue(value.hasAttr("attrName"));
assertEquals("attrValue", value.attr("attrName").value());
assertTrue(value.childElements().isEmpty());
assertTrue(typedValue.isDeserialized());
assertEquals(XML, typedValue.getType());
assertEquals(XML_FORMAT_NAME, typedValue.getSerializationDataFormat());
assertEquals(xmlString, typedValue.getValueSerialized());
}
use of org.camunda.spin.xml.SpinXmlElement in project camunda-bpm-platform by camunda.
the class SpinFunctionMapperTest method testSpin_S_Available.
public void testSpin_S_Available() {
SpinXmlElement spinXmlEl = executeExpression("${ S('" + xmlString + "') }");
assertNotNull(spinXmlEl);
assertEquals("elementName", spinXmlEl.name());
}
use of org.camunda.spin.xml.SpinXmlElement in project camunda-bpm-platform by camunda.
the class SpinFunctionMapperTest method testSpin_XML_Available.
public void testSpin_XML_Available() {
SpinXmlElement spinXmlEl = executeExpression("${ XML('" + xmlString + "') }");
assertNotNull(spinXmlEl);
assertEquals("elementName", spinXmlEl.name());
}
use of org.camunda.spin.xml.SpinXmlElement in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testSerializationAsXml.
@Deployment(resources = ONE_TASK_PROCESS)
public 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.getId(), "simpleBean", objectValue(bean).serializationDataFormat(XML_FORMAT_NAME).create());
// validate untyped value
Object value = runtimeService.getVariable(instance.getId(), "simpleBean");
assertEquals(bean, value);
// validate typed value
ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean");
assertEquals(ValueType.OBJECT, typedValue.getType());
assertTrue(typedValue.isDeserialized());
assertEquals(bean, typedValue.getValue());
assertEquals(bean, typedValue.getValue(XmlSerializable.class));
assertEquals(XmlSerializable.class, typedValue.getObjectType());
assertEquals(XML_FORMAT_NAME, typedValue.getSerializationDataFormat());
assertEquals(XmlSerializable.class.getName(), typedValue.getObjectTypeName());
SpinXmlElement serializedValue = Spin.XML(typedValue.getValueSerialized());
assertEquals(bean.getStringProperty(), serializedValue.childElement("stringProperty").textContent());
assertEquals(bean.getBooleanProperty(), Boolean.parseBoolean(serializedValue.childElement("booleanProperty").textContent()));
assertEquals(bean.getIntProperty(), Integer.parseInt(serializedValue.childElement("intProperty").textContent()));
}
Aggregations