Search in sources :

Example 61 with TypedValue

use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.

the class JavaSerializationTest method testSetUntypedNullForExistingVariable.

@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetUntypedNullForExistingVariable() throws Exception {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    // initially the variable has a value
    JavaSerializable javaSerializable = new JavaSerializable("foo");
    runtimeService.setVariable(instance.getId(), "varName", objectValue(javaSerializable).serializationDataFormat(JAVA_DATA_FORMAT).create());
    // get value via untyped api
    assertEquals(javaSerializable, runtimeService.getVariable(instance.getId(), "varName"));
    // set the variable to null via untyped Api
    runtimeService.setVariable(instance.getId(), "varName", null);
    // variable is now untyped null
    TypedValue nullValue = runtimeService.getVariableTyped(instance.getId(), "varName");
    assertUntypedNullValue(nullValue);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 62 with TypedValue

use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.

the class PrimitiveTypeValueSerializationTest method shouldGetTypedVariable.

@Test
public void shouldGetTypedVariable() {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
    runtimeService.setVariable(instance.getId(), VARIABLE_NAME, typedValue);
    TypedValue typedVariableValue = runtimeService.getVariableTyped(instance.getId(), VARIABLE_NAME);
    assertEquals(typedValue.getType(), typedVariableValue.getType());
    assertEquals(typedValue.getValue(), typedVariableValue.getValue());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test)

Example 63 with TypedValue

use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.

the class AbstractVariableScope method setVariableLocal.

public void setVariableLocal(String variableName, Object value) {
    TypedValue typedValue = Variables.untypedValue(value);
    setVariableLocal(variableName, typedValue, getSourceActivityVariableScope());
}
Also used : TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 64 with TypedValue

use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.

the class AbstractVariableScope method setVariableLocalTransient.

/**
 * Sets a variable in the local scope. In contrast to
 * {@link #setVariableLocal(String, Object)}, the variable is transient that
 * means it will not be stored in the data base. For example, a transient
 * variable can be used for a result variable that is only available for
 * output mapping.
 */
public void setVariableLocalTransient(String variableName, Object value) {
    TypedValue typedValue = Variables.untypedValue(value);
    checkJavaSerialization(variableName, typedValue);
    CoreVariableInstance coreVariableInstance = getVariableInstanceFactory().build(variableName, typedValue, true);
    getVariableStore().addVariable(coreVariableInstance);
}
Also used : CoreVariableInstance(org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 65 with TypedValue

use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.

the class AbstractVariableScope method initializeVariableStore.

public void initializeVariableStore(Map<String, Object> variables) {
    for (String variableName : variables.keySet()) {
        TypedValue value = Variables.untypedValue(variables.get(variableName));
        CoreVariableInstance variableValue = getVariableInstanceFactory().build(variableName, value, false);
        getVariableStore().addVariable(variableValue);
    }
}
Also used : CoreVariableInstance(org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Aggregations

TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)81 Test (org.junit.Test)25 Deployment (org.camunda.bpm.engine.test.Deployment)15 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)14 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)11 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)8 VariableMap (org.camunda.bpm.engine.variable.VariableMap)7 DmnDataTypeTransformer (org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer)6 BusinessProcess (org.camunda.bpm.engine.cdi.BusinessProcess)6 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)4 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)4 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)3 DeclarativeProcessController (org.camunda.bpm.engine.cdi.test.impl.beans.DeclarativeProcessController)3 RestException (org.camunda.bpm.engine.rest.exception.RestException)3 Task (org.camunda.bpm.engine.task.Task)3 ArrayList (java.util.ArrayList)2 DmnDecisionResultEntries (org.camunda.bpm.dmn.engine.DmnDecisionResultEntries)2 DmnDecisionRuleResult (org.camunda.bpm.dmn.engine.DmnDecisionRuleResult)2 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2