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"));
}
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"));
}
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"));
}
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");
}
}
}
}
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();
}
Aggregations