org.camunda.bpm.model.dmn.DmnModelInstance Java Examples

The following examples show how to use org.camunda.bpm.model.dmn.DmnModelInstance. 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: XlsxDeploymentTest.java    From camunda-dmn-xlsx with Apache License 2.0 6 votes vote down vote up
@Test
public void testXlsxDeploymentWithMetaData() {
  // when
  deployment = rule.getRepositoryService()
    .createDeployment()
    .addClasspathResource("test1.xlsx")
    .addClasspathResource("test1.xlsx.yaml")
    .deploy()
    .getId();

  // then
  DecisionDefinition decisionDefinition = rule.getRepositoryService().createDecisionDefinitionQuery().singleResult();
  assertThat(decisionDefinition).isNotNull();

  DmnModelInstance dmnModel = rule.getRepositoryService().getDmnModelInstance(decisionDefinition.getId());
  Collection<DecisionTable> decisionTables = dmnModel.getModelElementsByType(DecisionTable.class);
  assertThat(decisionTables).hasSize(1);

  DecisionTable decisionTable = decisionTables.iterator().next();
  assertThat(decisionTable.getInputs()).hasSize(1);
  assertThat(decisionTable.getOutputs()).hasSize(1);

}
 
Example #2
Source File: DmnTransformListenerTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: DmnTransformTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: DmnModelElementInstanceCmdTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/repository/one.dmn")
public void testRepositoryService() {
  String decisionDefinitionId = repositoryService
    .createDecisionDefinitionQuery()
    .decisionDefinitionKey(DECISION_KEY)
    .singleResult()
    .getId();

  DmnModelInstance modelInstance = repositoryService.getDmnModelInstance(decisionDefinitionId);
  assertNotNull(modelInstance);

  Collection<Decision> decisions = modelInstance.getModelElementsByType(Decision.class);
  assertEquals(1, decisions.size());

  Collection<DecisionTable> decisionTables = modelInstance.getModelElementsByType(DecisionTable.class);
  assertEquals(1, decisionTables.size());

  Collection<Input> inputs = modelInstance.getModelElementsByType(Input.class);
  assertEquals(1, inputs.size());

  Collection<Output> outputs = modelInstance.getModelElementsByType(Output.class);
  assertEquals(1, outputs.size());

  Collection<Rule> rules = modelInstance.getModelElementsByType(Rule.class);
  assertEquals(2, rules.size());
}
 
Example #5
Source File: XslxToDmnConversionTest.java    From camunda-dmn-xlsx with Apache License 2.0 6 votes vote down vote up
@Test
public void testConversionWithRanges() {
  XlsxConverter converter = new XlsxConverter();
  InputStream inputStream = TestHelper.getClassPathResource("test5.xlsx");
  DmnModelInstance dmnModelInstance = converter.convert(inputStream);
  assertThat(dmnModelInstance).isNotNull();

  DecisionTable table = TestHelper.assertAndGetSingleDecisionTable(dmnModelInstance);
  assertThat(table).isNotNull();
  assertThat(table.getInputs()).hasSize(1);
  assertThat(table.getOutputs()).hasSize(1);
  assertThat(table.getRules()).hasSize(4);

  Rule firstRule = table.getRules().iterator().next();

  InputEntry inputEntry = firstRule.getInputEntries().iterator().next();
  String firstInput = inputEntry.getTextContent();
  assertThat(firstInput).isEqualTo("[1..2]");
}
 
Example #6
Source File: DmnTransformListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployAndGetDecisionDefinition() throws Exception {

  // given decision model
  DmnModelInstance dmnModelInstance = createDmnModelInstance();

  // when decision model is deployed
  DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", dmnModelInstance);
  DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder);

  // then deployment contains definition
  List<DecisionDefinition> deployedDecisionDefinitions = deployment.getDeployedDecisionDefinitions();
  assertEquals(1, deployedDecisionDefinitions.size());
  assertNull(deployment.getDeployedDecisionRequirementsDefinitions());
  assertNull(deployment.getDeployedProcessDefinitions());
  assertNull(deployment.getDeployedCaseDefinitions());

  // and persisted definition are equal to deployed definition
  DecisionDefinition persistedDecisionDef = repositoryService.createDecisionDefinitionQuery()
    .decisionDefinitionResourceName("foo.dmn").singleResult();
  assertEquals(persistedDecisionDef.getId(), deployedDecisionDefinitions.get(0).getId());
}
 
