use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class SentryEntryCriteriaTest method testShouldNotTriggerCompletionTwice.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testShouldNotTriggerCompletionTwice.cmmn", "org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.noop.bpmn20.xml" })
public void testShouldNotTriggerCompletionTwice() {
// when
CaseInstance ci = caseService.createCaseInstanceByKey("case");
// then
assertTrue(ci.isCompleted());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceQueryTest method testQueryByCaseDefinitionId.
@Deployment(resources = { DECISION_CASE, DECISION_SINGLE_OUTPUT_DMN })
public void testQueryByCaseDefinitionId() {
CaseInstance caseInstance = createCaseInstanceAndEvaluateDecision();
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
assertThat(query.caseDefinitionId(caseInstance.getCaseDefinitionId()).count(), is(1L));
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testCmmnActivityInstanceIdOnTask.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCmmnActivityInstanceIdOnTask() {
// given
CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");
String taskExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
Task task = taskService.createTaskQuery().singleResult();
// when
taskService.setVariable(task.getId(), "foo", "bar");
// then
HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("foo").singleResult();
assertNotNull(variable);
assertEquals(caseInstance.getId(), variable.getActivityInstanceId());
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
HistoricDetail variableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variable.getId()).singleResult();
assertEquals(taskExecutionId, variableDetail.getActivityInstanceId());
}
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testManualActivationRuleEvaluatesDecision.
@Deployment(resources = { DECISION_CASE_WITH_DECISION_SERVICE_INSIDE_RULE, DECISION_RETURNS_TRUE })
public void testManualActivationRuleEvaluatesDecision() {
CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").setVariable("input1", null).setVariable("myBean", new DecisionServiceDelegate()).create();
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.getCaseDefinitionId()).singleResult();
String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().getId();
String activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").singleResult().getId();
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();
assertThat(historicDecisionInstance, is(notNullValue()));
assertThat(historicDecisionInstance.getDecisionDefinitionId(), is(decisionDefinitionId));
assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is(DECISION_DEFINITION_KEY));
assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("sample decision"));
// references to case instance should be set since the decision is evaluated while executing a case instance
assertThat(historicDecisionInstance.getProcessDefinitionKey(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessDefinitionId(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessInstanceId(), is(nullValue()));
assertThat(historicDecisionInstance.getCaseDefinitionKey(), is(caseDefinition.getKey()));
assertThat(historicDecisionInstance.getCaseDefinitionId(), is(caseDefinition.getId()));
assertThat(historicDecisionInstance.getCaseInstanceId(), is(caseInstance.getId()));
assertThat(historicDecisionInstance.getActivityId(), is("PI_HumanTask_1"));
assertThat(historicDecisionInstance.getActivityInstanceId(), is(activityInstanceId));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class Cmmn10CompatibilityTest method testRequiredRule.
@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/cmm10/Cmmn10CompatibilityTest.testRequiredRule.cmmn")
public void testRequiredRule() {
CaseInstance caseInstance = createCaseInstanceByKey("case", Variables.createVariables().putValue("required", true));
CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1");
assertNotNull(taskExecution);
assertTrue(taskExecution.isRequired());
try {
caseService.completeCaseExecution(caseInstance.getId());
fail("completing the containing stage should not be allowed");
} catch (NotAllowedException e) {
// happy path
}
}
Aggregations