Search in sources :

Example 56 with VariableMap

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

the class CaseCallActivityTest method testInputSourceExpression.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputSourceExpression.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSourceExpression() {
    // given
    VariableMap parameters = Variables.createVariables().putValue("aVariable", "abc").putValue("anotherVariable", 999);
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, parameters).getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(subCaseInstance.getId()).list();
    assertFalse(variables.isEmpty());
    assertEquals(2, variables.size());
    for (VariableInstance variable : variables) {
        String name = variable.getName();
        if ("aVariable".equals(name)) {
            assertEquals("aVariable", name);
            assertEquals("abc", variable.getValue());
        } else if ("anotherVariable".equals(name)) {
            assertEquals("anotherVariable", name);
            assertEquals((long) 1000, variable.getValue());
        } else {
            fail("Found an unexpected variable: '" + name + "'");
        }
    }
    // complete ////////////////////////////////////////////////////////
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    complete(humanTaskId);
    close(subCaseInstance.getId());
    assertProcessEnded(superProcessInstanceId);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 57 with VariableMap

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

the class CaseCallActivityTest method testInputSource.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputSource.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSource() {
    // given
    VariableMap parameters = Variables.createVariables().putValue("aVariable", "abc").putValue("anotherVariable", 999).putValue("aThirdVariable", "def");
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, parameters).getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(subCaseInstance.getId()).list();
    assertFalse(variables.isEmpty());
    assertEquals(2, variables.size());
    for (VariableInstance variable : variables) {
        String name = variable.getName();
        if ("aVariable".equals(name)) {
            assertEquals("aVariable", name);
            assertEquals("abc", variable.getValue());
        } else if ("anotherVariable".equals(name)) {
            assertEquals("anotherVariable", name);
            assertEquals(999, variable.getValue());
        } else {
            fail("Found an unexpected variable: '" + name + "'");
        }
    }
    // complete ////////////////////////////////////////////////////////
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    complete(humanTaskId);
    close(subCaseInstance.getId());
    assertProcessEnded(superProcessInstanceId);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 58 with VariableMap

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

the class CaseCallActivityTest method testInputSourceAsCompositeExpression.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputSourceAsCompositeExpression.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSourceAsCompositeExpression() {
    // given
    VariableMap parameters = Variables.createVariables().putValue("aVariable", "abc").putValue("anotherVariable", 999);
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, parameters).getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(subCaseInstance.getId()).list();
    assertFalse(variables.isEmpty());
    assertEquals(2, variables.size());
    for (VariableInstance variable : variables) {
        String name = variable.getName();
        if ("aVariable".equals(name)) {
            assertEquals("aVariable", name);
            assertEquals("Prefixabc", variable.getValue());
        } else if ("anotherVariable".equals(name)) {
            assertEquals("anotherVariable", name);
            assertEquals("Prefix" + (long) 1000, variable.getValue());
        } else {
            fail("Found an unexpected variable: '" + name + "'");
        }
    }
    // complete ////////////////////////////////////////////////////////
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    complete(humanTaskId);
    close(subCaseInstance.getId());
    assertProcessEnded(superProcessInstanceId);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 59 with VariableMap

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

the class CaseCallActivityTest method testInputSourceDifferentTarget.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputSourceDifferentTarget.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSourceDifferentTarget() {
    // given
    VariableMap parameters = Variables.createVariables().putValue("aVariable", "abc").putValue("anotherVariable", 999).putValue("aThirdVariable", "def");
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, parameters).getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(subCaseInstance.getId()).list();
    assertFalse(variables.isEmpty());
    assertEquals(2, variables.size());
    for (VariableInstance variable : variables) {
        String name = variable.getName();
        if ("myVariable".equals(name)) {
            assertEquals("myVariable", name);
            assertEquals("abc", variable.getValue());
        } else if ("myAnotherVariable".equals(name)) {
            assertEquals("myAnotherVariable", name);
            assertEquals(999, variable.getValue());
        } else {
            fail("Found an unexpected variable: '" + name + "'");
        }
    }
    // complete ////////////////////////////////////////////////////////
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    complete(humanTaskId);
    close(subCaseInstance.getId());
    assertProcessEnded(superProcessInstanceId);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 60 with VariableMap

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

the class CaseCallActivityTest method testInputDifferentBusinessKey.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputDifferentBusinessKey.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputDifferentBusinessKey() {
    // given
    String myBusinessKey = "myBusinessKey";
    String myOwnBusinessKey = "myOwnBusinessKey";
    VariableMap variables = Variables.createVariables().putValue(myOwnBusinessKey, myOwnBusinessKey);
    // when
    String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, variables, myBusinessKey).getId();
    // then
    String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());
    assertEquals(myOwnBusinessKey, subCaseInstance.getBusinessKey());
    // complete ////////////////////////////////////////////////////////
    String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
    complete(humanTaskId);
    close(subCaseInstance.getId());
    assertProcessEnded(superProcessInstanceId);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) VariableMap(org.camunda.bpm.engine.variable.VariableMap) 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