use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceCaseInstanceTest method testCreateByIdWithVariablesAndBusinessKeyNonFluent.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCreateByIdWithVariablesAndBusinessKeyNonFluent() {
// given a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// when
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("aVariable", "aValue");
CaseInstance caseInstance = caseService.createCaseInstanceById(caseDefinitionId, "aBusinessKey", variables);
// then
assertNotNull(caseInstance);
assertEquals("aBusinessKey", caseInstance.getBusinessKey());
assertEquals(1, runtimeService.createVariableInstanceQuery().caseInstanceIdIn(caseInstance.getId()).variableValueEquals("aVariable", "aValue").count());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceCaseInstanceTest method testCompleteWithEnabledTask.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testCompleteWithEnabledTask() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
// when
caseService.withCaseExecution(caseInstanceId).complete();
// then
// the corresponding case execution has been also
// deleted and completed
CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
assertNull(caseExecution);
CaseInstance caseInstance = caseService.createCaseInstanceQuery().singleResult();
assertNotNull(caseInstance);
assertTrue(caseInstance.isCompleted());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceCaseInstanceTest method testCreateByIdWithBusinessKeyNonFluent.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCreateByIdWithBusinessKeyNonFluent() {
// given a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// when
CaseInstance caseInstance = caseService.createCaseInstanceById(caseDefinitionId, "aBusinessKey");
// then
assertNotNull(caseInstance);
// check properties
assertEquals("aBusinessKey", caseInstance.getBusinessKey());
assertEquals(caseDefinitionId, caseInstance.getCaseDefinitionId());
assertEquals(caseInstance.getId(), caseInstance.getCaseInstanceId());
assertTrue(caseInstance.isActive());
assertFalse(caseInstance.isEnabled());
// get persisted case instance
CaseInstance instance = caseService.createCaseInstanceQuery().singleResult();
// should have the same properties
assertEquals(caseInstance.getId(), instance.getId());
assertEquals(caseInstance.getBusinessKey(), instance.getBusinessKey());
assertEquals(caseInstance.getCaseDefinitionId(), instance.getCaseDefinitionId());
assertEquals(caseInstance.getCaseInstanceId(), instance.getCaseInstanceId());
assertEquals(caseInstance.isActive(), instance.isActive());
assertEquals(caseInstance.isEnabled(), instance.isEnabled());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceCaseInstanceTest method testCreateByKeyWithBusinessKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCreateByKeyWithBusinessKey() {
// given a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// when
CaseInstance caseInstance = caseService.withCaseDefinitionByKey("oneTaskCase").businessKey("aBusinessKey").create();
// then
assertNotNull(caseInstance);
// check properties
assertEquals("aBusinessKey", caseInstance.getBusinessKey());
assertEquals(caseDefinitionId, caseInstance.getCaseDefinitionId());
assertEquals(caseInstance.getId(), caseInstance.getCaseInstanceId());
assertTrue(caseInstance.isActive());
assertFalse(caseInstance.isEnabled());
// get persistend case instance
CaseInstance instance = caseService.createCaseInstanceQuery().singleResult();
// should have the same properties
assertEquals(caseInstance.getId(), instance.getId());
assertEquals(caseInstance.getBusinessKey(), instance.getBusinessKey());
assertEquals(caseInstance.getCaseDefinitionId(), instance.getCaseDefinitionId());
assertEquals(caseInstance.getCaseInstanceId(), instance.getCaseInstanceId());
assertEquals(caseInstance.isActive(), instance.isActive());
assertEquals(caseInstance.isEnabled(), instance.isEnabled());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseServiceCaseInstanceTest method testCloseNonFluent.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testCloseNonFluent() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// disable human task -> case instance is completed
caseService.withCaseExecution(caseExecutionId).disable();
// when
caseService.closeCaseInstance(caseInstanceId);
// then
CaseInstance caseInstance = caseService.createCaseInstanceQuery().singleResult();
assertNull(caseInstance);
}
Aggregations