use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class JsonSerializationTest method testVariableValueCaching.
@Deployment(resources = ONE_TASK_PROCESS)
public void testVariableValueCaching() {
final ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
JsonSerializable bean = new JsonSerializable("a String", 42, true);
runtimeService.setVariable(instance.getId(), "simpleBean", bean);
Object returnedBean = runtimeService.getVariable(instance.getId(), "simpleBean");
assertSame(bean, returnedBean);
return null;
}
});
VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
Object returnedBean = variableInstance.getValue();
Object theSameReturnedBean = variableInstance.getValue();
assertSame(returnedBean, theSameReturnedBean);
}
use of org.camunda.bpm.engine.runtime.VariableInstance 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.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class FilterResourceImpl method getVariableValuesForTask.
protected List<HalResource<?>> getVariableValuesForTask(HalTask halTask, Map<String, List<VariableInstance>> variableInstances) {
// converted variables values
List<HalResource<?>> variableValues = new ArrayList<HalResource<?>>();
// variable scope ids to check, ordered by visibility
LinkedHashSet<String> variableScopeIds = getVariableScopeIds(halTask);
// names of already converted variables
Set<String> knownVariableNames = new HashSet<String>();
for (String variableScopeId : variableScopeIds) {
if (variableInstances.containsKey(variableScopeId)) {
for (VariableInstance variableInstance : variableInstances.get(variableScopeId)) {
if (!knownVariableNames.contains(variableInstance.getName())) {
variableValues.add(HalVariableValue.generateVariableValue(variableInstance, variableScopeId));
knownVariableNames.add(variableInstance.getName());
}
}
}
}
return variableValues;
}
use of org.camunda.bpm.engine.runtime.VariableInstance 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.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class DelegationAuthorizationTest method testScriptIoMappingExecutesCommandAfterUserCompletesTask.
@Deployment
public void testScriptIoMappingExecutesCommandAfterUserCompletesTask() {
// given
String processInstanceId = startProcessInstanceByKey(DEFAULT_PROCESS_KEY).getId();
String taskId = selectSingleTask().getId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query.variableName("userId").singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query.variableName("count").singleResult();
assertNotNull(variableCount);
assertEquals(1l, variableCount.getValue());
assertEquals(2, runtimeService.createProcessInstanceQuery().count());
enableAuthorization();
}
Aggregations