Search in sources :

Example 46 with HistoricDecisionInstance

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()));
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 47 with HistoricDecisionInstance

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()));
}
Also used : HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 48 with HistoricDecisionInstance

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()));
}
Also used : DecisionServiceDelegate(org.camunda.bpm.engine.test.history.DecisionServiceDelegate) CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with HistoricDecisionInstance

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()));
}
Also used : HashMap(java.util.HashMap) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 50 with HistoricDecisionInstance

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()));
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)51 Deployment (org.camunda.bpm.engine.test.Deployment)23 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)9 Test (org.junit.Test)9 HistoricDecisionInputInstance (org.camunda.bpm.engine.history.HistoricDecisionInputInstance)8 ArrayList (java.util.ArrayList)7 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)7 VariableMap (org.camunda.bpm.engine.variable.VariableMap)6 List (java.util.List)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)4 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)4 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)4 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)4 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)4 HashMap (java.util.HashMap)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)3 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3