use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class CmmnDisabledTest method testVariableInstanceQuery.
public void testVariableInstanceQuery() {
ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()).addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml").deploy();
VariableMap variables = Variables.createVariables().putValue("my-variable", "a-value");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
// variable instance query
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertEquals(1, result.size());
VariableInstance variableInstance = result.get(0);
assertEquals("my-variable", variableInstance.getName());
// get variable
assertNotNull(runtimeService.getVariable(processInstance.getId(), "my-variable"));
// get variable local
assertNotNull(runtimeService.getVariableLocal(processInstance.getId(), "my-variable"));
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testShouldNotFetchSerializedVariables.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/ExternalTaskServiceTest.testFetchVariables.bpmn20.xml")
public void testShouldNotFetchSerializedVariables() {
// given
ExternalTaskCustomValue customValue = new ExternalTaskCustomValue();
customValue.setTestValue("value1");
runtimeService.startProcessInstanceByKey("subProcessExternalTask", Variables.createVariables().putValue("processVar1", customValue));
// when
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).variables("processVar1").execute();
// then
LockedExternalTask task = externalTasks.get(0);
VariableMap variables = task.getVariables();
assertEquals(1, variables.size());
try {
variables.get("processVar1");
fail("did not receive an exception although variable was serialized");
} catch (IllegalStateException e) {
assertEquals("Object is not deserialized.", e.getMessage());
}
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testFetchSerializedVariables.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/ExternalTaskServiceTest.testFetchVariables.bpmn20.xml")
public void testFetchSerializedVariables() {
// given
ExternalTaskCustomValue customValue = new ExternalTaskCustomValue();
customValue.setTestValue("value1");
runtimeService.startProcessInstanceByKey("subProcessExternalTask", Variables.createVariables().putValue("processVar1", customValue));
// when
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).variables("processVar1").enableCustomObjectDeserialization().execute();
// then
LockedExternalTask task = externalTasks.get(0);
VariableMap variables = task.getVariables();
assertEquals(1, variables.size());
final ExternalTaskCustomValue receivedCustomValue = (ExternalTaskCustomValue) variables.get("processVar1");
assertNotNull(receivedCustomValue);
assertNotNull(receivedCustomValue.getTestValue());
assertEquals("value1", receivedCustomValue.getTestValue());
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class FormServiceTest method testSubmitStartFormDataTypedVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/form/FormsProcess.bpmn20.xml" })
@Test
public void testSubmitStartFormDataTypedVariables() {
String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
String stringValue = "some string";
String serializedValue = "some value";
ProcessInstance processInstance = formService.submitStartForm(procDefId, createVariables().putValueTyped("boolean", booleanValue(null)).putValueTyped("string", stringValue(stringValue)).putValueTyped("serializedObject", serializedObjectValue(serializedValue).objectTypeName(String.class.getName()).serializationDataFormat(Variables.SerializationDataFormats.JAVA).create()).putValueTyped("object", objectValue(serializedValue).create()));
VariableMap variables = runtimeService.getVariablesTyped(processInstance.getId(), false);
assertEquals(booleanValue(null), variables.getValueTyped("boolean"));
assertEquals(stringValue(stringValue), variables.getValueTyped("string"));
assertNotNull(variables.<ObjectValue>getValueTyped("serializedObject").getValueSerialized());
assertNotNull(variables.<ObjectValue>getValueTyped("object").getValueSerialized());
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class FormServiceTest method testGetStartFormVariablesEnumType.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/form/FormServiceTest.startFormFieldsUnknownType.bpmn20.xml" })
@Test
public void testGetStartFormVariablesEnumType() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
VariableMap startFormVariables = formService.getStartFormVariables(processDefinition.getId());
assertEquals("a", startFormVariables.get("enumField"));
assertEquals(ValueType.STRING, startFormVariables.getValueTyped("enumField").getType());
}
Aggregations