use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testGetVariablesTypedByNameWithReadInstancePermissionOnAnyProcessDefinition.
public void testGetVariablesTypedByNameWithReadInstancePermissionOnAnyProcessDefinition() {
// given
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY, getVariables()).getId();
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);
// when
VariableMap variables = runtimeService.getVariablesTyped(processInstanceId, Arrays.asList(VARIABLE_NAME), false);
// then
assertNotNull(variables);
assertFalse(variables.isEmpty());
assertEquals(1, variables.size());
assertEquals(VARIABLE_VALUE, variables.get(VARIABLE_NAME));
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testGetVariablesLocalTypedByNameWithReadPermissionOnProcessInstance.
public void testGetVariablesLocalTypedByNameWithReadPermissionOnProcessInstance() {
// given
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY, getVariables()).getId();
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
// when
VariableMap variables = runtimeService.getVariablesLocalTyped(processInstanceId, Arrays.asList(VARIABLE_NAME), false);
// then
assertNotNull(variables);
assertFalse(variables.isEmpty());
assertEquals(1, variables.size());
assertEquals(VARIABLE_VALUE, variables.get(VARIABLE_NAME));
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testGetVariablesTypedWithReadInstancePermissionOnProcessDefinition.
public void testGetVariablesTypedWithReadInstancePermissionOnProcessDefinition() {
// given
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY, getVariables()).getId();
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_INSTANCE);
// when
VariableMap variables = runtimeService.getVariablesTyped(processInstanceId);
// then
assertNotNull(variables);
assertFalse(variables.isEmpty());
assertEquals(1, variables.size());
assertEquals(VARIABLE_VALUE, variables.get(VARIABLE_NAME));
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetVariablesLocalTyped.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testGetVariablesLocalTyped() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("variable1", "value1");
vars.put("variable2", "value2");
runtimeService.startProcessInstanceByKey("oneTaskProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.setVariablesLocal(taskId, vars);
VariableMap variablesTyped = taskService.getVariablesLocalTyped(taskId);
assertEquals(vars, variablesTyped);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetVariablesLocalTypedDeserialize.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testGetVariablesLocalTypedDeserialize() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.setVariablesLocal(taskId, Variables.createVariables().putValue("broken", Variables.serializedObjectValue("broken").serializationDataFormat(Variables.SerializationDataFormats.JAVA).objectTypeName("unexisting").create()));
// this works
VariableMap variablesTyped = taskService.getVariablesLocalTyped(taskId, false);
assertNotNull(variablesTyped.getValueTyped("broken"));
variablesTyped = taskService.getVariablesLocalTyped(taskId, Arrays.asList("broken"), false);
assertNotNull(variablesTyped.getValueTyped("broken"));
// this does not
try {
taskService.getVariablesLocalTyped(taskId);
} catch (ProcessEngineException e) {
testRule.assertTextPresent("Cannot deserialize object", e.getMessage());
}
// this does not
try {
taskService.getVariablesLocalTyped(taskId, Arrays.asList("broken"), true);
} catch (ProcessEngineException e) {
testRule.assertTextPresent("Cannot deserialize object", e.getMessage());
}
}
Aggregations