use of org.camunda.bpm.engine.variable.value.StringValue in project camunda-bpm-platform by camunda.
the class ProcessVariableTypedTest method testProcessVariableTypeAnnotation.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testProcessVariableTypeAnnotation() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
VariableMap variables = Variables.createVariables().putValue("injectedValue", "camunda");
businessProcess.startProcessByKey("keyOfTheProcess", variables);
TypedValue value = getBeanInstance(DeclarativeProcessController.class).getInjectedValue();
assertNotNull(value);
assertTrue(value instanceof StringValue);
assertEquals(ValueType.STRING, value.getType());
assertEquals("camunda", value.getValue());
}
use of org.camunda.bpm.engine.variable.value.StringValue in project camunda-bpm-platform by camunda.
the class ProcessVariableLocalTypedTest method testProcessVariableLocalTypeAnnotation.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testProcessVariableLocalTypeAnnotation() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
VariableMap variables = Variables.createVariables().putValue("injectedLocalValue", "camunda");
businessProcess.startProcessByKey("keyOfTheProcess", variables);
TypedValue value = getBeanInstance(DeclarativeProcessController.class).getInjectedLocalValue();
assertNotNull(value);
assertTrue(value instanceof StringValue);
assertEquals(ValueType.STRING, value.getType());
assertEquals("camunda", value.getValue());
}
use of org.camunda.bpm.engine.variable.value.StringValue in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseInstanceCmdsTenantCheckTest method getVariableTypedDisabledTenantCheck.
@Test
public void getVariableTypedDisabledTenantCheck() {
identityService.setAuthentication("user", null, null);
processEngineConfiguration.setTenantCheckEnabled(false);
StringValue variable = caseService.getVariableTyped(caseExecutionId, VARIABLE_NAME);
assertThat(variable.getValue(), is(VARIABLE_VALUE));
}
use of org.camunda.bpm.engine.variable.value.StringValue in project camunda-bpm-platform by camunda.
the class TaskVariablesTest method testTaskExecutionVariables.
@Deployment
public void testTaskExecutionVariables() {
String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId();
String taskId = taskService.createTaskQuery().singleResult().getId();
Map<String, Object> expectedVariables = new HashMap<String, Object>();
assertEquals(expectedVariables, runtimeService.getVariables(processInstanceId));
assertEquals(expectedVariables, taskService.getVariables(taskId));
assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId));
assertEquals(expectedVariables, taskService.getVariablesLocal(taskId));
runtimeService.setVariable(processInstanceId, "instrument", "trumpet");
expectedVariables = new HashMap<String, Object>();
assertEquals(expectedVariables, taskService.getVariablesLocal(taskId));
expectedVariables.put("instrument", "trumpet");
assertEquals(expectedVariables, runtimeService.getVariables(processInstanceId));
assertEquals(expectedVariables, taskService.getVariables(taskId));
assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId));
taskService.setVariable(taskId, "player", "gonzo");
expectedVariables = new HashMap<String, Object>();
assertEquals(expectedVariables, taskService.getVariablesLocal(taskId));
expectedVariables.put("player", "gonzo");
expectedVariables.put("instrument", "trumpet");
assertEquals(expectedVariables, runtimeService.getVariables(processInstanceId));
assertEquals(expectedVariables, taskService.getVariables(taskId));
assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId));
assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId, null));
assertEquals(expectedVariables, runtimeService.getVariablesLocalTyped(processInstanceId, null, true));
taskService.setVariableLocal(taskId, "budget", "unlimited");
expectedVariables = new HashMap<String, Object>();
expectedVariables.put("budget", "unlimited");
assertEquals(expectedVariables, taskService.getVariablesLocal(taskId));
assertEquals(expectedVariables, taskService.getVariablesLocalTyped(taskId, true));
expectedVariables.put("player", "gonzo");
expectedVariables.put("instrument", "trumpet");
assertEquals(expectedVariables, taskService.getVariables(taskId));
assertEquals(expectedVariables, taskService.getVariablesTyped(taskId, true));
assertEquals(expectedVariables, taskService.getVariables(taskId, null));
assertEquals(expectedVariables, taskService.getVariablesTyped(taskId, null, true));
expectedVariables = new HashMap<String, Object>();
expectedVariables.put("player", "gonzo");
expectedVariables.put("instrument", "trumpet");
assertEquals(expectedVariables, runtimeService.getVariables(processInstanceId));
assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId));
// typed variable API
ArrayList<String> serializableValue = new ArrayList<String>();
serializableValue.add("1");
serializableValue.add("2");
taskService.setVariable(taskId, "objectVariable", objectValue(serializableValue).create());
ArrayList<String> serializableValueLocal = new ArrayList<String>();
serializableValueLocal.add("3");
serializableValueLocal.add("4");
taskService.setVariableLocal(taskId, "objectVariableLocal", objectValue(serializableValueLocal).create());
Object value = taskService.getVariable(taskId, "objectVariable");
assertEquals(serializableValue, value);
Object valueLocal = taskService.getVariableLocal(taskId, "objectVariableLocal");
assertEquals(serializableValueLocal, valueLocal);
ObjectValue typedValue = taskService.getVariableTyped(taskId, "objectVariable");
assertEquals(serializableValue, typedValue.getValue());
ObjectValue serializedValue = taskService.getVariableTyped(taskId, "objectVariable", false);
assertFalse(serializedValue.isDeserialized());
ObjectValue typedValueLocal = taskService.getVariableLocalTyped(taskId, "objectVariableLocal");
assertEquals(serializableValueLocal, typedValueLocal.getValue());
ObjectValue serializedValueLocal = taskService.getVariableLocalTyped(taskId, "objectVariableLocal", false);
assertFalse(serializedValueLocal.isDeserialized());
try {
StringValue val = taskService.getVariableTyped(taskId, "objectVariable");
fail("expected exception");
} catch (ClassCastException e) {
// happy path
}
}
use of org.camunda.bpm.engine.variable.value.StringValue in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceQueryTest method verifyStringValue.
protected void verifyStringValue(Map<String, Object> stringValue) {
StringValue exampleValue = MockProvider.EXAMPLE_HISTORIC_DECISION_STRING_VALUE;
assertThat(stringValue, hasEntry("type", (Object) VariableValueDto.toRestApiTypeName(exampleValue.getType().getName())));
assertThat(stringValue, hasEntry("value", (Object) exampleValue.getValue()));
assertThat(stringValue, hasEntry("valueInfo", (Object) Collections.emptyMap()));
}
Aggregations