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 DmnBusinessRuleTaskResultMappingTest method testSingleResultEmptyResult.
@Deployment(resources = { SINGLE_RESULT_BPMN, TEST_DECISION })
public void testSingleResultEmptyResult() {
ProcessInstance processInstance = startTestProcess("empty result");
Object result = runtimeService.getVariable(processInstance.getId(), "result");
assertNull(result);
TypedValue resultTyped = runtimeService.getVariableTyped(processInstance.getId(), "result");
assertEquals(Variables.untypedNullValue(), resultTyped);
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class ProcessTaskTest method testInputOutputLimitedTypedVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testVariablesRoundtrip.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testInputOutputLimitedTypedVariables() {
String variableName = "aVariable";
String variableName2 = "anotherVariable";
TypedValue caseVariableValue = Variables.stringValue("abc");
TypedValue caseVariableValue2 = Variables.integerValue(null);
String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE, Variables.createVariables().putValue(variableName, caseVariableValue).putValue(variableName2, caseVariableValue2)).getId();
String processInstanceId = queryProcessInstance().getId();
TypedValue value = runtimeService.getVariableTyped(processInstanceId, variableName);
assertThat(value, is(caseVariableValue));
value = runtimeService.getVariableTyped(processInstanceId, variableName2);
assertThat(value, is(caseVariableValue2));
TypedValue processVariableValue = Variables.stringValue("cba");
TypedValue processVariableValue2 = Variables.booleanValue(null);
runtimeService.setVariable(processInstanceId, variableName, processVariableValue);
runtimeService.setVariable(processInstanceId, variableName2, processVariableValue2);
// should also complete process instance
taskService.complete(queryTask().getId());
value = caseService.getVariableTyped(caseInstanceId, variableName);
assertThat(value, is(processVariableValue));
value = caseService.getVariableTyped(caseInstanceId, variableName2);
assertThat(value, is(processVariableValue2));
// 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 UpdateValueDelegate method execute.
public void execute(DelegateExecution execution) throws Exception {
TypedValue typedValue = execution.getVariableTyped("listVar");
List<JsonSerializable> var = (List<JsonSerializable>) typedValue.getValue();
JsonSerializable newElement = new JsonSerializable();
newElement.setStringProperty(STRING_PROPERTY);
// implicit update of the list, so no execution.setVariable call
var.add(newElement);
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class BusinessProcessBeanTest method test.
/* General test asserting that the business process bean is functional */
@Test
@Deployment
public void test() throws Exception {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
// start the process
businessProcess.startProcessByKey("businessProcessBeanTest").getId();
// ensure that the process is started:
assertNotNull(processEngine.getRuntimeService().createProcessInstanceQuery().singleResult());
// ensure that there is a single task waiting
Task task = processEngine.getTaskService().createTaskQuery().singleResult();
assertNotNull(task);
String value = "value";
businessProcess.setVariable("key", Variables.stringValue(value));
assertEquals(value, businessProcess.getVariable("key"));
// Typed variable API
TypedValue typedValue = businessProcess.getVariableTyped("key");
assertEquals(ValueType.STRING, typedValue.getType());
assertEquals(value, typedValue.getValue());
// Local variables
String localValue = "localValue";
businessProcess.setVariableLocal("localKey", Variables.stringValue(localValue));
assertEquals(localValue, businessProcess.getVariableLocal("localKey"));
// Local typed variable API
TypedValue typedLocalValue = businessProcess.getVariableLocalTyped("localKey");
assertEquals(ValueType.STRING, typedLocalValue.getType());
assertEquals(localValue, typedLocalValue.getValue());
// complete the task
assertEquals(task.getId(), businessProcess.startTask(task.getId()).getId());
businessProcess.completeTask();
// assert the task is completed
assertNull(processEngine.getTaskService().createTaskQuery().singleResult());
// assert that the process is ended:
assertNull(processEngine.getRuntimeService().createProcessInstanceQuery().singleResult());
}
Aggregations