Search in sources :

Example 6 with RuleBaseConfiguration

use of org.drools.core.RuleBaseConfiguration in project drools by kiegroup.

the class PhreakJoinNodeTest method createContext.

public BuildContext createContext() {
    RuleBaseConfiguration conf = new RuleBaseConfiguration();
    KnowledgeBaseImpl rbase = new KnowledgeBaseImpl("ID", conf);
    BuildContext buildContext = new BuildContext(rbase);
    RuleImpl rule = new RuleImpl("rule1").setPackage("org.pkg1");
    InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.pkg1");
    pkg.getDialectRuntimeRegistry().setDialectData("mvel", new MVELDialectRuntimeData());
    pkg.addRule(rule);
    buildContext.setRule(rule);
    return buildContext;
}
Also used : RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) BuildContext(org.drools.core.reteoo.builder.BuildContext) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 7 with RuleBaseConfiguration

use of org.drools.core.RuleBaseConfiguration in project drools by kiegroup.

the class PhreakNotNodeTest method createContext.

public BuildContext createContext() {
    RuleBaseConfiguration conf = new RuleBaseConfiguration();
    KnowledgeBaseImpl rbase = new KnowledgeBaseImpl("ID", conf);
    BuildContext buildContext = new BuildContext(rbase);
    RuleImpl rule = new RuleImpl("rule1").setPackage("org.pkg1");
    InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.pkg1");
    pkg.getDialectRuntimeRegistry().setDialectData("mvel", new MVELDialectRuntimeData());
    pkg.addRule(rule);
    buildContext.setRule(rule);
    return buildContext;
}
Also used : RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) BuildContext(org.drools.core.reteoo.builder.BuildContext) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 8 with RuleBaseConfiguration

use of org.drools.core.RuleBaseConfiguration in project drools by kiegroup.

the class SegmentPropagationTest method createContext.

public BuildContext createContext() {
    RuleBaseConfiguration conf = new RuleBaseConfiguration();
    KnowledgeBaseImpl rbase = new KnowledgeBaseImpl("ID", conf);
    BuildContext buildContext = new BuildContext(rbase);
    RuleImpl rule = new RuleImpl("rule1").setPackage("org.pkg1");
    InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.pkg1");
    pkg.getDialectRuntimeRegistry().setDialectData("mvel", new MVELDialectRuntimeData());
    pkg.addRule(rule);
    buildContext.setRule(rule);
    return buildContext;
}
Also used : RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) BuildContext(org.drools.core.reteoo.builder.BuildContext) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 9 with RuleBaseConfiguration

use of org.drools.core.RuleBaseConfiguration in project drools by kiegroup.

the class ReteooBuilderPerformanceTest method getReteBuilders.

private static ReteooBuilder[] getReteBuilders(int count) {
    System.out.println("Creating " + count + " ReteBuilder's");
    ReteooBuilder[] reteBuilders = new ReteooBuilder[count];
    RuleBaseConfiguration conf = new RuleBaseConfiguration();
    for (int i = 0; i < reteBuilders.length; i++) {
        reteBuilders[i] = new ReteooBuilder(new KnowledgeBaseImpl("id1", conf));
    }
    return reteBuilders;
}
Also used : RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) ReteooBuilder(org.drools.core.reteoo.ReteooBuilder) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl)

Example 10 with RuleBaseConfiguration

use of org.drools.core.RuleBaseConfiguration in project drools by kiegroup.

the class DynamicRulesTest method testJBRULES_2206.

@Test(timeout = 10000)
public void testJBRULES_2206() {
    KieBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
    ((RuleBaseConfiguration) config).setRuleBaseUpdateHandler(null);
    InternalKnowledgeBase kbase = (InternalKnowledgeBase) getKnowledgeBase(config);
    KieSession session = createKnowledgeSession(kbase);
    AgendaEventListener ael = mock(AgendaEventListener.class);
    session.addEventListener(ael);
    for (int i = 0; i < 5; i++) {
        session.insert(new Cheese());
    }
    kbase.addPackages(loadKnowledgePackages("test_JBRULES_2206_1.drl"));
    ((InternalAgenda) session.getAgenda()).evaluateEagerList();
    // two matching rules were added, so 2 activations should have been created
    verify(ael, times(2)).matchCreated(any(MatchCreatedEvent.class));
    int fireCount = session.fireAllRules();
    // both should have fired
    assertEquals(2, fireCount);
    kbase.addPackages(loadKnowledgePackages("test_JBRULES_2206_2.drl"));
    ((InternalAgenda) session.getAgenda()).evaluateEagerList();
    // one rule was overridden and should activate
    verify(ael, times(3)).matchCreated(any(MatchCreatedEvent.class));
    fireCount = session.fireAllRules();
    // that rule should fire again
    assertEquals(1, fireCount);
    session.dispose();
}
Also used : KieBaseConfiguration(org.kie.api.KieBaseConfiguration) RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) InternalAgenda(org.drools.core.common.InternalAgenda) AgendaEventListener(org.kie.api.event.rule.AgendaEventListener) KieSession(org.kie.api.runtime.KieSession) Cheese(org.drools.compiler.Cheese) MatchCreatedEvent(org.kie.api.event.rule.MatchCreatedEvent) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) EntryPoint(org.kie.api.runtime.rule.EntryPoint) Test(org.junit.Test)

Aggregations

RuleBaseConfiguration (org.drools.core.RuleBaseConfiguration)28 Test (org.junit.Test)14 KieSession (org.kie.api.runtime.KieSession)8 ArrayList (java.util.ArrayList)7 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)6 KnowledgeBaseImpl (org.drools.core.impl.KnowledgeBaseImpl)6 List (java.util.List)5 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)5 BuildContext (org.drools.core.reteoo.builder.BuildContext)5 BetaNodeFieldConstraint (org.drools.core.spi.BetaNodeFieldConstraint)5 KieBase (org.kie.api.KieBase)5 Properties (java.util.Properties)4 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)4 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)4 MVELDialectRuntimeData (org.drools.core.rule.MVELDialectRuntimeData)4 StockTick (org.drools.compiler.StockTick)3 InternalFactHandle (org.drools.core.common.InternalFactHandle)3 BetaMemory (org.drools.core.reteoo.BetaMemory)3 IndexableConstraint (org.drools.core.rule.IndexableConstraint)3 TupleIndexHashTable (org.drools.core.util.index.TupleIndexHashTable)3