use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testDeleteProcessInstance.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsConstant.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testDeleteProcessInstance() {
// given
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
String subCaseInstanceId = queryOneTaskCaseInstance().getId();
// when
runtimeService.deleteProcessInstance(superProcessInstanceId, null);
// then
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
CaseInstance subCaseInstance = queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
assertTrue(subCaseInstance.isActive());
// complete ////////////////////////////////////////////////////////
terminate(subCaseInstanceId);
close(subCaseInstanceId);
assertCaseEnded(subCaseInstanceId);
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class HistoryCleanupAuthorizationTest method prepareInstances.
protected void prepareInstances(Integer processInstanceTimeToLive, Integer decisionTimeToLive, Integer caseTimeToLive) {
// update time to live
disableAuthorization();
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testProcess").list();
assertEquals(1, processDefinitions.size());
repositoryService.updateProcessDefinitionHistoryTimeToLive(processDefinitions.get(0).getId(), processInstanceTimeToLive);
final List<DecisionDefinition> decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey("testDecision").list();
assertEquals(1, decisionDefinitions.size());
repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), decisionTimeToLive);
List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("oneTaskCase").list();
assertEquals(1, caseDefinitions.size());
repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitions.get(0).getId(), caseTimeToLive);
Date oldCurrentTime = ClockUtil.getCurrentTime();
ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, -6));
// create 3 process instances
List<String> processInstanceIds = new ArrayList<String>();
Map<String, Object> variables = Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37));
for (int i = 0; i < 3; i++) {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess", variables);
processInstanceIds.add(processInstance.getId());
}
runtimeService.deleteProcessInstances(processInstanceIds, null, true, true);
// +10 standalone decisions
for (int i = 0; i < 10; i++) {
decisionService.evaluateDecisionByKey("testDecision").variables(variables).evaluate();
}
// create 4 case instances
for (int i = 0; i < 4; i++) {
CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase", Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37 + i)));
caseService.terminateCaseExecution(caseInstance.getId());
caseService.closeCaseInstance(caseInstance.getId());
}
ClockUtil.setCurrentTime(oldCurrentTime);
enableAuthorization();
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceDetails.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceDetails() {
// given
// create case instances
String variableNameCase1 = "varName1";
CaseInstance caseInstance1 = caseService.createCaseInstanceByKey("oneTaskCase", Variables.createVariables().putValue(variableNameCase1, "value1"));
CaseInstance caseInstance2 = caseService.createCaseInstanceByKey("oneTaskCase", Variables.createVariables().putValue("varName2", "value2"));
caseService.setVariable(caseInstance1.getId(), variableNameCase1, "theValue");
// assume
List<HistoricDetail> detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(3, detailsList.size());
caseService.terminateCaseExecution(caseInstance1.getId(), caseService.getVariables(caseInstance1.getId()));
caseService.terminateCaseExecution(caseInstance2.getId(), caseService.getVariables(caseInstance2.getId()));
caseService.closeCaseInstance(caseInstance1.getId());
caseService.closeCaseInstance(caseInstance2.getId());
// when
historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance1.getId(), caseInstance2.getId()));
// then
detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(0, detailsList.size());
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class HistoryCleanupTest method prepareCMMNData.
private void prepareCMMNData(int instanceCount) {
Date oldCurrentTime = ClockUtil.getCurrentTime();
ClockUtil.setCurrentTime(DateUtils.addDays(new Date(), DAYS_IN_THE_PAST));
for (int i = 0; i < instanceCount; i++) {
CaseInstance caseInstance = caseService.createCaseInstanceByKey(ONE_TASK_CASE);
caseService.terminateCaseExecution(caseInstance.getId());
caseService.closeCaseInstance(caseInstance.getId());
}
ClockUtil.setCurrentTime(oldCurrentTime);
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class CaseInstanceQueryTest method testCaseInstanceProperties.
public void testCaseInstanceProperties() {
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY_2).singleResult().getId();
CaseInstance caseInstance = caseService.createCaseInstanceQuery().caseDefinitionKey(CASE_DEFINITION_KEY_2).singleResult();
assertNotNull(caseInstance.getId());
assertEquals(caseInstance.getId(), caseInstance.getCaseInstanceId());
assertEquals("1", caseInstance.getBusinessKey());
assertEquals(caseDefinitionId, caseInstance.getCaseDefinitionId());
assertEquals("CasePlanModel_1", caseInstance.getActivityId());
assertNull(caseInstance.getActivityName());
assertNull(caseInstance.getParentId());
assertTrue(caseInstance.isActive());
assertFalse(caseInstance.isEnabled());
}
Aggregations