use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class ProcessTaskTest method testInputOutputAllTypedVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testInputOutputAll.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testInputOutputAllTypedVariables() {
String variableName = "aVariable";
String variableName2 = "anotherVariable";
String variableName3 = "theThirdVariable";
TypedValue variableValue = Variables.stringValue("abc");
TypedValue variableValue2 = Variables.longValue(null);
String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE, Variables.createVariables().putValue(variableName, variableValue).putValue(variableName2, variableValue2)).getId();
String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK).getId();
String processInstanceId = queryProcessInstance().getId();
TypedValue value = runtimeService.getVariableTyped(processInstanceId, variableName);
assertThat(value, is(variableValue));
value = runtimeService.getVariableTyped(processInstanceId, variableName2);
assertThat(value, is(variableValue2));
String taskId = queryTask().getId();
TypedValue variableValue3 = Variables.integerValue(1);
runtimeService.setVariable(processInstanceId, variableName3, variableValue3);
// should also complete process instance
taskService.complete(taskId);
value = caseService.getVariableTyped(caseInstanceId, variableName3);
assertThat(value, is(variableValue3));
// complete ////////////////////////////////////////////////////////
assertProcessEnded(processInstanceId);
close(caseInstanceId);
assertCaseEnded(caseInstanceId);
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class CreateProcessInstanceWithJsonVariablesTest method testCreateProcessInstanceWithVariable.
@ScenarioUnderTest("initProcessInstance.1")
@Test
public void testCreateProcessInstanceWithVariable() {
// then
ProcessInstance processInstance = engineRule.getRuntimeService().createProcessInstanceQuery().processInstanceBusinessKey("processWithJsonVariables").singleResult();
List<VariableInstance> variables = engineRule.getRuntimeService().createVariableInstanceQuery().processInstanceIdIn(processInstance.getId()).list();
assertEquals(4, variables.size());
final Object objectVariable = engineRule.getRuntimeService().getVariable(processInstance.getId(), "objectVariable");
assertObjectVariable(objectVariable);
final Object plainTypeArrayVariable = engineRule.getRuntimeService().getVariable(processInstance.getId(), "plainTypeArrayVariable");
assertPlainTypeArrayVariable(plainTypeArrayVariable);
final Object notGenericObjectListVariable = engineRule.getRuntimeService().getVariable(processInstance.getId(), "notGenericObjectListVariable");
assertNotGenericObjectListVariable(notGenericObjectListVariable);
final TypedValue serializedObject = engineRule.getRuntimeService().getVariableTyped(processInstance.getId(), "serializedMapVariable", true);
assertSerializedMap(serializedObject);
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class GetTaskVariableCmdTyped method execute.
public TypedValue execute(CommandContext commandContext) {
ensureNotNull("taskId", taskId);
ensureNotNull("variableName", variableName);
TaskEntity task = Context.getCommandContext().getTaskManager().findTaskById(taskId);
ensureNotNull("task " + taskId + " doesn't exist", "task", task);
checkGetTaskVariableTyped(task, commandContext);
TypedValue value;
if (isLocal) {
value = task.getVariableLocalTyped(variableName, deserializeValue);
} else {
value = task.getVariableTyped(variableName, deserializeValue);
}
return value;
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class CallActivityTest method testSubProcessWithAllDataInputOutputTypedApi.
/**
* Test case for handing over process variables to a sub process via the typed
* api and passing all variables
*/
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testSubProcessAllDataInputOutputTypedApi.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" })
public void testSubProcessWithAllDataInputOutputTypedApi() {
TypedValue superVariable = Variables.stringValue(null);
VariableMap vars = Variables.createVariables();
vars.putValueTyped("superVariable", superVariable);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessDataInputOutput", vars);
// one task in the subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInSubProcess = taskQuery.singleResult();
assertThat(taskInSubProcess.getName(), is("Task in subprocess"));
assertThat(runtimeService.getVariableTyped(taskInSubProcess.getProcessInstanceId(), "superVariable"), is(superVariable));
assertThat(taskService.getVariableTyped(taskInSubProcess.getId(), "superVariable"), is(superVariable));
TypedValue subVariable = Variables.stringValue(null);
runtimeService.setVariable(taskInSubProcess.getProcessInstanceId(), "subVariable", subVariable);
// Completing this task ends the subprocess which leads to a task in the super process
taskService.complete(taskInSubProcess.getId());
Task taskAfterSubProcess = taskQuery.singleResult();
assertThat(taskAfterSubProcess.getName(), is("Task in super process"));
assertThat(runtimeService.getVariableTyped(processInstance.getId(), "subVariable"), is(subVariable));
assertThat(taskService.getVariableTyped(taskAfterSubProcess.getId(), "superVariable"), is(superVariable));
// Completing this task ends the super process which leads to a task in the super process
taskService.complete(taskAfterSubProcess.getId());
assertProcessEnded(processInstance.getId());
assertEquals(0, runtimeService.createExecutionQuery().list().size());
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class CallActivityTest method testSubProcessWithLimitedDataInputOutputTypedApi.
/**
* Test case for handing over process variables to a sub process via the typed
* api and passing only certain variables
*/
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testSubProcessLimitedDataInputOutputTypedApi.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" })
public void testSubProcessWithLimitedDataInputOutputTypedApi() {
TypedValue superVariable = Variables.stringValue(null);
VariableMap vars = Variables.createVariables();
vars.putValueTyped("superVariable", superVariable);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessDataInputOutput", vars);
// one task in the subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInSubProcess = taskQuery.singleResult();
assertThat(taskInSubProcess.getName(), is("Task in subprocess"));
assertThat(runtimeService.getVariableTyped(taskInSubProcess.getProcessInstanceId(), "subVariable"), is(superVariable));
assertThat(taskService.getVariableTyped(taskInSubProcess.getId(), "subVariable"), is(superVariable));
TypedValue subVariable = Variables.stringValue(null);
runtimeService.setVariable(taskInSubProcess.getProcessInstanceId(), "subVariable", subVariable);
// super variable is unchanged
assertThat(runtimeService.getVariableTyped(processInstance.getId(), "superVariable"), is(superVariable));
// Completing this task ends the subprocess which leads to a task in the super process
taskService.complete(taskInSubProcess.getId());
Task taskAfterSubProcess = taskQuery.singleResult();
assertThat(taskAfterSubProcess.getName(), is("Task in super process"));
assertThat(runtimeService.getVariableTyped(processInstance.getId(), "superVariable"), is(subVariable));
assertThat(taskService.getVariableTyped(taskAfterSubProcess.getId(), "superVariable"), is(subVariable));
// Completing this task ends the super process which leads to a task in the super process
taskService.complete(taskAfterSubProcess.getId());
assertProcessEnded(processInstance.getId());
assertEquals(0, runtimeService.createExecutionQuery().list().size());
}
Aggregations