use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetVariablesTypedDeserialize.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testGetVariablesTypedDeserialize() {
runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("broken", Variables.serializedObjectValue("broken").serializationDataFormat(Variables.SerializationDataFormats.JAVA).objectTypeName("unexisting").create()));
String taskId = taskService.createTaskQuery().singleResult().getId();
// this works
VariableMap variablesTyped = taskService.getVariablesTyped(taskId, false);
assertNotNull(variablesTyped.getValueTyped("broken"));
variablesTyped = taskService.getVariablesTyped(taskId, Arrays.asList("broken"), false);
assertNotNull(variablesTyped.getValueTyped("broken"));
// this does not
try {
taskService.getVariablesTyped(taskId);
} catch (ProcessEngineException e) {
testRule.assertTextPresent("Cannot deserialize object", e.getMessage());
}
// this does not
try {
taskService.getVariablesTyped(taskId, Arrays.asList("broken"), true);
} catch (ProcessEngineException e) {
testRule.assertTextPresent("Cannot deserialize object", e.getMessage());
}
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class PurgeDatabaseTest method testPurgeDatabase.
@Test
public void testPurgeDatabase() {
Assert.assertNotNull(processEngine);
VariableMap variableMap = Variables.putValue("var", "value");
runtimeService.startProcessInstanceByKey("testDeployProcessArchive", variableMap);
runtimeService.startProcessInstanceByKey("testDeployProcessArchive", variableMap);
ManagementServiceImpl managementServiceImpl = (ManagementServiceImpl) managementService;
managementServiceImpl.purge();
assertAndEnsureCleanDb(processEngine);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testVariableAccessOnDeleteInCalledProcess.
@Test
public void testVariableAccessOnDeleteInCalledProcess() {
// given
VariablesCollectingListener.reset();
BpmnModelInstance callActivityProcess = Bpmn.createExecutableProcess("calling").startEvent().callActivity().camundaIn("foo", "foo").calledElement("called").endEvent().done();
BpmnModelInstance calledProcess = Bpmn.createExecutableProcess("called").startEvent().userTask().camundaTaskListenerClass(TaskListener.EVENTNAME_DELETE, VariablesCollectingListener.class.getName()).endEvent().done();
testRule.deploy(callActivityProcess, calledProcess);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("calling", Variables.createVariables().putValue("foo", "bar"));
// when
runtimeService.deleteProcessInstance(processInstance.getId(), null);
// then
VariableMap collectedVariables = VariablesCollectingListener.getCollectedVariables();
assertNotNull(collectedVariables);
assertEquals(1, collectedVariables.size());
assertEquals("bar", collectedVariables.get("foo"));
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testCatchExceptionThrownBySignalOfParallelDelegateExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownByParallelDelegateExpression.bpmn20.xml" })
public void testCatchExceptionThrownBySignalOfParallelDelegateExpression() {
VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").list().get(3);
assertNotNull(serviceTask);
runtimeService.setVariables(pi, throwException());
runtimeService.signal(serviceTask.getId());
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertTrue((Boolean) runtimeService.getVariable(pi, "signaled"));
Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
assertNotNull(userTask);
assertEquals("userTaskException", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testCatchExceptionThrownByExecuteOfSequentialDelegateExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownBySequentialDelegateExpression.bpmn20.xml" })
public void testCatchExceptionThrownByExecuteOfSequentialDelegateExpression() {
VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
variables.putAll(throwException());
String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
assertNotNull(userTask);
assertEquals("userTaskException", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
Aggregations