Search in sources :

Example 16 with DmnDecision

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);
}
Also used : InputStream(java.io.InputStream) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 17 with DmnDecision

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();
}
Also used : DmnVariableImpl(org.camunda.bpm.dmn.engine.impl.DmnVariableImpl) DmnExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl) DmnDecisionLiteralExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 18 with DmnDecision

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();
}
Also used : InputStream(java.io.InputStream) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 19 with DmnDecision

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);
}
Also used : DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 20 with DmnDecision

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);
}
Also used : InputStream(java.io.InputStream) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Aggregations

DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)27 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)9 Test (org.junit.Test)9 InputStream (java.io.InputStream)8 Decision (org.camunda.bpm.model.dmn.instance.Decision)7 ArrayList (java.util.ArrayList)5 DmnModelInstance (org.camunda.bpm.model.dmn.DmnModelInstance)5 DmnDecisionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl)3 DmnDecisionLiteralExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl)2 DmnDecisionTableImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl)2 Definitions (org.camunda.bpm.model.dmn.instance.Definitions)2 List (java.util.List)1 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)1 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)1 DmnEngine (org.camunda.bpm.dmn.engine.DmnEngine)1 DmnDecisionLogicEvaluationEvent (org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent)1 DmnDecisionRequirementsGraphImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionRequirementsGraphImpl)1 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)1 DmnVariableImpl (org.camunda.bpm.dmn.engine.impl.DmnVariableImpl)1 DmnDecisionLogicEvaluationHandler (org.camunda.bpm.dmn.engine.impl.evaluation.DmnDecisionLogicEvaluationHandler)1