org.camunda.bpm.model.dmn.Dmn Java Examples
The following examples show how to use
org.camunda.bpm.model.dmn.Dmn.
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-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 #2
Source File: DmnHelper.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public static DmnModelInstance createSimpleDmnModel(final String decisionKey) { final DmnModelInstance modelInstance = Dmn.createEmptyModel(); final Definitions definitions = generateNamedElement(Definitions.class, "definitions", modelInstance); definitions.setNamespace(TEST_NAMESPACE); modelInstance.setDefinitions(definitions); Decision decision = generateNamedElement(Decision.class, "decision1", modelInstance); decision.setId(decisionKey); DecisionTable decisionTable = generateElement(DecisionTable.class, modelInstance); decision.setExpression(decisionTable); Output output = generateElement(Output.class, modelInstance); decisionTable.getOutputs().add(output); definitions.addChildElement(decision); return modelInstance; }
Example #3
Source File: DecisionDefinitionDeployerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testDeployEmptyDecisionDefinition() throws Exception { // given empty decision model DmnModelInstance modelInstance = Dmn.createEmptyModel(); Definitions definitions = modelInstance.newInstance(Definitions.class); definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS); definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS); definitions.setNamespace(DmnModelConstants.CAMUNDA_NS); modelInstance.setDefinitions(definitions); // when decision model is deployed DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", modelInstance); DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder); // then deployment contains no definitions assertNull(deployment.getDeployedDecisionDefinitions()); assertNull(deployment.getDeployedDecisionRequirementsDefinitions()); // and there are no persisted definitions assertNull(repositoryService.createDecisionDefinitionQuery() .decisionDefinitionResourceName("foo.dmn").singleResult()); }
Example #4
Source File: DecisionDefinitionDeployerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected static DmnModelInstance createDmnModelInstanceNegativeHistoryTimeToLive() { DmnModelInstance modelInstance = Dmn.createEmptyModel(); Definitions definitions = modelInstance.newInstance(Definitions.class); definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS); definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS); definitions.setNamespace(DmnModelConstants.CAMUNDA_NS); modelInstance.setDefinitions(definitions); Decision decision = modelInstance.newInstance(Decision.class); decision.setId("Decision-1"); decision.setName("foo"); decision.setCamundaHistoryTimeToLive(-5); modelInstance.getDefinitions().addChildElement(decision); return modelInstance; }
Example #5
Source File: GetDmnModelElementTypeRule.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") protected void starting(Description description) { String className = description.getClassName(); assertThat(className).endsWith("Test"); className = className.substring(0, className.length() - "Test".length()); Class<? extends ModelElementInstance> instanceClass; try { instanceClass = (Class<? extends ModelElementInstance>) Class.forName(className); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } modelInstance = Dmn.createEmptyModel(); model = modelInstance.getModel(); modelElementType = model.getType(instanceClass); }
Example #6
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 #7
Source File: XlsxDeployer.java From camunda-dmn-xlsx with Apache License 2.0 | 6 votes |
protected ResourceEntity generateDeploymentResource(DeploymentEntity deployment, DmnModelInstance dmnModel, String name) { ResourceEntity resource = new ResourceEntity(); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Dmn.writeModelToStream(byteStream, dmnModel); byte[] bytes = byteStream.toByteArray(); resource.setName(name); resource.setBytes(bytes); resource.setDeploymentId(deployment.getId()); // Mark the resource as 'generated' resource.setGenerated(true); return resource; }
Example #8
Source File: DmnTransformListenerTest.java From camunda-engine-dmn 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 #9
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 #10
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 #11
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 #12
Source File: DecisionDefinitionDeployerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected static DmnModelInstance createDmnModelInstance() { DmnModelInstance modelInstance = Dmn.createEmptyModel(); Definitions definitions = modelInstance.newInstance(Definitions.class); definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS); definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS); definitions.setNamespace(DmnModelConstants.CAMUNDA_NS); modelInstance.setDefinitions(definitions); Decision decision = modelInstance.newInstance(Decision.class); decision.setId("Decision-1"); decision.setName("foo"); decision.setCamundaHistoryTimeToLive(5); modelInstance.getDefinitions().addChildElement(decision); DecisionTable decisionTable = modelInstance.newInstance(DecisionTable.class); decisionTable.setId(DmnModelConstants.DMN_ELEMENT_DECISION_TABLE); decisionTable.setHitPolicy(HitPolicy.FIRST); decision.addChildElement(decisionTable); Input input = modelInstance.newInstance(Input.class); input.setId("Input-1"); input.setLabel("Input"); decisionTable.addChildElement(input); InputExpression inputExpression = modelInstance.newInstance(InputExpression.class); inputExpression.setId("InputExpression-1"); Text inputExpressionText = modelInstance.newInstance(Text.class); inputExpressionText.setTextContent("input"); inputExpression.setText(inputExpressionText); inputExpression.setTypeRef("string"); input.setInputExpression(inputExpression); Output output = modelInstance.newInstance(Output.class); output.setName("output"); output.setLabel("Output"); output.setTypeRef("string"); decisionTable.addChildElement(output); return modelInstance; }
Example #13
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 #14
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 #15
Source File: ParseDecisionTest.java From camunda-bpm-platform 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 #16
Source File: ParseDecisionTest.java From camunda-bpm-platform 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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
Source File: DmnTransformTest.java From camunda-engine-dmn 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 #23
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 #24
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 #25
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 #26
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 #27
Source File: XlsxWorksheetConverter.java From camunda-dmn-xlsx with Apache License 2.0 | 5 votes |
protected DmnModelInstance initializeEmptyDmnModel() { DmnModelInstance dmnModel = Dmn.createEmptyModel(); Definitions definitions = generateNamedElement(dmnModel, Definitions.class, "definitions"); definitions.setNamespace(DmnModelConstants.CAMUNDA_NS); dmnModel.setDefinitions(definitions); return dmnModel; }
Example #28
Source File: DefaultDmnTransform.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void setModelInstance(File file) { ensureNotNull("file", file); try { modelInstance = Dmn.readModelFromFile(file); } catch (DmnModelException e) { throw LOG.unableToTransformDecisionsFromFile(file, e); } }
Example #29
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 #30
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(); }