Search in sources :

Example 76 with CaseInstance

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());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 77 with CaseInstance

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));
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) NativeHistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.NativeHistoricDecisionInstanceQuery) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 78 with CaseInstance

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());
    }
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) Task(org.camunda.bpm.engine.task.Task) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 79 with CaseInstance

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()));
}
Also used : DecisionServiceDelegate(org.camunda.bpm.engine.test.history.DecisionServiceDelegate) CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 80 with CaseInstance

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
    }
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) 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