Search in sources :

Example 51 with CaseInstance

use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.

the class CmmnDecisionTaskResultMappingTest method testSingleResultMapping.

@SuppressWarnings("unchecked")
@Deployment(resources = { SINGLE_RESULT_MAPPING_CMMN, TEST_DECISION })
public void testSingleResultMapping() {
    CaseInstance caseInstance = createTestCase("multiple entries");
    Map<String, Object> output = (Map<String, Object>) caseService.getVariable(caseInstance.getId(), "result");
    assertEquals(2, output.size());
    assertEquals("foo", output.get("result1"));
    assertEquals("bar", output.get("result2"));
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Map(java.util.Map) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 52 with CaseInstance

use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.

the class CmmnDecisionTaskResultMappingTest method testTransientDecisionResult.

@Deployment(resources = { DEFAULT_MAPPING_CMMN, TEST_DECISION })
public void testTransientDecisionResult() {
    // when a decision is evaluated and the result is stored in a transient variable "decisionResult"
    CaseInstance caseInstance = createTestCase("single entry");
    // then the variable should not be available outside the decision task
    assertNull(caseService.getVariable(caseInstance.getId(), "decisionResult"));
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 53 with CaseInstance

use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.

the class CmmnDecisionTaskResultMappingTest method testSingleEntryMapping.

@Deployment(resources = { SINGLE_ENTRY_MAPPING_CMMN, TEST_DECISION })
public void testSingleEntryMapping() {
    CaseInstance caseInstance = createTestCase("single entry");
    assertEquals("foo", caseService.getVariable(caseInstance.getId(), "result"));
    assertEquals(Variables.stringValue("foo"), caseService.getVariableTyped(caseInstance.getId(), "result"));
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 54 with CaseInstance

use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.

the class VariableListenerTest method FAILING_testListenerDoesNotInterfereWithHistory.

/**
 * TODO: add when history for case execution variables is implemented
 */
@Deployment
public void FAILING_testListenerDoesNotInterfereWithHistory() {
    CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();
    // when i set a variable that causes the listener to be notified
    // and that listener sets the same variable to another value (here "value2")
    caseService.withCaseExecution(caseInstance.getId()).setVariableLocal("variable", "value1").execute();
    // then there should be two historic variable updates for both values
    if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_FULL.getId()) {
        List<HistoricDetail> variableUpdates = historyService.createHistoricDetailQuery().variableUpdates().list();
        assertEquals(2, variableUpdates.size());
        for (HistoricDetail detail : variableUpdates) {
            HistoricVariableUpdate update = (HistoricVariableUpdate) detail;
            boolean update1Processed = false;
            boolean update2Processed = false;
            if (!update1Processed && update.getValue().equals("value1")) {
                update1Processed = true;
            } else if (!update2Processed && update.getValue().equals("value2")) {
                update2Processed = true;
            } else {
                fail("unexpected variable update");
            }
        }
    }
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 55 with CaseInstance

use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.

the class VariableListenerTest method testListenerSourceExecution.

@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/listener/VariableListenerTest.testListenerOnParentScope.cmmn")
public void testListenerSourceExecution() {
    CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();
    CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNotNull(taskExecution);
    // when i set a variable on a deeper scope execution but actually on the parent
    caseService.withCaseExecution(taskExecution.getId()).setVariable("aTaskVariable", "aTaskValue").execute();
    // then the listener is invoked
    assertEquals(1, LogVariableListener.getInvocations().size());
    // and the source execution is the execution the variable was set on
    DelegateVariableInstanceSpec.fromCaseExecution(caseInstance).sourceExecution(taskExecution).event(VariableListener.CREATE).name("aTaskVariable").value("aTaskValue").matches(LogVariableListener.getInvocations().get(0));
    LogVariableListener.reset();
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)183 Deployment (org.camunda.bpm.engine.test.Deployment)149 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)62 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)23 Test (org.junit.Test)21 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)18 Task (org.camunda.bpm.engine.task.Task)18 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)16 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)13 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)10 HashMap (java.util.HashMap)9 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)9 ArrayList (java.util.ArrayList)6 CaseService (org.camunda.bpm.engine.CaseService)6 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)6 Date (java.util.Date)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)5 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 VariableMap (org.camunda.bpm.engine.variable.VariableMap)5