use of org.camunda.bpm.engine.runtime.CaseExecution 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();
}
use of org.camunda.bpm.engine.runtime.CaseExecution 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());
}
use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class RepetitionRuleTest method testRepeatStageWithoutEntryCriteriaWhenCompleting.
@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/repetition/RepetitionRuleTest.testRepeatStageWithoutEntryCriteria.cmmn")
public void testRepeatStageWithoutEntryCriteriaWhenCompleting() {
// given
String caseInstanceId = createCaseInstanceByKey(CASE_ID, Variables.createVariables().putValue("repeating", true)).getId();
CaseExecutionQuery stageQuery = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
assertEquals(1, stageQuery.count());
CaseExecution activeStageCaseExecution = stageQuery.active().singleResult();
assertNotNull(activeStageCaseExecution);
CaseExecution humanTaskCaseExecution = queryCaseExecutionByActivityId("PI_HumanTask_1");
// when (1)
complete(humanTaskCaseExecution.getId());
// then (1)
stageQuery = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
assertEquals(1, stageQuery.count());
activeStageCaseExecution = stageQuery.active().singleResult();
assertNotNull(activeStageCaseExecution);
humanTaskCaseExecution = queryCaseExecutionByActivityId("PI_HumanTask_1");
// when (2)
caseService.setVariable(caseInstanceId, "repeating", false);
complete(humanTaskCaseExecution.getId());
// then (3)
CaseExecutionQuery query = caseService.createCaseExecutionQuery();
assertEquals(1, query.count());
assertEquals(caseInstanceId, query.singleResult().getId());
}
use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class RepetitionRuleTest method testRepeatStageMultipleTimes.
@Deployment
public void testRepeatStageMultipleTimes() {
// given
createCaseInstance();
String firstHumanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
// when (1)
disable(firstHumanTaskId);
// then (1)
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);
// when (2)
reenable(firstHumanTaskId);
disable(firstHumanTaskId);
// then (2)
query = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
assertEquals(3, query.count());
// enabled instances
assertEquals(2, query.active().count());
// available instances
assertEquals(1, query.available().count());
}
use of org.camunda.bpm.engine.runtime.CaseExecution in project camunda-bpm-platform by camunda.
the class RepetitionRuleTest method testRepeatStageWithoutEntryCriteriaOnCustomStandardEvent.
@Deployment
public void testRepeatStageWithoutEntryCriteriaOnCustomStandardEvent() {
// given
String caseInstanceId = createCaseInstance().getId();
CaseExecutionQuery stageQuery = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
assertEquals(1, stageQuery.count());
CaseExecution enabledStageCaseExecution = stageQuery.enabled().singleResult();
assertNotNull(enabledStageCaseExecution);
// when (1)
disable(enabledStageCaseExecution.getId());
// then (1)
stageQuery = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
assertEquals(2, stageQuery.count());
enabledStageCaseExecution = stageQuery.enabled().singleResult();
assertNotNull(enabledStageCaseExecution);
// when (2)
disable(enabledStageCaseExecution.getId());
// then (2)
stageQuery = caseService.createCaseExecutionQuery().activityId("PI_Stage_1");
assertEquals(3, stageQuery.count());
enabledStageCaseExecution = stageQuery.enabled().singleResult();
assertNotNull(enabledStageCaseExecution);
// when (3)
complete(caseInstanceId);
// then (3)
CaseExecutionQuery query = caseService.createCaseExecutionQuery();
assertEquals(1, query.count());
assertEquals(caseInstanceId, query.singleResult().getId());
}
Aggregations