Search in sources :

Example 61 with CaseInstance

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

the class VariableListenerTest method testVariableListenerExecutionContext.

@Deployment
public void testVariableListenerExecutionContext() {
    CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();
    CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNotNull(taskExecution);
    // when i set a variable
    caseService.withCaseExecution(taskExecution.getId()).setVariableLocal("testVariable", "value1").execute();
    // then the listener is invoked
    assertEquals(1, LogExecutionContextListener.getCaseExecutionContexts().size());
    CaseExecutionContext executionContext = LogExecutionContextListener.getCaseExecutionContexts().get(0);
    assertNotNull(executionContext);
    // although this is not inside a command, checking for IDs should be ok
    assertEquals(caseInstance.getId(), executionContext.getCaseInstance().getId());
    assertEquals(taskExecution.getId(), executionContext.getExecution().getId());
    LogExecutionContextListener.reset();
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionContext(org.camunda.bpm.engine.impl.context.CaseExecutionContext) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 62 with CaseInstance

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

the class MilestoneTest method testWithEntryCriteria.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/milestone/MilestoneTest.testWithEntryCriteria.cmmn" })
public void testWithEntryCriteria() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
    CaseExecution milestone = caseService.createCaseExecutionQuery().activityId("PI_Milestone_1").singleResult();
    String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    assertTrue(milestone.isAvailable());
    // then
    assertNull(caseService.getVariable(caseInstanceId, "occur"));
    milestone = caseService.createCaseExecutionQuery().available().singleResult();
    assertTrue(milestone.isAvailable());
    // when
    caseService.withCaseExecution(humanTaskId).complete();
    // then
    Object occurVariable = caseService.getVariable(caseInstanceId, "occur");
    assertNotNull(occurVariable);
    assertTrue((Boolean) occurVariable);
    milestone = caseService.createCaseExecutionQuery().available().singleResult();
    assertNull(milestone);
    CaseInstance caseInstance = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
    assertTrue(caseInstance.isCompleted());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 63 with CaseInstance

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

the class AutoCompleteTest method testManualActivationDisabled.

@Deployment
public void testManualActivationDisabled() {
    // given
    // a deployed case definition
    // when (1)
    String caseInstanceId = createCaseInstanceByKey(CASE_DEFINITION_KEY).getId();
    // then (1)
    CaseInstanceQuery instanceQuery = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId);
    CaseInstance caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
    CaseExecutionQuery executionQuery = caseService.createCaseExecutionQuery();
    String humanTask2Id = executionQuery.activityId("PI_HumanTask_2").singleResult().getId();
    // when (2)
    caseService.completeCaseExecution(humanTask2Id);
    // then (2)
    caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isCompleted());
    // humanTask1 and humanTask2 are not available
    assertNull(executionQuery.activityId("PI_HumanTask_1").singleResult());
    assertNull(executionQuery.activityId("PI_HumanTask_2").singleResult());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 64 with CaseInstance

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

the class AutoCompleteTest method testRequiredEnabledInsideStage.

@Deployment
public void testRequiredEnabledInsideStage() {
    // given
    String caseInstanceId = createCaseInstanceByKey(CASE_DEFINITION_KEY).getId();
    CaseExecutionQuery executionQuery = caseService.createCaseExecutionQuery();
    String humanTask3Id = executionQuery.activityId("PI_HumanTask_3").singleResult().getId();
    // when (1)
    complete(humanTask3Id);
    // then (1)
    CaseExecution stage = executionQuery.activityId("PI_Stage_1").singleResult();
    assertNotNull(stage);
    assertTrue(stage.isActive());
    String humanTask2Id = executionQuery.activityId("PI_HumanTask_2").singleResult().getId();
    // when (2)
    complete(humanTask2Id);
    // then (2)
    assertNull(executionQuery.activityId("PI_Stage_1").singleResult());
    CaseInstance caseInstance = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 65 with CaseInstance

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

the class AutoCompleteTest method testRequiredEnabled.

@Deployment
public void testRequiredEnabled() {
    // given
    // a deployed case definition
    CaseExecutionQuery executionQuery = caseService.createCaseExecutionQuery();
    CaseInstanceQuery instanceQuery = caseService.createCaseInstanceQuery();
    // when (1)
    String caseInstanceId = createCaseInstanceByKey(CASE_DEFINITION_KEY).getId();
    // then (1)
    CaseInstance caseInstance = instanceQuery.caseInstanceId(caseInstanceId).singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
    String humanTask1Id = executionQuery.activityId("PI_HumanTask_1").singleResult().getId();
    manualStart(humanTask1Id);
    // when (2)
    complete(humanTask1Id);
    // then (2)
    caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
    String humanTask2Id = executionQuery.activityId("PI_HumanTask_2").singleResult().getId();
    manualStart(humanTask2Id);
    // when (3)
    complete(humanTask2Id);
    // then (3)
    caseInstance = instanceQuery.singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isCompleted());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) 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