Search in sources :

Example 1 with StringValue

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

the class ProcessVariableTypedTest method testProcessVariableTypeAnnotation.

@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testProcessVariableTypeAnnotation() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    VariableMap variables = Variables.createVariables().putValue("injectedValue", "camunda");
    businessProcess.startProcessByKey("keyOfTheProcess", variables);
    TypedValue value = getBeanInstance(DeclarativeProcessController.class).getInjectedValue();
    assertNotNull(value);
    assertTrue(value instanceof StringValue);
    assertEquals(ValueType.STRING, value.getType());
    assertEquals("camunda", value.getValue());
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) DeclarativeProcessController(org.camunda.bpm.engine.cdi.test.impl.beans.DeclarativeProcessController) StringValue(org.camunda.bpm.engine.variable.value.StringValue) BusinessProcess(org.camunda.bpm.engine.cdi.BusinessProcess) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 2 with StringValue

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

the class ProcessVariableLocalTypedTest method testProcessVariableLocalTypeAnnotation.

@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testProcessVariableLocalTypeAnnotation() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    VariableMap variables = Variables.createVariables().putValue("injectedLocalValue", "camunda");
    businessProcess.startProcessByKey("keyOfTheProcess", variables);
    TypedValue value = getBeanInstance(DeclarativeProcessController.class).getInjectedLocalValue();
    assertNotNull(value);
    assertTrue(value instanceof StringValue);
    assertEquals(ValueType.STRING, value.getType());
    assertEquals("camunda", value.getValue());
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) DeclarativeProcessController(org.camunda.bpm.engine.cdi.test.impl.beans.DeclarativeProcessController) StringValue(org.camunda.bpm.engine.variable.value.StringValue) BusinessProcess(org.camunda.bpm.engine.cdi.BusinessProcess) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 3 with StringValue

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

the class MultiTenancyCaseInstanceCmdsTenantCheckTest method getVariableTypedDisabledTenantCheck.

@Test
public void getVariableTypedDisabledTenantCheck() {
    identityService.setAuthentication("user", null, null);
    processEngineConfiguration.setTenantCheckEnabled(false);
    StringValue variable = caseService.getVariableTyped(caseExecutionId, VARIABLE_NAME);
    assertThat(variable.getValue(), is(VARIABLE_VALUE));
}
Also used : StringValue(org.camunda.bpm.engine.variable.value.StringValue) Test(org.junit.Test)

Example 4 with StringValue

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

the class TaskVariablesTest method testTaskExecutionVariables.

