use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldNotDetectLoopInMultiLevelDecisionWithMultipleRequiredDecision.
@Test
public void shouldNotDetectLoopInMultiLevelDecisionWithMultipleRequiredDecision() {
InputStream inputStream = IoUtil.fileAsStream(MULTI_LEVEL_MULTIPLE_REQUIRED_DECISIONS_DMN);
DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
List<DmnDecision> decisions = dmnEngine.parseDecisions(modelInstance);
assertThat(decisions.size()).isEqualTo(8);
}
use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldTransformDecisionWithLiteralExpression.
@Test
public void shouldTransformDecisionWithLiteralExpression() {
List<DmnDecision> decisions = parseDecisionsFromFile(DECISION_WITH_LITERAL_EXPRESSION_DMN);
assertThat(decisions).hasSize(1);
DmnDecision decision = decisions.get(0);
assertThat(decision).isNotNull();
assertThat(decision.getKey()).isEqualTo("decision");
assertThat(decision.getName()).isEqualTo("Decision");
assertThat(decision.getDecisionLogic()).isNotNull().isInstanceOf(DmnDecisionLiteralExpressionImpl.class);
DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = (DmnDecisionLiteralExpressionImpl) decision.getDecisionLogic();
DmnVariableImpl variable = dmnDecisionLiteralExpression.getVariable();
assertThat(variable).isNotNull();
assertThat(variable.getId()).isEqualTo("v1");
assertThat(variable.getName()).isEqualTo("c");
assertThat(variable.getTypeDefinition()).isNotNull();
assertThat(variable.getTypeDefinition().getTypeName()).isEqualTo("integer");
DmnExpressionImpl dmnExpression = dmnDecisionLiteralExpression.getExpression();
assertThat(dmnExpression).isNotNull();
assertThat(dmnExpression.getId()).isEqualTo("e1");
assertThat(dmnExpression.getExpressionLanguage()).isEqualTo("groovy");
assertThat(dmnExpression.getExpression()).isEqualTo("a + b");
assertThat(dmnExpression.getTypeDefinition()).isNull();
}
use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldParseDecisionWithMultipleRequiredDecisions.
@Test
public void shouldParseDecisionWithMultipleRequiredDecisions() {
InputStream inputStream = IoUtil.fileAsStream(MULTIPLE_REQUIRED_DECISIONS_DMN);
DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
DmnDecision decision = dmnEngine.parseDecision("car", modelInstance);
Collection<DmnDecision> requiredDecisions = decision.getRequiredDecisions();
assertThat(requiredDecisions.size()).isEqualTo(2);
DmnDecision carPriceDecision = getDecision(requiredDecisions, "carPrice");
assertThat(carPriceDecision).isNotNull();
DmnDecision carSpeedDecision = getDecision(requiredDecisions, "carSpeed");
assertThat(carSpeedDecision).isNotNull();
}
use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldTransformDecisionTables.
@Test
public void shouldTransformDecisionTables() {
List<DmnDecision> decisions = parseDecisionsFromFile(TRANSFORM_DMN);
DmnDecision decision = decisions.get(0);
assertThat(decision.isDecisionTable()).isTrue();
assertThat(decision).isInstanceOf(DmnDecisionImpl.class);
DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decision.getDecisionLogic();
assertThat(decisionTable.getHitPolicyHandler()).isInstanceOf(UniqueHitPolicyHandler.class);
decision = decisions.get(1);
assertThat(decision.isDecisionTable()).isTrue();
assertThat(decision).isInstanceOf(DmnDecisionImpl.class);
decisionTable = (DmnDecisionTableImpl) decision.getDecisionLogic();
assertThat(decisionTable.getHitPolicyHandler()).isInstanceOf(FirstHitPolicyHandler.class);
}
use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldParseDecisionsWithRequiredDecisions.
@Test
public void shouldParseDecisionsWithRequiredDecisions() {
InputStream inputStream = IoUtil.fileAsStream(REQUIRED_DECISIONS_DMN);
DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
List<DmnDecision> decisions = dmnEngine.parseDecisions(modelInstance);
DmnDecision buyProductDecision = getDecision(decisions, "buyProduct");
assertThat(buyProductDecision).isNotNull();
Collection<DmnDecision> requiredProductDecisions = buyProductDecision.getRequiredDecisions();
assertThat(requiredProductDecisions.size()).isEqualTo(1);
DmnDecision requiredProductDecision = getDecision(requiredProductDecisions, "buyComputer");
assertThat(requiredProductDecision).isNotNull();
DmnDecision buyComputerDecision = getDecision(decisions, "buyComputer");
assertThat(buyComputerDecision).isNotNull();
Collection<DmnDecision> buyComputerRequiredDecisions = buyComputerDecision.getRequiredDecisions();
assertThat(buyComputerRequiredDecisions.size()).isEqualTo(1);
DmnDecision buyComputerRequiredDecision = getDecision(buyComputerRequiredDecisions, "buyElectronic");
assertThat(buyComputerRequiredDecision).isNotNull();
DmnDecision buyElectronicDecision = getDecision(decisions, "buyElectronic");
assertThat(buyElectronicDecision).isNotNull();
Collection<DmnDecision> buyElectronicRequiredDecisions = buyElectronicDecision.getRequiredDecisions();
assertThat(buyElectronicRequiredDecisions.size()).isEqualTo(0);
}
Aggregations