use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testSetUntypedNullForExistingVariable.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetUntypedNullForExistingVariable() throws Exception {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// initially the variable has a value
XmlSerializable object = new XmlSerializable();
runtimeService.setVariable(instance.getId(), "varName", objectValue(object).serializationDataFormat(XML_FORMAT_NAME).create());
// get value via untyped api
assertEquals(object, runtimeService.getVariable(instance.getId(), "varName"));
// set the variable to null via untyped Api
runtimeService.setVariable(instance.getId(), "varName", null);
// variable is now untyped null
TypedValue nullValue = runtimeService.getVariableTyped(instance.getId(), "varName");
assertUntypedNullValue(nullValue);
}
use of org.camunda.bpm.engine.test.Deployment 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.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testSetSerializedVariableValueNullNoTypeName.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetSerializedVariableValueNullNoTypeName() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
SerializedObjectValueBuilder serializedValue = serializedObjectValue().serializationDataFormat(XML_FORMAT_NAME);
// no objectTypeName specified
runtimeService.setVariable(instance.getId(), "simpleBean", serializedValue);
// null can be retrieved
XmlSerializable returnedBean = (XmlSerializable) runtimeService.getVariable(instance.getId(), "simpleBean");
assertNull(returnedBean);
// validate typed value metadata
ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean");
assertNull(typedValue.getValue());
assertNull(typedValue.getValueSerialized());
assertEquals(XML_FORMAT_NAME, typedValue.getSerializationDataFormat());
assertNull(typedValue.getObjectTypeName());
}
use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class XmlValueTest method testXmlValueInCondition.
@Deployment(resources = "org/camunda/spin/plugin/xmlConditionProcess.bpmn20.xml")
public void testXmlValueInCondition() {
// given
String xmlString = "<customer age=\"22\" />";
XmlValue value = xmlValue(xmlString).create();
VariableMap variables = Variables.createVariables().putValueTyped("customer", value);
// when
runtimeService.startProcessInstanceByKey("process", variables);
// then
Task task = taskService.createTaskQuery().singleResult();
assertEquals("task1", task.getTaskDefinitionKey());
}
use of org.camunda.bpm.engine.test.Deployment 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());
}
Aggregations