Search in sources :

Example 16 with Decision

use of org.kie.dmn.model.api.Decision in project drools by kiegroup.

the class OverlapHitPolicyTest method testOverlapHitPolicy.

@Test
public void testOverlapHitPolicy() {
    Definitions definitions = getDefinitions("OverlapHitPolicy.dmn", "https://github.com/kiegroup/drools/kie-dmn/_3010653A-DD3F-4C88-89DA-3FDD845F6604", "OverlapHitPolicy");
    // mutates XML file in the Hit Policy, accordingly to this test parameter.
    ((DecisionTable) ((Decision) definitions.getDrgElement().get(0)).getExpression()).setHitPolicy(hp);
    List<DMNMessage> validate = validator.validate(definitions, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE);
    checkAnalysis(validate);
    if (hp == HitPolicy.UNIQUE) {
        assertTrue("It should contain at least 1 DMNMessage for the type", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP_HITPOLICY_UNIQUE)));
    } else if (hp == HitPolicy.ANY) {
        assertTrue("It should contain at least 1 DMNMessage for the type", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP_HITPOLICY_ANY)));
    } else {
        LOG.debug("Testing for {} I am expecting there is NOT DMNMessage pertaining to Overlaps", hp);
        assertTrue(validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP_HITPOLICY_UNIQUE)) && validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP_HITPOLICY_ANY)) && validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP)));
    }
}
Also used : Arrays(java.util.Arrays) RangeBoundary(org.kie.dmn.feel.runtime.Range.RangeBoundary) DecisionTable(org.kie.dmn.model.api.DecisionTable) DMNMessage(org.kie.dmn.api.core.DMNMessage) Bound(org.kie.dmn.validation.dtanalysis.model.Bound) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) VALIDATE_COMPILATION(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION) RunWith(org.junit.runner.RunWith) Definitions(org.kie.dmn.model.api.Definitions) BigDecimal(java.math.BigDecimal) Hyperrectangle(org.kie.dmn.validation.dtanalysis.model.Hyperrectangle) Decision(org.kie.dmn.model.api.Decision) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Parameterized(org.junit.runners.Parameterized) Interval(org.kie.dmn.validation.dtanalysis.model.Interval) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Collectors(java.util.stream.Collectors) HitPolicy(org.kie.dmn.model.api.HitPolicy) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) Overlap(org.kie.dmn.validation.dtanalysis.model.Overlap) ANALYZE_DECISION_TABLE(org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE) DecisionTable(org.kie.dmn.model.api.DecisionTable) DMNMessage(org.kie.dmn.api.core.DMNMessage) Definitions(org.kie.dmn.model.api.Definitions) Test(org.junit.Test)

Example 17 with Decision

use of org.kie.dmn.model.api.Decision in project drools by kiegroup.

the class DecisionConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Decision dec = (Decision) parent;
    if (dec.getQuestion() != null)
        writeChildrenNodeAsValue(writer, context, dec.getQuestion(), QUESTION);
    if (dec.getAllowedAnswers() != null)
        writeChildrenNodeAsValue(writer, context, dec.getAllowedAnswers(), ALLOWED_ANSWERS);
    if (dec.getVariable() != null)
        writeChildrenNode(writer, context, dec.getVariable(), VARIABLE);
    for (InformationRequirement ir : dec.getInformationRequirement()) {
        writeChildrenNode(writer, context, ir, INFORMATION_REQUIREMENT);
    }
    for (KnowledgeRequirement kr : dec.getKnowledgeRequirement()) {
        writeChildrenNode(writer, context, kr, KNOWLEDGE_REQUIREMENT);
    }
    for (AuthorityRequirement ar : dec.getAuthorityRequirement()) {
        writeChildrenNode(writer, context, ar, AUTHORITY_REQUIREMENT);
    }
    for (DMNElementReference so : dec.getSupportedObjective()) {
        writeChildrenNode(writer, context, so, SUPPORTED_OBJECTIVE);
    }
    for (DMNElementReference ipi : dec.getImpactedPerformanceIndicator()) {
        writeChildrenNode(writer, context, ipi, IMPACTED_PERFORMANCE_INDICATOR);
    }
    for (DMNElementReference dm : dec.getDecisionMaker()) {
        writeChildrenNode(writer, context, dm, DECISION_MAKER);
    }
    for (DMNElementReference downer : dec.getDecisionOwner()) {
        writeChildrenNode(writer, context, downer, DECISION_OWNER);
    }
    for (DMNElementReference up : dec.getUsingProcess()) {
        writeChildrenNode(writer, context, up, USING_PROCESS);
    }
    for (DMNElementReference ut : dec.getUsingTask()) {
        writeChildrenNode(writer, context, ut, USING_TASK);
    }
    if (dec.getExpression() != null) {
        Expression e = dec.getExpression();
        String nodeName = MarshallingUtils.defineExpressionNodeName(xstream, e);
        writeChildrenNode(writer, context, e, nodeName);
    }
}
Also used : KnowledgeRequirement(org.kie.dmn.model.api.KnowledgeRequirement) DMNElementReference(org.kie.dmn.model.api.DMNElementReference) InformationRequirement(org.kie.dmn.model.api.InformationRequirement) Expression(org.kie.dmn.model.api.Expression) AuthorityRequirement(org.kie.dmn.model.api.AuthorityRequirement) TDecision(org.kie.dmn.model.v1_3.TDecision) Decision(org.kie.dmn.model.api.Decision)

