use of org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldTransformRules.
@Test
public void shouldTransformRules() {
DmnDecisionImpl decisionEntity = (DmnDecisionImpl) parseDecisionFromFile("decision1", TRANSFORM_DMN);
DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decisionEntity.getDecisionLogic();
List<DmnDecisionTableRuleImpl> rules = decisionTable.getRules();
assertThat(rules).hasSize(1);
DmnDecisionTableRuleImpl rule = rules.get(0);
List<DmnExpressionImpl> conditions = rule.getConditions();
assertThat(conditions).hasSize(2);
DmnExpressionImpl condition = conditions.get(0);
assertThat(condition.getId()).isEqualTo("inputEntry");
assertThat(condition.getName()).isEqualTo("camunda");
assertThat(condition.getExpressionLanguage()).isEqualTo("camunda");
assertThat(condition.getExpression()).isEqualTo("camunda");
condition = conditions.get(1);
assertThat(condition.getId()).isNull();
assertThat(condition.getName()).isNull();
assertThat(condition.getExpressionLanguage()).isNull();
assertThat(condition.getExpression()).isNull();
List<DmnExpressionImpl> conclusions = rule.getConclusions();
assertThat(conclusions).hasSize(2);
DmnExpressionImpl dmnOutputEntry = conclusions.get(0);
assertThat(dmnOutputEntry.getId()).isEqualTo("outputEntry");
assertThat(dmnOutputEntry.getName()).isEqualTo("camunda");
assertThat(dmnOutputEntry.getExpressionLanguage()).isEqualTo("camunda");
assertThat(dmnOutputEntry.getExpression()).isEqualTo("camunda");
dmnOutputEntry = conclusions.get(1);
assertThat(dmnOutputEntry.getId()).isNull();
assertThat(dmnOutputEntry.getName()).isNull();
assertThat(dmnOutputEntry.getExpressionLanguage()).isNull();
assertThat(dmnOutputEntry.getExpression()).isNull();
}
use of org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldTransformOutputs.
@Test
public void shouldTransformOutputs() {
DmnDecisionImpl decisionEntity = (DmnDecisionImpl) parseDecisionFromFile("decision1", TRANSFORM_DMN);
DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decisionEntity.getDecisionLogic();
List<DmnDecisionTableOutputImpl> outputs = decisionTable.getOutputs();
assertThat(outputs).hasSize(2);
DmnDecisionTableOutputImpl output = outputs.get(0);
assertThat(output.getId()).isEqualTo("output1");
assertThat(output.getName()).isEqualTo("camunda");
assertThat(output.getOutputName()).isEqualTo("camunda");
assertThat(output.getTypeDefinition()).isNotNull();
assertThat(output.getTypeDefinition().getTypeName()).isEqualTo("string");
output = outputs.get(1);
assertThat(output.getId()).isEqualTo("output2");
assertThat(output.getName()).isNull();
assertThat(output.getOutputName()).isEqualTo("out2");
assertThat(output.getTypeDefinition()).isNotNull();
assertThat(output.getTypeDefinition()).isEqualTo(new DefaultTypeDefinition());
}
use of org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl in project camunda-engine-dmn by camunda.
the class DmnEngineApiTest method shouldFailEvaluatingDecisionIfDecisionLogicIsNotSupported.
@Test
public void shouldFailEvaluatingDecisionIfDecisionLogicIsNotSupported() {
DmnDecisionImpl decision = new DmnDecisionImpl();
decision.setKey("decision");
decision.setDecisionLogic(mock(DmnDecisionLogic.class));
try {
dmnEngine.evaluateDecision(decision, variables);
failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
} catch (DmnEngineException e) {
assertThat(e).hasMessageStartingWith("DMN-01012");
}
}
use of org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl in project camunda-engine-dmn by camunda.
the class DefaultDmnTransform method transformDecisions.
protected List<DmnDecision> transformDecisions(Collection<Decision> decisions) {
Map<String, DmnDecisionImpl> dmnDecisions = transformIndividualDecisions(decisions);
buildDecisionRequirements(decisions, dmnDecisions);
List<DmnDecision> dmnDecisionList = new ArrayList<DmnDecision>(dmnDecisions.values());
for (Decision decision : decisions) {
DmnDecision dmnDecision = dmnDecisions.get(decision.getId());
notifyTransformListeners(decision, dmnDecision);
}
ensureNoLoopInDecisions(dmnDecisionList);
return dmnDecisionList;
}
use of org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl in project camunda-engine-dmn by camunda.
the class DefaultDmnTransform method transformDecision.
protected DmnDecisionImpl transformDecision(Decision decision) {
DmnElementTransformHandler<Decision, DmnDecisionImpl> handler = handlerRegistry.getHandler(Decision.class);
DmnDecisionImpl dmnDecision = handler.handleElement(this, decision);
this.decision = dmnDecision;
// validate decision id
if (dmnDecision.getKey() == null) {
throw LOG.decisionIdIsMissing(dmnDecision);
}
Expression expression = decision.getExpression();
if (expression == null) {
LOG.decisionWithoutExpression(decision);
return null;
}
if (expression instanceof DecisionTable) {
DmnDecisionTableImpl dmnDecisionTable = transformDecisionTable((DecisionTable) expression);
dmnDecision.setDecisionLogic(dmnDecisionTable);
} else if (expression instanceof LiteralExpression) {
DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = transformDecisionLiteralExpression(decision, (LiteralExpression) expression);
dmnDecision.setDecisionLogic(dmnDecisionLiteralExpression);
} else {
LOG.decisionTypeNotSupported(expression, decision);
return null;
}
return dmnDecision;
}
Aggregations