Search in sources :

Example 86 with CaseExecution

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

the class RepetitionRuleTest method testRepeatStage.

@Deployment
public void testRepeatStage() {
    // given
    createCaseInstance();
    String firstHumanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    // when
    complete(firstHumanTaskId);
    // then
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
    assertEquals(2, query.count());
    CaseExecution originInstance = query.active().singleResult();
    assertNotNull(originInstance);
    CaseExecution repetitionInstance = query.available().singleResult();
    assertNotNull(repetitionInstance);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 87 with CaseExecution

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

the class RepetitionRuleTest method testRepeatTaskWithoutEntryCriteriaWhenCompleting.

@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/repetition/RepetitionRuleTest.testRepeatTaskWithoutEntryCriteria.cmmn")
public void testRepeatTaskWithoutEntryCriteriaWhenCompleting() {
    // given
    String caseInstanceId = createCaseInstanceByKey(CASE_ID, Variables.createVariables().putValue("repeating", true)).getId();
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(1, query.count());
    CaseExecution activeCaseExecution = query.active().singleResult();
    assertNotNull(activeCaseExecution);
    // when (1)
    complete(activeCaseExecution.getId());
    // then (1)
    query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(1, query.count());
    activeCaseExecution = query.active().singleResult();
    assertNotNull(activeCaseExecution);
    // when (2)
    caseService.setVariable(caseInstanceId, "repeating", false);
    complete(activeCaseExecution.getId());
    // then (2)
    query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(0, query.count());
    // then (3)
    query = caseService.createCaseExecutionQuery();
    assertEquals(1, query.count());
    assertEquals(caseInstanceId, query.singleResult().getId());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 88 with CaseExecution

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

the class RepetitionRuleTest method testRepeatTaskWithoutEntryCriteriaOnCustomStandardEvent.

@Deployment
public void testRepeatTaskWithoutEntryCriteriaOnCustomStandardEvent() {
    // given
    String caseInstanceId = createCaseInstance().getId();
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(1, query.count());
    CaseExecution enabledCaseExecution = query.enabled().singleResult();
    assertNotNull(enabledCaseExecution);
    // when (1)
    disable(enabledCaseExecution.getId());
    // then (1)
    query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(2, query.count());
    enabledCaseExecution = query.enabled().singleResult();
    assertNotNull(enabledCaseExecution);
    // when (2)
    disable(enabledCaseExecution.getId());
    // then (2)
    query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1");
    assertEquals(3, query.count());
    enabledCaseExecution = query.enabled().singleResult();
    assertNotNull(enabledCaseExecution);
    // when (3)
    complete(caseInstanceId);
    // then (3)
    query = caseService.createCaseExecutionQuery();
    assertEquals(1, query.count());
    assertEquals(caseInstanceId, query.singleResult().getId());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 89 with CaseExecution

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

the class RepetitionRuleTest method testRepeatTaskMultipleTimes.

@Deployment
public void testRepeatTaskMultipleTimes() {
    // given
    createCaseInstance();
    String firstHumanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    // when (1)
    disable(firstHumanTaskId);
    // then (1)
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_2");
    assertEquals(2, query.count());
    CaseExecution originInstance = query.active().singleResult();
    assertNotNull(originInstance);
    CaseExecution repetitionInstance = query.available().singleResult();
    assertNotNull(repetitionInstance);
    // when (2)
    reenable(firstHumanTaskId);
    disable(firstHumanTaskId);
    // then (2)
    query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_2");
    assertEquals(3, query.count());
    // active instances
    assertEquals(2, query.active().count());
    // available instances
    assertEquals(1, query.available().count());
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 90 with CaseExecution

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

the class SentryCombinedEntryAndExitCriteriaTest method FAILING_testParentSuspendInsideStageDifferentPlanItemOrder.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/sentry/SentryCombinedEntryAndExitCriteriaTest.testParentSuspendInsideStageDifferentPlanItemOrder.cmmn" })
public void FAILING_testParentSuspendInsideStageDifferentPlanItemOrder() {
    // given
    createCaseInstance();
    CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
    String stageId = stage.getId();
    manualStart(stageId);
    CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
    String firstHumanTaskId = firstHumanTask.getId();
    assertTrue(firstHumanTask.isEnabled());
    CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
    String secondHumanTaskId = secondHumanTask.getId();
    assertTrue(secondHumanTask.isEnabled());
    CaseExecution thirdHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
    String thirdHumanTaskId = thirdHumanTask.getId();
    assertTrue(thirdHumanTask.isAvailable());
    // when
    suspend(stageId);
    // then
    stage = queryCaseExecutionById(stageId);
    assertTrue(((CaseExecutionEntity) stage).isSuspended());
    firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
    assertTrue(((CaseExecutionEntity) firstHumanTask).isSuspended());
    secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
    assertNull(secondHumanTask);
    thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
    assertTrue(((CaseExecutionEntity) thirdHumanTask).isSuspended());
    assertEquals(CaseExecutionState.ENABLED, ((CaseExecutionEntity) thirdHumanTask).getPreviousState());
}
Also used : 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