Example 18 with Decision

use of org.kie.dmn.model.api.Decision in project drools by kiegroup.

the class DMNModelIOSets method buildIODoc.

private void buildIODoc() {
    for (DRGElement drge : model.getDefinitions().getDrgElement()) {
        if (drge instanceof InputData) {
            inputDoc.put(drge.getName(), drge.getDescription());
            outputDoc.put(drge.getName(), drge.getDescription());
        } else if (drge instanceof Decision) {
            outputDoc.put(drge.getName(), drge.getDescription());
        }
    }
}
Also used : InputData(org.kie.dmn.model.api.InputData) Decision(org.kie.dmn.model.api.Decision) DRGElement(org.kie.dmn.model.api.DRGElement)

Example 19 with Decision

use of org.kie.dmn.model.api.Decision in project kie-wb-common by kiegroup.

the class QNamePropertyConverterTest method testWBfromDMNForBuiltInDataType11variant.

@Test
public void testWBfromDMNForBuiltInDataType11variant() {
    final Decision parent11_variant = new org.kie.dmn.model.v1_1.TDecision();
    final String nonTrivialFEELPrefix = "friendlyenough";
    parent11_variant.getNsContext().put(nonTrivialFEELPrefix, parent11_variant.getURIFEEL());
    final javax.xml.namespace.QName dmn = new javax.xml.namespace.QName(XMLConstants.NULL_NS_URI, BuiltInType.STRING.getName(), nonTrivialFEELPrefix);
    final QName wb = QNamePropertyConverter.wbFromDMN(dmn, parent11_variant);
    assertThat(wb).isNotNull();
    assertThat(wb.getNamespaceURI()).isEqualTo(QName.NULL_NS_URI);
    assertThat(wb.getLocalPart()).isEqualTo(BuiltInType.STRING.getName());
    assertThat(wb.getPrefix()).isEqualTo(QName.DEFAULT_NS_PREFIX);
}
Also used : QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Decision(org.kie.dmn.model.api.Decision) Test(org.junit.Test)

Aggregations

Decision (org.kie.dmn.model.api.Decision)19 Definitions (org.kie.dmn.model.api.Definitions)8 InputData (org.kie.dmn.model.api.InputData)6 BusinessKnowledgeModel (org.kie.dmn.model.api.BusinessKnowledgeModel)5 DMNElementReference (org.kie.dmn.model.api.DMNElementReference)5 DRGElement (org.kie.dmn.model.api.DRGElement)5 InformationRequirement (org.kie.dmn.model.api.InformationRequirement)5 Artifact (org.kie.dmn.model.api.Artifact)4 Association (org.kie.dmn.model.api.Association)4 AuthorityRequirement (org.kie.dmn.model.api.AuthorityRequirement)4 BusinessContextElement (org.kie.dmn.model.api.BusinessContextElement)4 ElementCollection (org.kie.dmn.model.api.ElementCollection)4 Expression (org.kie.dmn.model.api.Expression)4 Import (org.kie.dmn.model.api.Import)4 ItemDefinition (org.kie.dmn.model.api.ItemDefinition)4 KnowledgeRequirement (org.kie.dmn.model.api.KnowledgeRequirement)4 KnowledgeSource (org.kie.dmn.model.api.KnowledgeSource)4 OrganizationUnit (org.kie.dmn.model.api.OrganizationUnit)4 PerformanceIndicator (org.kie.dmn.model.api.PerformanceIndicator)4 TextAnnotation (org.kie.dmn.model.api.TextAnnotation)4