Example #9
Source File: DmnHelper.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: XlsxDeployer.java    From camunda-dmn-xlsx with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentEntity deployment) {
  if (!deployment.isNew()) {
    // only generate dmn xml once when deploying for the first time
    return;
  }

  List<ResourceEntity> generatedResources = new ArrayList<ResourceEntity>();

  for (ResourceEntity resource : deployment.getResources().values()) {
    if (canHandle(resource)) {
      XlsxDeploymentMetaData metaData = loadMetaData(deployment, resource.getName() + ".yaml");
      DmnModelInstance dmnModel = generateDmnModel(resource, metaData);
      ResourceEntity dmnResource = generateDeploymentResource(deployment, dmnModel, generateDmnResourceName(resource));
      generatedResources.add(dmnResource);
    }
  }

  addToDeployment(generatedResources, deployment);
}
 
Example #11
Source File: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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 #12
Source File: MultiTenancyDecisionDefinitionCmdsTenantCheckTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void getDmnModelInstanceWithAuthenticatedTenant() {
  identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));

  DmnModelInstance modelInstance = repositoryService.getDmnModelInstance(decisionDefinitionId);

  assertThat(modelInstance, notNullValue());
}
 
Example #13
Source File: DefaultDmnEngine.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public DmnDecision parseDecision(String decisionKey, DmnModelInstance dmnModelInstance) {
  ensureNotNull("decisionKey", decisionKey);
  List<DmnDecision> decisions = parseDecisions(dmnModelInstance);
  for (DmnDecision decision : decisions) {
    if (decisionKey.equals(decision.getKey())) {
      return decision;
    }
  }
  throw LOG.unableToFindDecisionWithKey(decisionKey);
}
 
Example #14
Source File: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployDmnModelInstanceNegativeHistoryTimeToLive() throws Exception {
  // given
  DmnModelInstance dmnModelInstance = createDmnModelInstanceNegativeHistoryTimeToLive();

  try {
    testRule.deploy(repositoryService.createDeployment().addModelInstance("foo.dmn", dmnModelInstance));
    fail("Exception for negative time to live value is expected.");
  } catch (ProcessEngineException ex) {
    assertTrue(ex.getCause().getMessage().contains("negative value is not allowed"));
  }
}
 
Example #15
Source File: TestHelper.java    From camunda-dmn-xlsx with Apache License 2.0 5 votes vote down vote up
public static DecisionTable assertAndGetSingleDecisionTable(DmnModelInstance dmnModel) {
  assertThat(dmnModel.getDefinitions()).isNotNull();
  Collection<Decision> decisions = dmnModel.getDefinitions().getChildElementsByType(Decision.class);
  assertThat(decisions).hasSize(1);

  Decision decision = decisions.iterator().next();
  assertThat(decision).isNotNull();

  Collection<DecisionTable> decisionTables = decision.getChildElementsByType(DecisionTable.class);
  assertThat(decisionTables).hasSize(1);

  return decisionTables.iterator().next();
}
 
Example #16
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 #17
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 #18
Source File: DmnHelper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static  <E extends NamedElement> E generateNamedElement(final Class<E> elementClass,
                                                               final String name,
                                                               final DmnModelInstance modelInstance) {
  E element = generateElement(elementClass, modelInstance);
  element.setName(name);
  return element;
}
 
Example #19
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 #20
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 #21
Source File: ParseDecisionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 #22
Source File: ParseDecisionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 #23
Source File: DmnEngineApiTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFailParsingDrgIfModelInstanceIsNull() {
  try{
    dmnEngine.parseDecisionRequirementsGraph((DmnModelInstance) null);
    failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
  }
  catch (IllegalArgumentException e) {
    assertThat(e)
      .hasMessageContaining("UTILS-02001");
  }
}
 
