use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testCaseDecisionInstanceProperties.
@Deployment(resources = { DECISION_CASE, DECISION_SINGLE_OUTPUT_DMN })
public void testCaseDecisionInstanceProperties() {
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_DecisionTask_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"));
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_DecisionTask_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 testDecisionEvaluatedWithAuthenticatedUserFromCase.
@Deployment(resources = { DECISION_CASE_WITH_DECISION_SERVICE, DECISION_SINGLE_OUTPUT_DMN })
public void testDecisionEvaluatedWithAuthenticatedUserFromCase() {
identityService.setAuthenticatedUserId("demo");
createCaseInstanceAndEvaluateDecision();
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();
assertThat(historicDecisionInstance, is(notNullValue()));
// the user should be null since decision was evaluated by the case
assertThat(historicDecisionInstance.getUserId(), is(nullValue()));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testIfPartEvaluatesDecision.
@Deployment(resources = { DECISION_CASE_WITH_DECISION_SERVICE_INSIDE_IF_PART, DECISION_RETURNS_TRUE })
public void testIfPartEvaluatesDecision() {
CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").setVariable("input1", null).setVariable("myBean", new DecisionServiceDelegate()).create();
String humanTask1 = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
caseService.completeCaseExecution(humanTask1);
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 testDecisionEvaluatedWithDecisionService.
@Deployment(resources = { DECISION_SINGLE_OUTPUT_DMN })
public void testDecisionEvaluatedWithDecisionService() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("input1", "test");
decisionService.evaluateDecisionTableByKey(DECISION_DEFINITION_KEY, variables);
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"));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
// references to process instance should be null since the decision is not evaluated while executing a process instance
assertThat(historicDecisionInstance.getProcessDefinitionKey(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessDefinitionId(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessInstanceId(), is(nullValue()));
assertThat(historicDecisionInstance.getActivityId(), is(nullValue()));
assertThat(historicDecisionInstance.getActivityInstanceId(), is(nullValue()));
// the user should be null since no user was authenticated during evaluation
assertThat(historicDecisionInstance.getUserId(), is(nullValue()));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testDecisionInstancePropertiesOfDrdDecision.
@Deployment(resources = DRG_DMN)
public void testDecisionInstancePropertiesOfDrdDecision() {
decisionService.evaluateDecisionTableByKey("dish-decision").variables(Variables.createVariables().putValue("temperature", 21).putValue("dayType", "Weekend")).evaluate();
DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
assertThat(query.count(), is(3L));
HistoricDecisionInstance rootHistoricDecisionInstance = query.decisionDefinitionKey("dish-decision").singleResult();
HistoricDecisionInstance requiredHistoricDecisionInstance1 = query.decisionDefinitionKey("season").singleResult();
HistoricDecisionInstance requiredHistoricDecisionInstance2 = query.decisionDefinitionKey("guestCount").singleResult();
assertThat(rootHistoricDecisionInstance.getRootDecisionInstanceId(), is(nullValue()));
assertThat(rootHistoricDecisionInstance.getDecisionRequirementsDefinitionId(), is(decisionRequirementsDefinition.getId()));
assertThat(rootHistoricDecisionInstance.getDecisionRequirementsDefinitionKey(), is(decisionRequirementsDefinition.getKey()));
assertThat(requiredHistoricDecisionInstance1.getRootDecisionInstanceId(), is(rootHistoricDecisionInstance.getId()));
assertThat(requiredHistoricDecisionInstance1.getDecisionRequirementsDefinitionId(), is(decisionRequirementsDefinition.getId()));
assertThat(requiredHistoricDecisionInstance1.getDecisionRequirementsDefinitionKey(), is(decisionRequirementsDefinition.getKey()));
assertThat(requiredHistoricDecisionInstance2.getRootDecisionInstanceId(), is(rootHistoricDecisionInstance.getId()));
assertThat(requiredHistoricDecisionInstance2.getDecisionRequirementsDefinitionId(), is(decisionRequirementsDefinition.getId()));
assertThat(requiredHistoricDecisionInstance2.getDecisionRequirementsDefinitionKey(), is(decisionRequirementsDefinition.getKey()));
}
Aggregations