Java Code Examples for org.camunda.bpm.model.dmn.Dmn#readModelFromStream()
The following examples show how to use
org.camunda.bpm.model.dmn.Dmn#readModelFromStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DmnTransformTest.java From camunda-engine-dmn with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: DmnTransformTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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); }
Example 3
Source File: DmnTransformListenerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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"); }
Example 4
Source File: ParseDecisionTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@Test public void shouldParseDrgFromModelInstance() { InputStream inputStream = IoUtil.fileAsStream(NO_INPUT_DMN); DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream); DmnDecisionRequirementsGraph drg = dmnEngine.parseDecisionRequirementsGraph(modelInstance); assertDecisionRequirementsGraph(drg, "definitions"); }
Example 5
Source File: DmnTransformTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldDetectLoopInParseDecisionWithSelfRequiredDecision() { InputStream inputStream = IoUtil.fileAsStream(SELF_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"); } }
Example 6
Source File: DmnTransformTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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"); } }
Example 7
Source File: DmnTransformTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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"); } }
Example 8
Source File: DmnTransformTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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(); }
Example 9
Source File: DmnTransformTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: DefaultDmnTransform.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void setModelInstance(InputStream inputStream) { ensureNotNull("inputStream", inputStream); try { modelInstance = Dmn.readModelFromStream(inputStream); } catch (DmnModelException e) { throw LOG.unableToTransformDecisionsFromInputStream(e); } }
Example 11
Source File: ParseDmnModelRule.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override protected void starting(Description description) { DmnModelResource dmnModelResource = description.getAnnotation(DmnModelResource.class); if(dmnModelResource != null) { String resourcePath = dmnModelResource.resource(); if (resourcePath.isEmpty()) { Class<?> testClass = description.getTestClass(); String methodName = description.getMethodName(); String resourceFolderName = testClass.getName().replaceAll("\\.", "/"); resourcePath = resourceFolderName + "." + methodName + ".dmn"; } InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(resourcePath); try { dmnModelInstance = Dmn.readModelFromStream(resourceAsStream); } finally { IoUtil.closeSilently(resourceAsStream); } } }
Example 12
Source File: DefaultDmnTransform.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
public void setModelInstance(InputStream inputStream) { ensureNotNull("inputStream", inputStream); try { modelInstance = Dmn.readModelFromStream(inputStream); } catch (DmnModelException e) { throw LOG.unableToTransformDecisionsFromInputStream(e); } }
Example 13
Source File: ParseDecisionTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@Test public void shouldParseDecisionFromModelInstance() { InputStream inputStream = IoUtil.fileAsStream(NO_INPUT_DMN); DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream); decision = dmnEngine.parseDecision("decision", modelInstance); assertDecision(decision, "decision"); }
Example 14
Source File: DmnTransformTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@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); }
Example 15
Source File: DmnTransformTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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); }
Example 16
Source File: DmnTransformTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@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"); } }
Example 17
Source File: DmnTransformTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@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"); } }
Example 18
Source File: DmnTransformTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@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(); }
Example 19
Source File: DmnTransformTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@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); }
Example 20
Source File: DmnEngineApiTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected DmnModelInstance createDmnModelInstance() { return Dmn.readModelFromStream(createInputStream()); }