Search in sources :

Example 56 with Deployment

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);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 57 with Deployment

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()));
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) Variables.serializedObjectValue(org.camunda.bpm.engine.variable.Variables.serializedObjectValue) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) SpinXmlElement(org.camunda.spin.xml.SpinXmlElement) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 58 with Deployment

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());
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) Variables.serializedObjectValue(org.camunda.bpm.engine.variable.Variables.serializedObjectValue) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) SerializedObjectValueBuilder(org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 59 with Deployment

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) VariableMap(org.camunda.bpm.engine.variable.VariableMap) XmlValue(org.camunda.spin.plugin.variable.value.XmlValue) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 60 with Deployment

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());
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) XmlValue(org.camunda.spin.plugin.variable.value.XmlValue) SpinXmlElement(org.camunda.spin.xml.SpinXmlElement) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Deployment (org.camunda.bpm.engine.test.Deployment)3376 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1325 Task (org.camunda.bpm.engine.task.Task)788 Test (org.junit.Test)635 HashMap (java.util.HashMap)441 Job (org.camunda.bpm.engine.runtime.Job)310 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)277 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)265 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)256 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)251 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)230 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)206 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)195 Execution (org.camunda.bpm.engine.runtime.Execution)189 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)175 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)161 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)149 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)143 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)134 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)134