use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class SentryScenario method newSentryInstance.
@DescribesScenario("newSentryInstance")
public static ScenarioSetup newSentryInstance() {
return new ScenarioSetup() {
public void execute(ProcessEngine engine, String scenarioName) {
CaseService caseService = engine.getCaseService();
CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", scenarioName);
String caseInstanceId = caseInstance.getId();
CaseExecutionQuery query = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId);
String firstHumanTaskId = query.activityId("PI_HumanTask_1").singleResult().getId();
caseService.manuallyStartCaseExecution(firstHumanTaskId);
caseService.completeCaseExecution(firstHumanTaskId);
String secondHumanTaskId = query.activityId("PI_HumanTask_2").singleResult().getId();
caseService.manuallyStartCaseExecution(secondHumanTaskId);
caseService.completeCaseExecution(secondHumanTaskId);
}
};
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class SentryScenario method completeStage.
@DescribesScenario("triggerStageEntryCriterion")
public static ScenarioSetup completeStage() {
return new ScenarioSetup() {
public void execute(ProcessEngine engine, String scenarioName) {
CaseService caseService = engine.getCaseService();
CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", scenarioName);
String caseInstanceId = caseInstance.getId();
CaseExecutionQuery query = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId);
String firstHumanTaskId = query.activityId("PI_HumanTask_1").singleResult().getId();
caseService.manuallyStartCaseExecution(firstHumanTaskId);
caseService.completeCaseExecution(firstHumanTaskId);
String secondHumanTaskId = query.activityId("PI_HumanTask_2").singleResult().getId();
caseService.manuallyStartCaseExecution(secondHumanTaskId);
}
};
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testQueryByCaseInstanceIds.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseInstanceIds() {
// given
CaseInstance instance1 = createCaseInstance();
CaseInstance instance2 = createCaseInstance();
String taskInstanceId1 = caseService.createCaseExecutionQuery().caseInstanceId(instance1.getId()).activityId("PI_HumanTask_1").singleResult().getId();
String taskInstanceId2 = caseService.createCaseExecutionQuery().caseInstanceId(instance2.getId()).activityId("PI_HumanTask_1").singleResult().getId();
// when
HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityInstanceIdIn(taskInstanceId1, taskInstanceId2);
// then
assertCount(2, query);
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricCaseActivityCalledCaseInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testHistoricCaseActivityCalledCaseInstanceId() {
String taskId = "PI_CaseTask_1";
String calledCaseId = "oneTaskCase";
String calledTaskId = "PI_HumanTask_1";
createCaseInstanceByKey("oneCaseTaskCase").getId();
// as long as the case task is not activated there should be no other case instance
assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));
HistoricCaseActivityInstance historicInstance = queryHistoricActivityCaseInstance(taskId);
assertNull(historicInstance.getCalledCaseInstanceId());
// start case task manually to create case instance
CaseExecution caseTask = queryCaseExecutionByActivityId(taskId);
manualStart(caseTask.getId());
// there should exist a new case instance
CaseInstance calledCaseInstance = caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId).singleResult();
assertNotNull(calledCaseInstance);
// check that the called case instance id was correctly set
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());
// disable task to complete called case instance and close it
CaseExecution calledTask = queryCaseExecutionByActivityId(calledTaskId);
disable(calledTask.getId());
close(calledCaseInstance.getId());
// check that the called case instance id is still set
assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceTest method testHistoricCaseInstanceQuery.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn", "org/camunda/bpm/engine/test/api/repository/three_.cmmn" })
public void testHistoricCaseInstanceQuery() {
CaseInstance oneTaskCase = createCaseInstanceByKey("oneTaskCase", "oneBusiness");
CaseInstance twoTaskCase = createCaseInstanceByKey("twoTaskCase", "twoBusiness");
createCaseInstanceByKey("xyz_", "xyz_");
assertCount(1, historicQuery().caseInstanceId(oneTaskCase.getId()));
assertCount(1, historicQuery().caseInstanceId(twoTaskCase.getId()));
Set<String> caseInstanceIds = new HashSet<String>();
caseInstanceIds.add(oneTaskCase.getId());
caseInstanceIds.add("unknown1");
caseInstanceIds.add(twoTaskCase.getId());
caseInstanceIds.add("unknown2");
assertCount(2, historicQuery().caseInstanceIds(caseInstanceIds));
assertCount(0, historicQuery().caseInstanceIds(caseInstanceIds).caseInstanceId("someOtherId"));
assertCount(1, historicQuery().caseDefinitionId(oneTaskCase.getCaseDefinitionId()));
assertCount(1, historicQuery().caseDefinitionKey("oneTaskCase"));
assertCount(3, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("unknown")));
assertCount(2, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase")));
assertCount(1, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase", "twoTaskCase")));
assertCount(0, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase")).caseDefinitionKey("oneTaskCase"));
try {
// oracle handles empty string like null which seems to lead to undefined behavior of the LIKE comparison
historicQuery().caseDefinitionKeyNotIn(Arrays.asList(""));
fail("Exception expected");
} catch (NotValidException e) {
// expected
}
assertCount(1, historicQuery().caseDefinitionName("One Task Case"));
assertCount(2, historicQuery().caseDefinitionNameLike("%T%"));
assertCount(1, historicQuery().caseDefinitionNameLike("One%"));
assertCount(0, historicQuery().caseDefinitionNameLike("%Process%"));
assertCount(1, historicQuery().caseDefinitionNameLike("%z\\_"));
assertCount(1, historicQuery().caseInstanceBusinessKey("oneBusiness"));
assertCount(2, historicQuery().caseInstanceBusinessKeyLike("%Business"));
assertCount(1, historicQuery().caseInstanceBusinessKeyLike("one%"));
assertCount(0, historicQuery().caseInstanceBusinessKeyLike("%unknown%"));
assertCount(1, historicQuery().caseInstanceBusinessKeyLike("%z\\_"));
}
Aggregations