Search in sources :

Example 6 with StringValue

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

the class StartProcessTest method testStartProcessByKey.

@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/StartProcessTest.bpmn20.xml")
public void testStartProcessByKey() {
    assertNull(runtimeService.createProcessInstanceQuery().singleResult());
    getBeanInstance(DeclarativeProcessController.class).startProcessByKey();
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    assertNotNull(runtimeService.createProcessInstanceQuery().singleResult());
    assertEquals("camunda", businessProcess.getVariable("name"));
    TypedValue nameTypedValue = businessProcess.getVariableTyped("name");
    assertNotNull(nameTypedValue);
    assertTrue(nameTypedValue instanceof StringValue);
    assertEquals(ValueType.STRING, nameTypedValue.getType());
    assertEquals("camunda", nameTypedValue.getValue());
    assertEquals("untypedName", businessProcess.getVariable("untypedName"));
    TypedValue untypedNameTypedValue = businessProcess.getVariableTyped("untypedName");
    assertNotNull(untypedNameTypedValue);
    assertTrue(untypedNameTypedValue instanceof StringValue);
    assertEquals(ValueType.STRING, untypedNameTypedValue.getType());
    assertEquals("untypedName", untypedNameTypedValue.getValue());
    assertEquals("typedName", businessProcess.getVariable("typedName"));
    TypedValue typedNameTypedValue = businessProcess.getVariableTyped("typedName");
    assertNotNull(typedNameTypedValue);
    assertTrue(typedNameTypedValue instanceof StringValue);
    assertEquals(ValueType.STRING, typedNameTypedValue.getType());
    assertEquals("typedName", typedNameTypedValue.getValue());
    businessProcess.startTask(taskService.createTaskQuery().singleResult().getId());
    businessProcess.completeTask();
}
Also used : 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 7 with StringValue

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

the class MultiTenancyCaseInstanceCmdsTenantCheckTest method getVariableTypedWithAuthenticatedTenant.

@Test
public void getVariableTypedWithAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    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 8 with StringValue

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

the class CaseServiceTest method testGetVariableTypedLocal.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testGetVariableTypedLocal() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create().getId();
    String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).setVariableLocal("aSerializedObject", Variables.objectValue(Arrays.asList("1", "2")).create()).execute();
    // when
    StringValue stringValue = caseService.getVariableLocalTyped(caseExecutionId, "aVariableName");
    ObjectValue objectValue = caseService.getVariableLocalTyped(caseExecutionId, "aSerializedObject");
    ObjectValue serializedObjectValue = caseService.getVariableLocalTyped(caseExecutionId, "aSerializedObject", false);
    // then
    assertNotNull(stringValue.getValue());
    assertNotNull(objectValue.getValue());
    assertTrue(objectValue.isDeserialized());
    assertEquals(Arrays.asList("1", "2"), objectValue.getValue());
    assertFalse(serializedObjectValue.isDeserialized());
    assertNotNull(serializedObjectValue.getValueSerialized());
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) StringValue(org.camunda.bpm.engine.variable.value.StringValue) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with StringValue

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

the class CaseServiceTest method testGetVariableTyped.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testGetVariableTyped() {
    // 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("aSerializedObject", Variables.objectValue(Arrays.asList("1", "2")).create()).create().getId();
    String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // when
    StringValue stringValue = caseService.getVariableTyped(caseExecutionId, "aVariableName");
    ObjectValue objectValue = caseService.getVariableTyped(caseExecutionId, "aSerializedObject");
    ObjectValue serializedObjectValue = caseService.getVariableTyped(caseExecutionId, "aSerializedObject", false);
    // then
    assertNotNull(stringValue.getValue());
    assertNotNull(objectValue.getValue());
    assertTrue(objectValue.isDeserialized());
    assertEquals(Arrays.asList("1", "2"), objectValue.getValue());
    assertFalse(serializedObjectValue.isDeserialized());
    assertNotNull(serializedObjectValue.getValueSerialized());
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) StringValue(org.camunda.bpm.engine.variable.value.StringValue) Deployment(org.camunda.bpm.engine.test.Deployment)

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