use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteCmmnDisabledTest method clearDatabase.
@After
public void clearDatabase() {
engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
List<Job> jobs = engineRule.getManagementService().createJobQuery().list();
if (jobs.size() > 0) {
assertEquals(1, jobs.size());
String jobId = jobs.get(0).getId();
commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
}
commandContext.getMeterLogManager().deleteAll();
return null;
}
});
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
}
List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
}
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method collectHistoricDecisionInputIds.
private void collectHistoricDecisionInputIds(List<HistoricDecisionInstance> historicDecisionInstances, List<String> historicDecisionInputIds, List<String> inputByteArrayIds) {
for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
for (HistoricDecisionInputInstance inputInstanceEntity : historicDecisionInstance.getInputs()) {
historicDecisionInputIds.add(inputInstanceEntity.getId());
final String byteArrayValueId = ((HistoricDecisionInputInstanceEntity) inputInstanceEntity).getByteArrayValueId();
if (byteArrayValueId != null) {
inputByteArrayIds.add(byteArrayValueId);
}
}
}
assertEquals(PROCESS_INSTANCE_COUNT, historicDecisionInputIds.size());
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance 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.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class DmnHistoryTest method testHistoricDecisionInstance.
@Test
public void testHistoricDecisionInstance() {
VariableMap variables = Variables.createVariables().putValue("status", "bronze").putValue("sum", 100);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", variables);
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeInputs().includeOutputs().singleResult();
assertThat(historicDecisionInstance, is(notNullValue()));
assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is("decision"));
assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("Check Order"));
assertThat(historicDecisionInstance.getInputs().size(), is(2));
assertThat(historicDecisionInstance.getOutputs().size(), is(2));
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
taskService.complete(task.getId());
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceDecisionServiceEvaluationTest method evaluateDecisionWithDecisionService.
@Test
public void evaluateDecisionWithDecisionService() {
runtimeService.startProcessInstanceByKey("testProcess", Variables.createVariables().putValue("input1", null).putValue("myBean", new DecisionServiceDelegate()));
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().getId();
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();
assertThat(historicDecisionInstance, is(notNullValue()));
assertThat(historicDecisionInstance.getDecisionDefinitionId(), is(decisionDefinitionId));
assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is(DECISION_DEFINITION_KEY));
assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("sample decision"));
// references to process instance should be set since the decision is evaluated while executing a process instance
assertThat(historicDecisionInstance.getProcessDefinitionKey(), is(processDefinition.getKey()));
assertThat(historicDecisionInstance.getProcessDefinitionId(), is(processDefinition.getId()));
assertThat(historicDecisionInstance.getProcessInstanceId(), is(processInstance.getId()));
assertThat(historicDecisionInstance.getCaseDefinitionKey(), is(nullValue()));
assertThat(historicDecisionInstance.getCaseDefinitionId(), is(nullValue()));
assertThat(historicDecisionInstance.getCaseInstanceId(), is(nullValue()));
assertThat(historicDecisionInstance.getActivityId(), is(activityId));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
}
Aggregations