Search in sources :

Example 1 with DmnDecisionRequirementsGraph

use of org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph in project camunda-engine-dmn by camunda.

the class ParseDecisionTest method shouldParseDrgFromModelInstance.

@Test
public void shouldParseDrgFromModelInstance() {
    InputStream inputStream = IoUtil.fileAsStream(NO_INPUT_DMN);
    DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
    DmnDecisionRequirementsGraph drg = dmnEngine.parseDecisionRequirementsGraph(modelInstance);
    assertDecisionRequirementsGraph(drg, "definitions");
}
Also used : InputStream(java.io.InputStream) DmnDecisionRequirementsGraph(org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 2 with DmnDecisionRequirementsGraph

use of org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph in project camunda-engine-dmn by camunda.

the class DmnDecisionEvaluationTest method shouldEvaluateDecisionWithCollectHitPolicyReturningAList.

@Test
public void shouldEvaluateDecisionWithCollectHitPolicyReturningAList() {
    DmnDecisionRequirementsGraph graph = dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DRG_COLLECT_DMN));
    initVariables();
    variables.putValue("dayType", "WeekDay");
    DmnDecisionResult result = dmnEngine.evaluateDecision(graph.getDecision("dish-decision"), variables);
    assertThat(result.getSingleEntry()).isNotNull().isEqualTo("Steak");
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) DmnDecisionRequirementsGraph(org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 3 with DmnDecisionRequirementsGraph

use of org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph in project camunda-engine-dmn by camunda.

the class DmnTransformTest method shouldTransformDecisionRequirementsGraph.

@Test
public void shouldTransformDecisionRequirementsGraph() {
    InputStream inputStream = IoUtil.fileAsStream(REQUIRED_DECISIONS_DMN);
    DmnDecisionRequirementsGraph drg = dmnEngine.parseDecisionRequirementsGraph(inputStream);
    assertThat(drg).isNotNull();
    assertThat(drg.getKey()).isEqualTo("buy-decision");
    assertThat(drg.getName()).isEqualTo("Buy Decision");
    assertThat(drg.getDecisionKeys()).hasSize(3).contains("buyProduct", "buyComputer", "buyElectronic");
    Collection<DmnDecision> decisions = drg.getDecisions();
    assertThat(decisions).hasSize(3).extracting("key").contains("buyProduct", "buyComputer", "buyElectronic");
}
Also used : InputStream(java.io.InputStream) DmnDecisionRequirementsGraph(org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 4 with DmnDecisionRequirementsGraph

use of org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph in project camunda-engine-dmn by camunda.

the class DmnTransformListenerTest method shouldVerifyDmnDecisionRequirementsGraph.

@Test
public void shouldVerifyDmnDecisionRequirementsGraph() {
    dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DRG_EXAMPLE_DMN));
    DmnDecisionRequirementsGraph dmnDecisionRequirementsGraph = listener.getDmnDecisionRequirementsGraph();
    Definitions definitions = listener.getDefinitions();
    assertThat(dmnDecisionRequirementsGraph.getKey()).isEqualTo(definitions.getId()).isEqualTo("dish");
    assertThat(dmnDecisionRequirementsGraph.getName()).isEqualTo(definitions.getName()).isEqualTo("Dish");
    assertThat(dmnDecisionRequirementsGraph.getDecisions().size()).isEqualTo(3);
    assertThat(dmnDecisionRequirementsGraph.getDecision("dish-decision")).isNotNull();
    assertThat(dmnDecisionRequirementsGraph.getDecision("season")).isNotNull();
    assertThat(dmnDecisionRequirementsGraph.getDecision("guestCount")).isNotNull();
}
Also used : Definitions(org.camunda.bpm.model.dmn.instance.Definitions) DmnDecisionRequirementsGraph(org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 5 with DmnDecisionRequirementsGraph

use of org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph in project camunda-engine-dmn by camunda.

the class DmnEngineApiTest method shouldEvaluateDecisionOfDrg.

@Test
public void shouldEvaluateDecisionOfDrg() {
    DmnDecisionRequirementsGraph drd = dmnEngine.parseDecisionRequirementsGraph(createInputStream());
    decision = drd.getDecision("decision");
    DmnDecisionTableResult results = dmnEngine.evaluateDecisionTable(decision, createVariables().putValue("input", INPUT_VALUE));
    assertThat(results).hasSingleResult().hasSingleEntry(EXPECTED_OUTPUT_VALUE);
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) DmnDecisionRequirementsGraph(org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Aggregations

DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)7 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)7 Test (org.junit.Test)7 InputStream (java.io.InputStream)3 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)2 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)1 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)1 DmnModelInstance (org.camunda.bpm.model.dmn.DmnModelInstance)1 Definitions (org.camunda.bpm.model.dmn.instance.Definitions)1