Search in sources :

Example 1 with MyComparableHolder

use of org.drools.testcoverage.common.model.MyComparableHolder in project drools by kiegroup.

the class AlphaNodeRangeIndexingTest method testCustomComparable.

@Test
public void testCustomComparable() {
    final String drl = "package org.drools.compiler.test\n" + "import " + MyComparableHolder.class.getCanonicalName() + "\n" + "import " + MyComparable.class.getCanonicalName() + "\n" + "rule test1\n when\n" + "   MyComparableHolder( myComparable >= MyComparable.ABC )\n" + "then\n end\n" + "rule test2\n when\n" + "   MyComparableHolder( myComparable < MyComparable.DEF )\n" + "then\n end\n" + "rule test3\n when\n" + "   MyComparableHolder( myComparable > MyComparable.GHI )\n" + "then\n end\n" + "rule test4\n when\n" + "   MyComparableHolder( myComparable < MyComparable.JKL )\n" + "then\n end\n" + "rule test5\n when\n" + "   MyComparableHolder( myComparable > MyComparable.MNO )\n" + "then\n end\n" + "rule test6\n when\n" + "   MyComparableHolder( myComparable <= MyComparable.PQR )\n" + "then\n end\n";
    final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3);
    final KieSession ksession = kbase.newKieSession();
    // Doesn't support Object type for range index. See CompositeObjectSinkAdapter.isRangeIndexable()
    assertSinks(kbase, MyComparableHolder.class, 6, 6, 0, 0);
    MyComparable abc = new MyComparable("ABC", 1);
    ksession.insert(new MyComparableHolder(abc));
    int fired = ksession.fireAllRules();
    assertEquals(4, fired);
    MyComparable jkl = new MyComparable("JKL", 10);
    ksession.insert(new MyComparableHolder(jkl));
    fired = ksession.fireAllRules();
    assertEquals(3, fired);
}
Also used : KieBase(org.kie.api.KieBase) MyComparable(org.drools.testcoverage.common.model.MyComparable) MyComparableHolder(org.drools.testcoverage.common.model.MyComparableHolder) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Aggregations

MyComparable (org.drools.testcoverage.common.model.MyComparable)1 MyComparableHolder (org.drools.testcoverage.common.model.MyComparableHolder)1 Test (org.junit.Test)1 KieBase (org.kie.api.KieBase)1 KieSession (org.kie.api.runtime.KieSession)1