Example #24
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 #25
Source File: XslxToDmnConversionTest.java    From camunda-dmn-xlsx with Apache License 2.0 5 votes vote down vote up
@Test
public void testConversionWithComplexHeaders() {
  XlsxConverter converter = new XlsxConverter();
  converter.setIoDetectionStrategy(new AdvancedSpreadsheetAdapter());
  InputStream inputStream = TestHelper.getClassPathResource("test6.xlsx");
  DmnModelInstance dmnModelInstance = converter.convert(inputStream);
  assertThat(dmnModelInstance).isNotNull();

  DecisionTable table = TestHelper.assertAndGetSingleDecisionTable(dmnModelInstance);
  assertThat(table).isNotNull();
  assertThat(table.getInputs()).hasSize(2);
  assertThat(table.getOutputs()).hasSize(2);
  assertThat(table.getRules()).hasSize(2);
  assertThat(table.getHitPolicy()).isEqualTo(HitPolicy.FIRST);

  Iterator<Input> inputIterator = table.getInputs().iterator();
  Input input = inputIterator.next();

  assertThat(input.getId()).isEqualTo("input1");
  assertThat(input.getLabel()).isEqualTo("InputLabel1");
  assertThat(input.getInputExpression().getTypeRef()).isEqualTo("string");
  assertThat(input.getTextContent()).isEqualTo("Exp1");

  input = inputIterator.next();
  assertThat(input.getId()).isEqualTo("input2");
  assertThat(input.getLabel()).isEqualTo("InputLabel2");
  assertThat(input.getInputExpression().getTypeRef()).isEqualTo("integer");
  assertThat(input.getInputExpression().getExpressionLanguage()).isEqualTo("javascript");
  assertThat(input.getInputExpression().getTextContent()).isEqualTo(JAVASCRIPT_SNIPPET);

  Iterator<Rule> ruleIterator = table.getRules().iterator();
  Rule rule = ruleIterator.next();
  assertThat(rule.getDescription().getTextContent()).isEqualTo("Comment1");

  InputEntry inputEntry = rule.getInputEntries().iterator().next();
  assertThat(inputEntry.getTextContent()).isEqualTo("\"Foo\"");

  rule = ruleIterator.next();
  assertThat(rule.getDescription().getTextContent()).isEqualTo("Another Comment");
}
 
Example #26
Source File: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #27
Source File: DecisionDefinitionDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: XslxToDmnConversionTest.java    From camunda-dmn-xlsx with Apache License 2.0 5 votes vote down vote up
@Test
public void testConversionOfEmptyCells() {
  XlsxConverter converter = new XlsxConverter();
  InputStream inputStream = TestHelper.getClassPathResource("test3.xlsx");
  DmnModelInstance dmnModelInstance = converter.convert(inputStream);
  assertThat(dmnModelInstance).isNotNull();

  DecisionTable table = TestHelper.assertAndGetSingleDecisionTable(dmnModelInstance);
  assertThat(table).isNotNull();
  assertThat(table.getInputs()).hasSize(3);
  assertThat(table.getOutputs()).hasSize(1);
  assertThat(table.getRules()).hasSize(4);
}
 
Example #29
Source File: XslxToDmnConversionTest.java    From camunda-dmn-xlsx with Apache License 2.0 5 votes vote down vote up
@Test
public void testConversionOfMixedNumberAndStringColumns() {
  XlsxConverter converter = new XlsxConverter();
  InputStream inputStream = TestHelper.getClassPathResource("test2.xlsx");
  DmnModelInstance dmnModelInstance = converter.convert(inputStream);
  assertThat(dmnModelInstance).isNotNull();

  DecisionTable table = TestHelper.assertAndGetSingleDecisionTable(dmnModelInstance);
  assertThat(table).isNotNull();
  assertThat(table.getInputs()).hasSize(3);
  assertThat(table.getOutputs()).hasSize(1);
  assertThat(table.getRules()).hasSize(4);
}
 
Example #30
Source File: XslxToDmnConversionTest.java    From camunda-dmn-xlsx with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleConversion() {
  XlsxConverter converter = new XlsxConverter();
  InputStream inputStream = TestHelper.getClassPathResource("test1.xlsx");
  DmnModelInstance dmnModelInstance = converter.convert(inputStream);
  assertThat(dmnModelInstance).isNotNull();

  DecisionTable table = TestHelper.assertAndGetSingleDecisionTable(dmnModelInstance);
  assertThat(table).isNotNull();
  assertThat(table.getInputs()).hasSize(2);
  assertThat(table.getOutputs()).hasSize(1);
  assertThat(table.getRules()).hasSize(4);
}