Search in sources :

Example 96 with CaseExecutionQuery

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

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

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

the class RepetitionRuleTest method testRepeatMilestoneMultipleTimes.

@Deployment
public void testRepeatMilestoneMultipleTimes() {
    // given
    createCaseInstance();
    String firstHumanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    String milestoneId = queryCaseExecutionByActivityId("PI_Milestone_1").getId();
    // when (1)
    disable(firstHumanTaskId);
    // then (2)
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_Milestone_1");
    assertEquals(1, query.count());
    assertTrue(query.singleResult().isAvailable());
    assertFalse(milestoneId.equals(query.singleResult().getId()));
    // when (2)
    reenable(firstHumanTaskId);
    disable(firstHumanTaskId);
    // then (2)
    query = caseService.createCaseExecutionQuery().activityId("PI_Milestone_1");
    assertEquals(1, query.count());
    assertTrue(query.singleResult().isAvailable());
    assertFalse(milestoneId.equals(query.singleResult().getId()));
}
Also used : CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 99 with CaseExecutionQuery

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

the class RepetitionRuleTest method testRepeatMilestone.

@Deployment
public void testRepeatMilestone() {
    // given
    createCaseInstance();
    String firstHumanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    String milestoneId = queryCaseExecutionByActivityId("PI_Milestone_1").getId();
    // when
    complete(firstHumanTaskId);
    // then
    CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_Milestone_1");
    assertEquals(1, query.count());
    assertTrue(query.singleResult().isAvailable());
    assertFalse(milestoneId.equals(query.singleResult().getId()));
}
Also used : CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 100 with CaseExecutionQuery

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

Aggregations

CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)226 Deployment (org.camunda.bpm.engine.test.Deployment)70 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)47 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)24 NotValidException (org.camunda.bpm.engine.exception.NotValidException)24 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)16 ArrayList (java.util.ArrayList)14 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)13 Date (java.util.Date)12 Task (org.camunda.bpm.engine.task.Task)10 VariableMap (org.camunda.bpm.engine.variable.VariableMap)9 HashMap (java.util.HashMap)8 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)4 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)4 CaseService (org.camunda.bpm.engine.CaseService)2 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)2 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)2 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)2 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 CaseExecutionDto (org.camunda.bpm.engine.rest.dto.runtime.CaseExecutionDto)1