use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class CaseServiceTest method testExecuteSetVariablesLocalTyped.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testExecuteSetVariablesLocalTyped() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
VariableMap variables = createVariables().putValueTyped("aVariableName", stringValue("abc")).putValueTyped("anotherVariableName", integerValue(null));
// when
caseService.withCaseExecution(caseExecutionId).setVariablesLocal(variables).execute();
// then
// query by caseExecutionId
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().caseExecutionIdIn(caseExecutionId).list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
for (VariableInstance variable : result) {
assertEquals(caseExecutionId, variable.getCaseExecutionId());
assertEquals(caseInstanceId, variable.getCaseInstanceId());
if (variable.getName().equals("aVariableName")) {
assertEquals("aVariableName", variable.getName());
assertEquals(stringValue("abc"), variable.getTypedValue());
} else if (variable.getName().equals("anotherVariableName")) {
assertEquals("anotherVariableName", variable.getName());
assertEquals(integerValue(null), variable.getTypedValue());
} else {
fail("Unexpected variable: " + variable.getName());
}
}
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class CaseServiceTest method testGetVariablesWithVariableNamesTyped.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testGetVariablesWithVariableNamesTyped() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
caseService.withCaseDefinition(caseDefinitionId).setVariable("aVariableName", "abc").setVariable("anotherVariableName", 999).setVariable("thirVariable", "xyz").create().getId();
String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
List<String> names = new ArrayList<String>();
names.add("aVariableName");
names.add("anotherVariableName");
// when
VariableMap variables = caseService.getVariablesTyped(caseExecutionId, names, true);
// then
assertNotNull(variables);
assertFalse(variables.isEmpty());
assertEquals(2, variables.size());
assertEquals("abc", variables.get("aVariableName"));
assertEquals(999, variables.get("anotherVariableName"));
assertEquals(variables, caseService.getVariables(caseExecutionId, names));
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class MultiTenancyVariableInstanceQueryTest method startProcessInstanceForTenant.
protected void startProcessInstanceForTenant(String tenant) {
String processDefinitionId = repositoryService.createProcessDefinitionQuery().tenantIdIn(tenant).singleResult().getId();
VariableMap variables = Variables.createVariables().putValue("var", "test");
runtimeService.startProcessInstanceById(processDefinitionId, variables);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToVariableInstanceFromHumanTask.
public void testPropagateTenantIdToVariableInstanceFromHumanTask() {
deploymentForTenant(TENANT_ID, CMMN_FILE);
createCaseInstance();
VariableMap variables = Variables.createVariables().putValue("var", "test");
CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
caseService.setVariables(caseExecution.getId(), variables);
VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
assertThat(variableInstance, is(notNullValue()));
// inherit the tenant id from human task
assertThat(variableInstance.getTenantId(), is(TENANT_ID));
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToVariableInstanceOnCreateCaseInstance.
public void testPropagateTenantIdToVariableInstanceOnCreateCaseInstance() {
deploymentForTenant(TENANT_ID, CMMN_FILE);
VariableMap variables = Variables.putValue("var", "test");
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
caseService.createCaseInstanceById(caseDefinition.getId(), variables);
VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
assertThat(variableInstance, is(notNullValue()));
// inherit the tenant id from case instance
assertThat(variableInstance.getTenantId(), is(TENANT_ID));
}
Aggregations