use of org.camunda.spin.plugin.variable.value.XmlValue 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.spin.plugin.variable.value.XmlValue 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.plugin.variable.value.XmlValue in project camunda-bpm-platform by camunda.
the class XmlValueTest method testFailingDeserialization.
@Deployment(resources = ONE_TASK_PROCESS)
public void testFailingDeserialization() {
// given
XmlValue value = xmlValue(brokenXmlString).create();
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
runtimeService.setVariable(processInstanceId, variableName, value);
try {
// when
runtimeService.getVariable(processInstanceId, variableName);
fail("exception expected");
} catch (ProcessEngineException e) {
// happy path
}
try {
runtimeService.getVariableTyped(processInstanceId, variableName);
fail("exception expected");
} catch (ProcessEngineException e) {
// happy path
}
// However, I can access the serialized value
XmlValue xmlValue = runtimeService.getVariableTyped(processInstanceId, variableName, false);
assertFalse(xmlValue.isDeserialized());
assertEquals(brokenXmlString, xmlValue.getValueSerialized());
// but not the deserialized properties
try {
xmlValue.getValue();
fail("exception expected");
} catch (SpinRuntimeException e) {
}
}
use of org.camunda.spin.plugin.variable.value.XmlValue in project camunda-bpm-platform by camunda.
the class XmlValueTest method testGetUntypedXmlValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetUntypedXmlValue() {
// given
XmlValue xmlValue = xmlValue(xmlString).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, xmlValue);
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// when
SpinXmlElement value = (SpinXmlElement) runtimeService.getVariable(processInstanceId, variableName);
// then
assertTrue(value.hasAttr("attrName"));
assertEquals("attrValue", value.attr("attrName").value());
assertTrue(value.childElements().isEmpty());
assertEquals(xml().getName(), value.getDataFormatName());
}
use of org.camunda.spin.plugin.variable.value.XmlValue in project camunda-bpm-platform by camunda.
the class XmlValueTest method testBrokenXmlSerialization.
@Deployment(resources = ONE_TASK_PROCESS)
public void testBrokenXmlSerialization() {
// given
XmlValue value = xmlValue(brokenXmlString).create();
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
try {
// when
runtimeService.setVariable(processInstanceId, variableName, value);
} catch (Exception e) {
fail("no exception expected");
}
}
Aggregations