Search in sources :

Example 1 with DmnModelInstance

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

the class ParseDecisionTest method shouldParseDecisionFromModelInstance.

@Test
public void shouldParseDecisionFromModelInstance() {
    InputStream inputStream = IoUtil.fileAsStream(NO_INPUT_DMN);
    DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
    decision = dmnEngine.parseDecision("decision", modelInstance);
    assertDecision(decision, "decision");
}
Also used : InputStream(java.io.InputStream) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 2 with DmnModelInstance

use of org.camunda.bpm.model.dmn.DmnModelInstance 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 3 with DmnModelInstance

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

the class DmnTransformListenerTest method shouldVerifyTransformedDmnDecision.

@Test
public void shouldVerifyTransformedDmnDecision() {
    InputStream inputStream = IoUtil.fileAsStream(DECISION_TRANSFORM_DMN);
    DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
    dmnEngine.parseDecisionRequirementsGraph(modelInstance);
    DmnDecision dmnDecision = listener.getDmnDecision();
    Decision decision = listener.getDecision();
    assertThat(dmnDecision.getKey()).isEqualTo(decision.getId()).isEqualTo("decision1");
    assertThat(dmnDecision.getName()).isEqualTo(decision.getName()).isEqualTo("camunda");
}
Also used : InputStream(java.io.InputStream) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Decision(org.camunda.bpm.model.dmn.instance.Decision) 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 4 with DmnModelInstance

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

the class DmnTransformTest method shouldParseDecisionWithRequiredDecisions.

@Test
public void shouldParseDecisionWithRequiredDecisions() {
    InputStream inputStream = IoUtil.fileAsStream(REQUIRED_DECISIONS_DMN);
    DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
    DmnDecision buyProductDecision = dmnEngine.parseDecision("buyProduct", modelInstance);
    assertDecision(buyProductDecision, "buyProduct");
    Collection<DmnDecision> buyProductrequiredDecisions = buyProductDecision.getRequiredDecisions();
    assertThat(buyProductrequiredDecisions.size()).isEqualTo(1);
    DmnDecision buyComputerDecision = getDecision(buyProductrequiredDecisions, "buyComputer");
    assertThat(buyComputerDecision).isNotNull();
    Collection<DmnDecision> buyComputerRequiredDecision = buyComputerDecision.getRequiredDecisions();
    assertThat(buyComputerRequiredDecision.size()).isEqualTo(1);
    DmnDecision buyElectronicDecision = getDecision(buyComputerRequiredDecision, "buyElectronic");
    assertThat(buyElectronicDecision).isNotNull();
    assertThat(buyElectronicDecision.getRequiredDecisions().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)

Example 5 with DmnModelInstance

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

the class DmnTransformTest method shouldDetectLoopInParseDecisionWithRequiredDecisionOfDifferentOrder.

@Test
public void shouldDetectLoopInParseDecisionWithRequiredDecisionOfDifferentOrder() {
    InputStream inputStream = IoUtil.fileAsStream(LOOP_REQUIRED_DECISIONS_DIFFERENT_ORDER_DMN);
    DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
    try {
        dmnEngine.parseDecisions(modelInstance);
        failBecauseExceptionWasNotThrown(DmnTransformException.class);
    } catch (DmnTransformException e) {
        Assertions.assertThat(e).hasMessageStartingWith("DMN-02004").hasMessageContaining("DMN-02015").hasMessageContaining("has a loop");
    }
}
Also used : DmnTransformException(org.camunda.bpm.dmn.engine.impl.transform.DmnTransformException) InputStream(java.io.InputStream) DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Aggregations

DmnModelInstance (org.camunda.bpm.model.dmn.DmnModelInstance)21 Test (org.junit.Test)16 InputStream (java.io.InputStream)10 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)10 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)5 Decision (org.camunda.bpm.model.dmn.instance.Decision)4 DmnTransformException (org.camunda.bpm.dmn.engine.impl.transform.DmnTransformException)3 Definitions (org.camunda.bpm.model.dmn.instance.Definitions)3 DecisionTable (org.camunda.bpm.model.dmn.instance.DecisionTable)2 Input (org.camunda.bpm.model.dmn.instance.Input)2 Output (org.camunda.bpm.model.dmn.instance.Output)2 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1 DecisionDefinitionEntity (org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 Deployment (org.camunda.bpm.engine.test.Deployment)1 InputExpression (org.camunda.bpm.model.dmn.instance.InputExpression)1 Rule (org.camunda.bpm.model.dmn.instance.Rule)1 Text (org.camunda.bpm.model.dmn.instance.Text)1