Search in sources :

Example 16 with DmnModelInstance

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

the class DecisionDefinitionDeployerTest method testDeployDmnModelInstance.

@Test
public void testDeployDmnModelInstance() throws Exception {
    // given
    DmnModelInstance dmnModelInstance = createDmnModelInstance();
    // when
    testRule.deploy(repositoryService.createDeployment().addModelInstance("foo.dmn", dmnModelInstance));
    // then
    assertNotNull(repositoryService.createDecisionDefinitionQuery().decisionDefinitionResourceName("foo.dmn").singleResult());
}
Also used : DmnModelInstance(org.camunda.bpm.model.dmn.DmnModelInstance) Test(org.junit.Test)

Example 17 with DmnModelInstance

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

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

the class DmnTransformTest method shouldDetectLoopInParseDecisionWithRequiredDecision.

@Test
public void shouldDetectLoopInParseDecisionWithRequiredDecision() {
    InputStream inputStream = IoUtil.fileAsStream(LOOP_REQUIRED_DECISIONS_DMN);
    DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
    try {
        decision = dmnEngine.parseDecision("buyProduct", 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)

Example 19 with DmnModelInstance

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

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

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