@Deployment
public void testTaskExecutionVariables() {
    String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId();
    String taskId = taskService.createTaskQuery().singleResult().getId();
    Map<String, Object> expectedVariables = new HashMap<String, Object>();
    assertEquals(expectedVariables, runtimeService.getVariables(processInstanceId));
    assertEquals(expectedVariables, taskService.getVariables(taskId));
    assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId));
    assertEquals(expectedVariables, taskService.getVariablesLocal(taskId));
    runtimeService.setVariable(processInstanceId, "instrument", "trumpet");
    expectedVariables = new HashMap<String, Object>();
    assertEquals(expectedVariables, taskService.getVariablesLocal(taskId));
    expectedVariables.put("instrument", "trumpet");
    assertEquals(expectedVariables, runtimeService.getVariables(processInstanceId));
    assertEquals(expectedVariables, taskService.getVariables(taskId));
    assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId));
    taskService.setVariable(taskId, "player", "gonzo");
    expectedVariables = new HashMap<String, Object>();
    assertEquals(expectedVariables, taskService.getVariablesLocal(taskId));
    expectedVariables.put("player", "gonzo");
    expectedVariables.put("instrument", "trumpet");
    assertEquals(expectedVariables, runtimeService.getVariables(processInstanceId));
    assertEquals(expectedVariables, taskService.getVariables(taskId));
    assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId));
    assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId, null));
    assertEquals(expectedVariables, runtimeService.getVariablesLocalTyped(processInstanceId, null, true));
    taskService.setVariableLocal(taskId, "budget", "unlimited");
    expectedVariables = new HashMap<String, Object>();
    expectedVariables.put("budget", "unlimited");
    assertEquals(expectedVariables, taskService.getVariablesLocal(taskId));
    assertEquals(expectedVariables, taskService.getVariablesLocalTyped(taskId, true));
    expectedVariables.put("player", "gonzo");
    expectedVariables.put("instrument", "trumpet");
    assertEquals(expectedVariables, taskService.getVariables(taskId));
    assertEquals(expectedVariables, taskService.getVariablesTyped(taskId, true));
    assertEquals(expectedVariables, taskService.getVariables(taskId, null));
    assertEquals(expectedVariables, taskService.getVariablesTyped(taskId, null, true));
    expectedVariables = new HashMap<String, Object>();
    expectedVariables.put("player", "gonzo");
    expectedVariables.put("instrument", "trumpet");
    assertEquals(expectedVariables, runtimeService.getVariables(processInstanceId));
    assertEquals(expectedVariables, runtimeService.getVariablesLocal(processInstanceId));
    // typed variable API
    ArrayList<String> serializableValue = new ArrayList<String>();
    serializableValue.add("1");
    serializableValue.add("2");
    taskService.setVariable(taskId, "objectVariable", objectValue(serializableValue).create());
    ArrayList<String> serializableValueLocal = new ArrayList<String>();
    serializableValueLocal.add("3");
    serializableValueLocal.add("4");
    taskService.setVariableLocal(taskId, "objectVariableLocal", objectValue(serializableValueLocal).create());
    Object value = taskService.getVariable(taskId, "objectVariable");
    assertEquals(serializableValue, value);
    Object valueLocal = taskService.getVariableLocal(taskId, "objectVariableLocal");
    assertEquals(serializableValueLocal, valueLocal);
    ObjectValue typedValue = taskService.getVariableTyped(taskId, "objectVariable");
    assertEquals(serializableValue, typedValue.getValue());
    ObjectValue serializedValue = taskService.getVariableTyped(taskId, "objectVariable", false);
    assertFalse(serializedValue.isDeserialized());
    ObjectValue typedValueLocal = taskService.getVariableLocalTyped(taskId, "objectVariableLocal");
    assertEquals(serializableValueLocal, typedValueLocal.getValue());
    ObjectValue serializedValueLocal = taskService.getVariableLocalTyped(taskId, "objectVariableLocal", false);
    assertFalse(serializedValueLocal.isDeserialized());
    try {
        StringValue val = taskService.getVariableTyped(taskId, "objectVariable");
        fail("expected exception");
    } catch (ClassCastException e) {
    // happy path
    }
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StringValue(org.camunda.bpm.engine.variable.value.StringValue) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with StringValue

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

the class HistoricDecisionInstanceRestServiceQueryTest method verifyStringValue.

protected void verifyStringValue(Map<String, Object> stringValue) {
    StringValue exampleValue = MockProvider.EXAMPLE_HISTORIC_DECISION_STRING_VALUE;
    assertThat(stringValue, hasEntry("type", (Object) VariableValueDto.toRestApiTypeName(exampleValue.getType().getName())));
    assertThat(stringValue, hasEntry("value", (Object) exampleValue.getValue()));
    assertThat(stringValue, hasEntry("valueInfo", (Object) Collections.emptyMap()));
}
Also used : StringValue(org.camunda.bpm.engine.variable.value.StringValue)

Aggregations

StringValue (org.camunda.bpm.engine.variable.value.StringValue)9 Deployment (org.camunda.bpm.engine.test.Deployment)6 Test (org.junit.Test)5 BusinessProcess (org.camunda.bpm.engine.cdi.BusinessProcess)3 DeclarativeProcessController (org.camunda.bpm.engine.cdi.test.impl.beans.DeclarativeProcessController)3 ObjectValue (org.camunda.bpm.engine.variable.value.ObjectValue)3 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)3 VariableMap (org.camunda.bpm.engine.variable.VariableMap)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1