use of org.drools.core.reteoo.builder.BuildContext in project drools by kiegroup.
the class QueryElementNodeTest method setUp.
@Before
public void setUp() {
this.kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
this.buildContext = new BuildContext(kBase);
this.buildContext.setRule(new RuleImpl());
PropagationContextFactory pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
this.context = pctxFactory.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, null);
this.workingMemory = new InstrumentedWorkingMemory(0, this.kBase);
}
use of org.drools.core.reteoo.builder.BuildContext in project drools by kiegroup.
the class ReteTest method testNotShadowed.
@Test
@Ignore
public void testNotShadowed() {
Properties properties = new Properties();
properties.setProperty("drools.shadowProxyExcludes", "org.drools.core.test.model.Cheese");
RuleBaseConfiguration conf = new RuleBaseConfiguration(properties);
InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(conf);
buildContext = new BuildContext(kBase);
final StatefulKnowledgeSessionImpl ksession = new StatefulKnowledgeSessionImpl(1L, kBase);
// Create a Rete network with ObjectTypeNodes for List, Collection and ArrayList
final Rete rete = kBase.getRete();
final EntryPointNode entryPoint = new EntryPointNode(0, rete, buildContext);
entryPoint.attach(buildContext);
final ObjectTypeNode objectTypeNode = new ObjectTypeNode(1, entryPoint, new ClassObjectType(Cheese.class), buildContext);
objectTypeNode.attach(buildContext);
final MockObjectSink sink1 = new MockObjectSink();
objectTypeNode.addObjectSink(sink1);
// There are no String ObjectTypeNodes, make sure its not propagated
final Cheese cheese = new Cheese("brie", 15);
final DefaultFactHandle h1 = new DefaultFactHandle(1, cheese);
rete.assertObject(h1, pctxFactory.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, null), ksession);
ksession.fireAllRules();
final Object[] results = (Object[]) sink1.getAsserted().get(0);
}
use of org.drools.core.reteoo.builder.BuildContext in project drools by kiegroup.
the class ReteTest method setUp.
@Before
public void setUp() throws Exception {
this.kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
this.pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
this.buildContext = new BuildContext(kBase);
this.entryPoint = buildContext.getKnowledgeBase().getRete().getEntryPointNodes().values().iterator().next();
;
}
use of org.drools.core.reteoo.builder.BuildContext in project drools by kiegroup.
the class RuleUnlinkingTest method setUp.
public void setUp(int type) {
KieBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
buildContext = new BuildContext(kBase);
PropagationContextFactory pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
context = pctxFactory.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, null);
ObjectTypeNode otn = new ObjectTypeNode(4, null, new ClassObjectType(String.class), buildContext);
liaNode = new LeftInputAdapterNode(5, otn, buildContext);
n1 = (BetaNode) createNetworkNode(10, type, liaNode, null);
n2 = (BetaNode) createNetworkNode(11, type, n1, null);
n3 = (BetaNode) createNetworkNode(12, type, n2, null);
rule1 = new RuleImpl("rule1");
rule1.setActivationListener("agenda");
rtn1 = (RuleTerminalNode) createNetworkNode(18, RULE_TERMINAL_NODE, n3, rule1);
n4 = (BetaNode) createNetworkNode(13, type, n3, null);
n5 = (BetaNode) createNetworkNode(14, type, n4, null);
rule2 = new RuleImpl("rule2");
rule2.setActivationListener("agenda");
rtn2 = (RuleTerminalNode) createNetworkNode(19, RULE_TERMINAL_NODE, n5, rule2);
n6 = (BetaNode) createNetworkNode(15, type, n5, null);
n7 = (BetaNode) createNetworkNode(16, type, n6, null);
n8 = (BetaNode) createNetworkNode(17, type, n7, null);
rule3 = new RuleImpl("rule3");
rule3.setActivationListener("agenda");
rtn3 = (RuleTerminalNode) createNetworkNode(20, RULE_TERMINAL_NODE, n8, rule3);
// n1 -> n2 -> n3 -> r1
// \
// n4 -> n5 -> r2
// \
// n6 -> n7 -> n8 -> r3
liaNode.addAssociation(rule1);
liaNode.addAssociation(rule2);
liaNode.addAssociation(rule3);
n1.addAssociation(rule1);
n1.addAssociation(rule2);
n1.addAssociation(rule3);
n2.addAssociation(rule1);
n2.addAssociation(rule2);
n2.addAssociation(rule3);
n3.addAssociation(rule1);
n3.addAssociation(rule2);
n3.addAssociation(rule3);
n4.addAssociation(rule2);
n4.addAssociation(rule3);
n5.addAssociation(rule2);
n5.addAssociation(rule3);
n6.addAssociation(rule3);
n7.addAssociation(rule3);
n8.addAssociation(rule3);
}
use of org.drools.core.reteoo.builder.BuildContext in project drools by kiegroup.
the class RuleUnlinkingWithSegmentMemoryTest method setUp.
public void setUp(int type) {
KieBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(kconf);
buildContext = new BuildContext(kBase);
PropagationContextFactory pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
context = pctxFactory.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, null);
ObjectTypeNode otn = new ObjectTypeNode(4, null, new ClassObjectType(String.class), buildContext);
lian = new LeftInputAdapterNode(5, otn, buildContext);
n1 = (BetaNode) createNetworkNode(10, type, lian, null);
n2 = (BetaNode) createNetworkNode(11, type, n1, null);
n3 = (BetaNode) createNetworkNode(12, type, n2, null);
rule1 = new RuleImpl("rule1");
rule1.setActivationListener("agenda");
rtn1 = (RuleTerminalNode) createNetworkNode(18, RULE_TERMINAL_NODE, n3, rule1);
n4 = (BetaNode) createNetworkNode(13, type, n3, null);
n5 = (BetaNode) createNetworkNode(14, type, n4, null);
rule2 = new RuleImpl("rule2");
rule2.setActivationListener("agenda");
rtn2 = (RuleTerminalNode) createNetworkNode(19, RULE_TERMINAL_NODE, n5, rule2);
n6 = (BetaNode) createNetworkNode(15, type, n5, null);
n7 = (BetaNode) createNetworkNode(16, type, n6, null);
n8 = (BetaNode) createNetworkNode(17, type, n7, null);
rule3 = new RuleImpl("rule3");
rule3.setActivationListener("agenda");
rtn3 = (RuleTerminalNode) createNetworkNode(20, RULE_TERMINAL_NODE, n8, rule3);
lian.addAssociation(rule1);
lian.addAssociation(rule2);
lian.addAssociation(rule3);
n1.addAssociation(rule1);
n1.addAssociation(rule2);
n1.addAssociation(rule3);
n2.addAssociation(rule1);
n2.addAssociation(rule2);
n2.addAssociation(rule3);
n3.addAssociation(rule1);
n3.addAssociation(rule2);
n3.addAssociation(rule3);
n4.addAssociation(rule2);
n4.addAssociation(rule3);
n5.addAssociation(rule2);
n5.addAssociation(rule3);
n6.addAssociation(rule3);
n7.addAssociation(rule3);
n8.addAssociation(rule3);
}
Aggregations