use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class JsonValueTest method testGetTypedJsonValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetTypedJsonValue() throws JSONException {
// given
JsonValue jsonValue = jsonValue(jsonString).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, jsonValue);
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// when
JsonValue typedValue = runtimeService.getVariableTyped(processInstanceId, variableName);
// then
SpinJsonNode value = typedValue.getValue();
JSONAssert.assertEquals(jsonString, value.toString(), true);
assertTrue(typedValue.isDeserialized());
assertEquals(JSON, typedValue.getType());
assertEquals(JSON_FORMAT_NAME, typedValue.getSerializationDataFormat());
JSONAssert.assertEquals(jsonString, typedValue.getValueSerialized(), true);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class JsonValueTest method testTransientJsonValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testTransientJsonValue() throws JSONException {
// given
JsonValue jsonValue = jsonValue(jsonString).setTransient(true).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, jsonValue);
// when
runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// then
List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
assertEquals(0, variableInstances.size());
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class JsonValueTest method testGetUntypedJsonValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetUntypedJsonValue() throws JSONException {
// given
JsonValue jsonValue = jsonValue(jsonString).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, jsonValue);
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// when
SpinJsonNode value = (SpinJsonNode) runtimeService.getVariable(processInstanceId, variableName);
// then
JSONAssert.assertEquals(jsonString, value.toString(), true);
assertEquals(json().getName(), value.getDataFormatName());
}
use of org.camunda.bpm.engine.variable.VariableMap 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.variable.VariableMap 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