use of org.camunda.bpm.engine.test.dmn.businessruletask.TestPojo 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.test.dmn.businessruletask.TestPojo in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceTaskDetails.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceTaskDetails() {
// given
// create case instance
CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");
Task task = taskService.createTaskQuery().singleResult();
taskService.setVariable(task.getId(), "boo", new TestPojo("foo", 123.0));
taskService.setVariable(task.getId(), "goo", 9);
taskService.setVariable(task.getId(), "boo", new TestPojo("foo", 321.0));
// assume
List<HistoricDetail> detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(3, detailsList.size());
terminateAndCloseCaseInstance(caseInstance.getId(), taskService.getVariables(task.getId()));
// when
historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance.getId()));
// then
detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(0, detailsList.size());
}
use of org.camunda.bpm.engine.test.dmn.businessruletask.TestPojo in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceComplexVariable.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceComplexVariable() {
// given
// create case instances
VariableMap variables = Variables.createVariables();
CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase", variables.putValue("pojo", new TestPojo("okay", 13.37)));
caseService.setVariable(caseInstance.getId(), "pojo", "theValue");
// assume
List<HistoricVariableInstance> variablesInstances = historyService.createHistoricVariableInstanceQuery().list();
assertEquals(1, variablesInstances.size());
List<HistoricDetail> detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(2, detailsList.size());
terminateAndCloseCaseInstance(caseInstance.getId(), variables);
// when
historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance.getId()));
// then
variablesInstances = historyService.createHistoricVariableInstanceQuery().list();
assertEquals(0, variablesInstances.size());
detailsList = historyService.createHistoricDetailQuery().list();
assertEquals(0, detailsList.size());
}
use of org.camunda.bpm.engine.test.dmn.businessruletask.TestPojo in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method testCleanupHistoryStandaloneDecisionData.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/history/testDmnWithPojo.dmn11.xml" })
public void testCleanupHistoryStandaloneDecisionData() {
// given
for (int i = 0; i < 5; i++) {
engineRule.getDecisionService().evaluateDecisionByKey("testDecision").variables(Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37))).evaluate();
}
// remember input and output ids
List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().includeInputs().includeOutputs().list();
final List<String> inputIds = new ArrayList<String>();
final List<String> inputByteArrayIds = new ArrayList<String>();
collectHistoricDecisionInputIds(historicDecisionInstances, inputIds, inputByteArrayIds);
final List<String> outputIds = new ArrayList<String>();
final List<String> outputByteArrayIds = new ArrayList<String>();
collectHistoricDecisionOutputIds(historicDecisionInstances, outputIds, outputByteArrayIds);
List<String> decisionInstanceIds = extractIds(historicDecisionInstances);
// when
historyService.deleteHistoricDecisionInstancesBulk(decisionInstanceIds);
// then
assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("testProcess").count());
assertEquals(0, historyService.createHistoricDecisionInstanceQuery().count());
// check that decision inputs and outputs were removed
assertDataDeleted(inputIds, inputByteArrayIds, outputIds, outputByteArrayIds);
}
use of org.camunda.bpm.engine.test.dmn.businessruletask.TestPojo in project camunda-bpm-platform by camunda.
the class HistoryCleanupTest method prepareInstances.
private void prepareInstances(Integer processInstanceTimeToLive, Integer decisionTimeToLive, Integer caseTimeToLive) {
// update time to live
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(new Date(), DAYS_IN_THE_PAST));
// 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 < PROCESS_INSTANCES_COUNT; 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 < DECISION_INSTANCES_COUNT; i++) {
engineRule.getDecisionService().evaluateDecisionByKey("testDecision").variables(variables).evaluate();
}
// create 4 case instances
for (int i = 0; i < CASE_INSTANCES_COUNT; 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);
}
Aggregations