Search in sources :

Example 41 with VariableMap

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

the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToVariableInstanceFromTask.

public void testPropagateTenantIdToVariableInstanceFromTask() {
    deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().camundaAsyncAfter().endEvent().done());
    startProcessInstance(PROCESS_DEFINITION_KEY);
    VariableMap variables = Variables.createVariables().putValue("var", "test");
    Task task = taskService.createTaskQuery().singleResult();
    taskService.setVariablesLocal(task.getId(), variables);
    VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
    assertThat(variableInstance, is(notNullValue()));
    // inherit the tenant id from task
    assertThat(variableInstance.getTenantId(), is(TENANT_ID));
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Task(org.camunda.bpm.engine.task.Task) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance)

Example 42 with VariableMap

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

the class TenantIdProviderTest method providerCalledWithVariables_ProcessTask.

@Test
public void providerCalledWithVariables_ProcessTask() {
    ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
    TestTenantIdProvider.delegate = tenantIdProvider;
    testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().done(), "org/camunda/bpm/engine/test/api/multitenancy/CaseWithProcessTask.cmmn");
    // if the case is started
    engineRule.getCaseService().createCaseInstanceByKey("testCase", Variables.createVariables().putValue("varName", true));
    CaseExecution caseExecution = engineRule.getCaseService().createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult();
    // then the tenant id provider is passed in the variable
    assertThat(tenantIdProvider.parameters.size(), is(1));
    VariableMap variables = tenantIdProvider.parameters.get(0).getVariables();
    assertThat(variables.size(), is(1));
    assertThat((Boolean) variables.get("varName"), is(true));
}
Also used : DelegateCaseExecution(org.camunda.bpm.engine.delegate.DelegateCaseExecution) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableMap(org.camunda.bpm.engine.variable.VariableMap) Test(org.junit.Test)

Example 43 with VariableMap

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

the class MultiTenancyCaseInstanceCmdsTenantCheckTest method createCaseInstance.

protected String createCaseInstance(String tenantId) {
    VariableMap variables = Variables.putValue(VARIABLE_NAME, VARIABLE_VALUE);
    CaseInstanceBuilder builder = caseService.withCaseDefinitionByKey("twoTaskCase").setVariables(variables);
    if (tenantId == null) {
        return builder.create().getId();
    } else {
        return builder.caseDefinitionTenantId(tenantId).create().getId();
    }
}
Also used : CaseInstanceBuilder(org.camunda.bpm.engine.runtime.CaseInstanceBuilder) VariableMap(org.camunda.bpm.engine.variable.VariableMap)

Example 44 with VariableMap

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

the class MultiTenancyHistoricDataCmdsTenantCheckTest method evaluateDecisionTable.

protected String evaluateDecisionTable(String tenantId) {
    String decisionDefinitionId;
    if (tenantId == null) {
        decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().singleResult().getId();
    } else {
        decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().tenantIdIn(tenantId).singleResult().getId();
    }
    VariableMap variables = Variables.createVariables().putValue("status", "bronze");
    decisionService.evaluateDecisionTableById(decisionDefinitionId, variables);
    return decisionDefinitionId;
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap)

Example 45 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)

Aggregations

VariableMap (org.camunda.bpm.engine.variable.VariableMap)230 Deployment (org.camunda.bpm.engine.test.Deployment)107 Test (org.junit.Test)59 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 HashMap (java.util.HashMap)12 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 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