Search in sources :

Example 46 with VariableMap

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

the class MultiTenancyHistoricDecisionInstanceQueryTest method evaluateDecisionInstanceForTenant.

protected void evaluateDecisionInstanceForTenant(String tenant) {
    String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().tenantIdIn(tenant).singleResult().getId();
    VariableMap variables = Variables.createVariables().putValue("status", "bronze");
    decisionService.evaluateDecisionTableById(decisionDefinitionId, variables);
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap)

Example 47 with VariableMap

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

the class RuntimeServiceTest method testGetVariableInstancesFromVariableScope.

@Deployment
@Test
public void testGetVariableInstancesFromVariableScope() {
    VariableMap variables = createVariables().putValue("anIntegerVariable", 1234).putValue("anObjectValue", objectValue(new SimpleSerializableBean(10)).serializationDataFormat(Variables.SerializationDataFormats.JAVA)).putValue("anUntypedObjectValue", new SimpleSerializableBean(30));
    runtimeService.startProcessInstanceByKey("testProcess", variables);
// assertions are part of the java delegate AssertVariableInstancesDelegate
// only there we can access the VariableScope methods
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) SimpleSerializableBean(org.camunda.bpm.engine.test.api.runtime.util.SimpleSerializableBean) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 48 with VariableMap

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

the class RuntimeServiceTest method testGetVariablesLocalTypedDeserialize.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testGetVariablesLocalTypedDeserialize() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("broken", Variables.serializedObjectValue("broken").serializationDataFormat(Variables.SerializationDataFormats.JAVA).objectTypeName("unexisting").create()));
    // this works
    VariableMap variablesTyped = runtimeService.getVariablesLocalTyped(processInstance.getId(), false);
    assertNotNull(variablesTyped.getValueTyped("broken"));
    variablesTyped = runtimeService.getVariablesLocalTyped(processInstance.getId(), Arrays.asList("broken"), false);
    assertNotNull(variablesTyped.getValueTyped("broken"));
    // this does not
    try {
        runtimeService.getVariablesLocalTyped(processInstance.getId());
    } catch (ProcessEngineException e) {
        testRule.assertTextPresent("Cannot deserialize object", e.getMessage());
    }
    // this does not
    try {
        runtimeService.getVariablesLocalTyped(processInstance.getId(), Arrays.asList("broken"), true);
    } catch (ProcessEngineException e) {
        testRule.assertTextPresent("Cannot deserialize object", e.getMessage());
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with VariableMap

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

the class RuntimeServiceTest method testGetVariablesTyped.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testGetVariablesTyped() {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("variable1", "value1");
    vars.put("variable2", "value2");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    VariableMap variablesTyped = runtimeService.getVariablesTyped(processInstance.getId());
    assertEquals(vars, variablesTyped);
}
Also used : HashMap(java.util.HashMap) VariableMap(org.camunda.bpm.engine.variable.VariableMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 50 with VariableMap

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

the class ProcessInstantiationWithVariablesInReturnTest method testReturnVariablesFromStartWithWaitstate.

@Test
@Deployment(resources = SUBPROCESS_PROCESS)
public void testReturnVariablesFromStartWithWaitstate() {
    // given execute process with variables and wait state
    ProcessInstanceWithVariables procInstance = engineRule.getRuntimeService().createProcessInstanceByKey("subprocess").setVariable("aVariable1", "aValue1").setVariableLocal("aVariable2", "aValue2").setVariables(Variables.createVariables().putValue("aVariable3", "aValue3")).setVariablesLocal(Variables.createVariables().putValue("aVariable4", new byte[] { 127, 34, 64 })).executeWithVariablesInReturn(false, false);
    // when returned instance contains variables
    VariableMap map = procInstance.getVariables();
    assertNotNull(map);
    // then variables equal to variables which are accessible via query
    checkVariables(map, 4);
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) ProcessInstanceWithVariables(org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

VariableMap (org.camunda.bpm.engine.variable.VariableMap)228 Deployment (org.camunda.bpm.engine.test.Deployment)107 Test (org.junit.Test)57 Task (org.camunda.bpm.engine.task.Task)38 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)32 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)30 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)15 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)13 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)13 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 HashMap (java.util.HashMap)11 ProcessInstanceWithVariables (org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables)9 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)8 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)8 RestException (org.camunda.bpm.engine.rest.exception.RestException)8 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)8 Execution (org.camunda.bpm.engine.runtime.Execution)8 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)7 ThrowErrorDelegate (org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate)7