use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testCompoundDecisionOutputInstances.
@Deployment(resources = { DECISION_PROCESS, DECISION_COMPOUND_OUTPUT_DMN })
public void testCompoundDecisionOutputInstances() {
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("out2"));
assertThat(secondOutput.getRuleId(), is("rule1"));
assertThat(secondOutput.getRuleOrder(), is(1));
assertThat(secondOutput.getVariableName(), is("result2"));
assertThat(secondOutput.getValue(), is((Object) "not okay"));
}
use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testDecisionInstancePropertiesOfDecisionLiteralExpression.
@Deployment(resources = DECISION_LITERAL_EXPRESSION_DMN)
public void testDecisionInstancePropertiesOfDecisionLiteralExpression() {
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
decisionService.evaluateDecisionByKey("decision").variables(Variables.createVariables().putValue("sum", 2205)).evaluate();
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().includeInputs().includeOutputs();
assertThat(query.count(), is(1L));
HistoricDecisionInstance historicDecisionInstance = query.singleResult();
assertThat(historicDecisionInstance.getDecisionDefinitionId(), is(decisionDefinition.getId()));
assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is("decision"));
assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("Decision with Literal Expression"));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
assertThat(historicDecisionInstance.getInputs().size(), is(0));
List<HistoricDecisionOutputInstance> outputs = historicDecisionInstance.getOutputs();
assertThat(outputs.size(), is(1));
HistoricDecisionOutputInstance output = outputs.get(0);
assertThat(output.getVariableName(), is("result"));
assertThat(output.getTypeName(), is("string"));
assertThat((String) output.getValue(), is("ok"));
assertThat(output.getClauseId(), is(nullValue()));
assertThat(output.getClauseName(), is(nullValue()));
assertThat(output.getRuleId(), is(nullValue()));
assertThat(output.getRuleOrder(), is(nullValue()));
}
use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.
the class MockProvider method createMockHistoricDecisionInstanceWithInputsAndOutputs.
public static HistoricDecisionInstance createMockHistoricDecisionInstanceWithInputsAndOutputs() {
List<HistoricDecisionInputInstance> inputs = createMockHistoricDecisionInputInstances();
List<HistoricDecisionOutputInstance> outputs = createMockHistoricDecisionOutputInstances();
HistoricDecisionInstance mock = createMockHistoricDecisionInstanceBase();
when(mock.getInputs()).thenReturn(inputs);
when(mock.getOutputs()).thenReturn(outputs);
return mock;
}
use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.
the class DefaultDmnHistoryEventProducer method initDecisionInstanceEvent.
protected void initDecisionInstanceEvent(HistoricDecisionInstanceEntity event, DmnDecisionLogicEvaluationEvent evaluationEvent, HistoryEventTypes eventType) {
event.setEventType(eventType.getEventName());
DecisionDefinition decision = (DecisionDefinition) evaluationEvent.getDecision();
event.setDecisionDefinitionId(decision.getId());
event.setDecisionDefinitionKey(decision.getKey());
event.setDecisionDefinitionName(decision.getName());
if (decision.getDecisionRequirementsDefinitionId() != null) {
event.setDecisionRequirementsDefinitionId(decision.getDecisionRequirementsDefinitionId());
event.setDecisionRequirementsDefinitionKey(decision.getDecisionRequirementsDefinitionKey());
}
if (evaluationEvent instanceof DmnDecisionTableEvaluationEvent) {
initDecisionInstanceEventForDecisionTable(event, (DmnDecisionTableEvaluationEvent) evaluationEvent);
} else if (evaluationEvent instanceof DmnDecisionLiteralExpressionEvaluationEvent) {
initDecisionInstanceEventForDecisionLiteralExpression(event, (DmnDecisionLiteralExpressionEvaluationEvent) evaluationEvent);
} else {
event.setInputs(Collections.<HistoricDecisionInputInstance>emptyList());
event.setOutputs(Collections.<HistoricDecisionOutputInstance>emptyList());
}
}
use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.
the class DefaultDmnHistoryEventProducer method createHistoricDecisionOutputInstances.
protected List<HistoricDecisionOutputInstance> createHistoricDecisionOutputInstances(DmnDecisionTableEvaluationEvent evaluationEvent) {
List<HistoricDecisionOutputInstance> outputInstances = new ArrayList<HistoricDecisionOutputInstance>();
List<DmnEvaluatedDecisionRule> matchingRules = evaluationEvent.getMatchingRules();
for (int index = 0; index < matchingRules.size(); index++) {
DmnEvaluatedDecisionRule rule = matchingRules.get(index);
String ruleId = rule.getId();
Integer ruleOrder = index + 1;
for (DmnEvaluatedOutput outputClause : rule.getOutputEntries().values()) {
HistoricDecisionOutputInstanceEntity outputInstance = new HistoricDecisionOutputInstanceEntity();
outputInstance.setClauseId(outputClause.getId());
outputInstance.setClauseName(outputClause.getName());
outputInstance.setRuleId(ruleId);
outputInstance.setRuleOrder(ruleOrder);
outputInstance.setVariableName(outputClause.getOutputName());
outputInstance.setValue(outputClause.getValue());
outputInstances.add(outputInstance);
}
}
return outputInstances;
}
Aggregations