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();
}
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());
}
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());
}
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());
}
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());
}
Aggregations