use of org.kie.dmn.model.v1_1.Decision in project drools by kiegroup.
the class DMNRuntimeTest method testCycleDetectionSelfReference.
@Test
public void testCycleDetectionSelfReference() {
final Definitions defs = buildSimplifiedDefinitions("ns", "self");
final DecisionNodeImpl decision = buildSimplifiedDecisionNode(defs, "self");
decision.addDependency("self", decision);
final DMNModelImpl model = new DMNModelImpl(defs);
model.setDefinitions(defs);
model.addDecision(decision);
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime(this.getClass());
final DMNResult result = runtime.evaluateAll(model, DMNFactory.newContext());
assertTrue(result.hasErrors());
}
use of org.kie.dmn.model.v1_1.Decision in project drools by kiegroup.
the class DMNRuntimeTest method buildSimplifiedDefinitions.
private Definitions buildSimplifiedDefinitions(final String namespace, final String... decisions) {
final Definitions def = new TDefinitions();
def.setNamespace(namespace);
for (final String d : decisions) {
final Decision dec = new TDecision();
dec.setName(d);
def.getDrgElement().add(dec);
def.addChildren(dec);
dec.setParent(def);
}
return def;
}
use of org.kie.dmn.model.v1_1.Decision in project drools by kiegroup.
the class DMNRuntimeTest method buildSimplifiedDefinitions.
private Definitions buildSimplifiedDefinitions(final String namespace, final String... decisions) {
final Definitions def = new TDefinitions();
def.setNamespace(namespace);
for (final String d : decisions) {
final Decision dec = new TDecision();
dec.setName(d);
def.getDrgElement().add(dec);
def.addChildren(dec);
dec.setParent(def);
}
return def;
}
use of org.kie.dmn.model.v1_1.Decision in project drools by kiegroup.
the class DMNRuntimeTest method testCycleDetectionSelfReference.
@Test
public void testCycleDetectionSelfReference() {
final Definitions defs = buildSimplifiedDefinitions("ns", "self");
final DecisionNodeImpl decision = buildSimplifiedDecisionNode(defs, "self");
decision.addDependency("self", decision);
final DMNModelImpl model = new DMNModelImpl(defs);
model.setDefinitions(defs);
model.addDecision(decision);
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime(this.getClass());
final DMNResult result = runtime.evaluateAll(model, DMNFactory.newContext());
assertTrue(result.hasErrors());
}
use of org.kie.dmn.model.v1_1.Decision in project drools by kiegroup.
the class DefinitionsConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
Definitions def = (Definitions) parent;
for (Import i : def.getImport()) {
writeChildrenNode(writer, context, i, IMPORT);
}
for (ItemDefinition id : def.getItemDefinition()) {
writeChildrenNode(writer, context, id, ITEM_DEFINITION);
}
for (DRGElement e : def.getDrgElement()) {
String nodeName = DRG_ELEMENT;
if (e instanceof BusinessKnowledgeModel) {
nodeName = "businessKnowledgeModel";
} else if (e instanceof Decision) {
nodeName = "decision";
} else if (e instanceof InputData) {
nodeName = "inputData";
} else if (e instanceof KnowledgeSource) {
nodeName = "knowledgeSource";
}
writeChildrenNode(writer, context, e, nodeName);
}
for (Artifact a : def.getArtifact()) {
String nodeName = ARTIFACT;
if (a instanceof Association) {
nodeName = "association";
} else if (a instanceof TextAnnotation) {
nodeName = "textAnnotation";
}
writeChildrenNode(writer, context, a, nodeName);
}
for (ElementCollection ec : def.getElementCollection()) {
writeChildrenNode(writer, context, ec, ELEMENT_COLLECTION);
}
for (BusinessContextElement bce : def.getBusinessContextElement()) {
String nodeName = BUSINESS_CONTEXT_ELEMENT;
if (bce instanceof OrganizationUnit) {
nodeName = "organizationUnit";
} else if (bce instanceof PerformanceIndicator) {
nodeName = "performanceIndicator";
}
writeChildrenNode(writer, context, bce, nodeName);
}
}
Aggregations