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)));
}
}
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);
}
}
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());
}
}
}
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);
}
Aggregations