use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testMultipleDecisionOutputInstances.
@Deployment(resources = { DECISION_PROCESS, DECISION_MULTIPLE_OUTPUT_DMN })
public void testMultipleDecisionOutputInstances() {
startProcessInstanceAndEvaluateDecision();
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeOutputs().singleResult();
List<HistoricDecisionOutputInstance> outputs = historicDecisionInstance.getOutputs();
assertThat(outputs.size(), is(2));
HistoricDecisionOutputInstance firstOutput = outputs.get(0);
assertThat(firstOutput.getClauseId(), is("out1"));
assertThat(firstOutput.getRuleId(), is("rule1"));
assertThat(firstOutput.getRuleOrder(), is(1));
assertThat(firstOutput.getVariableName(), is("result1"));
assertThat(firstOutput.getValue(), is((Object) "okay"));
HistoricDecisionOutputInstance secondOutput = outputs.get(1);
assertThat(secondOutput.getClauseId(), is("out1"));
assertThat(secondOutput.getRuleId(), is("rule2"));
assertThat(secondOutput.getRuleOrder(), is(2));
assertThat(secondOutput.getVariableName(), is("result1"));
assertThat(secondOutput.getValue(), is((Object) "not okay"));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testDecisionInstanceProperties.
@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN })
public void testDecisionInstanceProperties() {
startProcessInstanceAndEvaluateDecision();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().getId();
String activityInstanceId = historyService.createHistoricActivityInstanceQuery().activityId("task").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"));
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("task"));
assertThat(historicDecisionInstance.getActivityInstanceId(), is(activityInstanceId));
assertThat(historicDecisionInstance.getRootDecisionInstanceId(), is(nullValue()));
assertThat(historicDecisionInstance.getDecisionRequirementsDefinitionId(), is(nullValue()));
assertThat(historicDecisionInstance.getDecisionRequirementsDefinitionKey(), is(nullValue()));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testDecisionOutputInstanceProperties.
@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN })
public void testDecisionOutputInstanceProperties() {
startProcessInstanceAndEvaluateDecision();
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeOutputs().singleResult();
List<HistoricDecisionOutputInstance> outputs = historicDecisionInstance.getOutputs();
assertThat(outputs, is(notNullValue()));
assertThat(outputs.size(), is(1));
HistoricDecisionOutputInstance output = outputs.get(0);
assertThat(output.getDecisionInstanceId(), is(historicDecisionInstance.getId()));
assertThat(output.getClauseId(), is("out"));
assertThat(output.getClauseName(), is("output"));
assertThat(output.getRuleId(), is("rule"));
assertThat(output.getRuleOrder(), is(1));
assertThat(output.getVariableName(), is("result"));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testCaseDecisionEvaluatedWithDecisionServiceInsideDelegate.
@Deployment(resources = { DECISION_CASE_WITH_DECISION_SERVICE, DECISION_SINGLE_OUTPUT_DMN })
public void testCaseDecisionEvaluatedWithDecisionServiceInsideDelegate() {
CaseInstance caseInstance = createCaseInstanceAndEvaluateDecision();
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.getCaseDefinitionId()).singleResult();
String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().getId();
String activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").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 case instance should be set since the decision is evaluated while executing a case instance
assertThat(historicDecisionInstance.getProcessDefinitionKey(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessDefinitionId(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessInstanceId(), is(nullValue()));
assertThat(historicDecisionInstance.getCaseDefinitionKey(), is(caseDefinition.getKey()));
assertThat(historicDecisionInstance.getCaseDefinitionId(), is(caseDefinition.getId()));
assertThat(historicDecisionInstance.getCaseInstanceId(), is(caseInstance.getId()));
assertThat(historicDecisionInstance.getActivityId(), is("PI_HumanTask_1"));
assertThat(historicDecisionInstance.getActivityInstanceId(), is(activityInstanceId));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testDecisionEvaluatedWithAuthenticatedUserFromProcess.
@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN })
public void testDecisionEvaluatedWithAuthenticatedUserFromProcess() {
identityService.setAuthenticatedUserId("demo");
startProcessInstanceAndEvaluateDecision();
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();
assertThat(historicDecisionInstance, is(notNullValue()));
// the user should be null since the decision was evaluated by the process
assertThat(historicDecisionInstance.getUserId(), is(nullValue()));
}
Aggregations