Search in sources :

Example 66 with CaseExecution

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

the class CaseTaskTest method testTerminateSubCaseInstance.

/**
 * removed manual start as it is handled by default behaviour
 */
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testTerminateSubCaseInstance() {
    // given
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE).getId();
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
    String subCaseInstanceId = queryOneTaskCaseInstance().getId();
    // when
    terminate(subCaseInstanceId);
    // then
    CmmnExecution subCaseInstance = (CmmnExecution) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    assertTrue(subCaseInstance.isTerminated());
    CaseExecution caseTask = queryCaseExecutionByActivityId(CASE_TASK);
    assertNotNull(caseTask);
    assertTrue(caseTask.isActive());
    // complete ////////////////////////////////////////////////////////
    close(subCaseInstanceId);
    assertCaseEnded(subCaseInstanceId);
    terminate(caseTaskId);
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 67 with CaseExecution

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

the class CaseTaskTest method testCallCaseAsConstant.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseAsConstant() {
    // given
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE).getId();
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId();
    CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId);
    assertEquals(caseTaskId, superCaseExecutionId);
    assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId());
    // complete ////////////////////////////////////////////////////////
    terminate(subCaseInstance.getId());
    close(subCaseInstance.getId());
    assertCaseEnded(subCaseInstance.getId());
    terminate(caseTaskId);
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 68 with CaseExecution

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

the class CaseTaskTest method testCallLatestCase.

/**
 * assert on default behaviour - remove manual activation
 */
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testCallLatestCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallLatestCase() {
    // given
    String cmmnResourceName = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn";
    String deploymentId = repositoryService.createDeployment().addClasspathResource(cmmnResourceName).deploy().getId();
    assertEquals(3, repositoryService.createCaseDefinitionQuery().count());
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE).getId();
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
    String latestCaseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(ONE_TASK_CASE).latestVersion().singleResult().getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId();
    CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId);
    assertEquals(caseTaskId, superCaseExecutionId);
    assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId());
    assertEquals(latestCaseDefinitionId, subCaseInstance.getCaseDefinitionId());
    // complete ////////////////////////////////////////////////////////
    terminate(subCaseInstance.getId());
    close(subCaseInstance.getId());
    assertCaseEnded(subCaseInstance.getId());
    terminate(caseTaskId);
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
    repositoryService.deleteDeployment(deploymentId, true);
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 69 with CaseExecution

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

the class VariableListenerTest method testInvalidListenerClassName.

@Deployment
public void testInvalidListenerClassName() {
    caseService.withCaseDefinitionByKey("case").create();
    CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNotNull(taskExecution);
    try {
        caseService.withCaseExecution(taskExecution.getId()).setVariableLocal("aTaskVariable", "aTaskValue").execute();
        fail("expected exception during variable listener invocation");
    } catch (ProcessEngineException e) {
    // happy path
    }
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 70 with CaseExecution

use of org.camunda.bpm.engine.runtime.CaseExecution 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

CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)280 Deployment (org.camunda.bpm.engine.test.Deployment)246 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)61 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)48 Task (org.camunda.bpm.engine.task.Task)28 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)27 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)18 Test (org.junit.Test)17 HashMap (java.util.HashMap)13 HistoricCaseActivityInstance (org.camunda.bpm.engine.history.HistoricCaseActivityInstance)11 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)11 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 VariableMap (org.camunda.bpm.engine.variable.VariableMap)7 DelegateCaseExecution (org.camunda.bpm.engine.delegate.DelegateCaseExecution)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)4 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)3 ArrayList (java.util.ArrayList)2 CaseService (org.camunda.bpm.engine.CaseService)2