Search in sources :

Example 11 with EventFactHandle

use of org.drools.core.common.EventFactHandle in project drools by kiegroup.

the class TemporalEvaluatorFactoryTest method testDuring.

@Test
public void testDuring() {
    registry.addEvaluatorDefinition(DuringEvaluatorDefinition.class.getName());
    EventFactHandle foo = new EventFactHandle(1, "foo", 1, 2, 10, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle bar = new EventFactHandle(2, "bar", 1, 4, 7, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle drool = new EventFactHandle(1, "drool", 1, 1, 5, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle mole = new EventFactHandle(1, "mole", 1, 7, 6, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    final Object[][] data = { { foo, "during", bar, Boolean.FALSE }, { foo, "during", drool, Boolean.FALSE }, { foo, "during", mole, Boolean.FALSE }, { bar, "during", foo, Boolean.TRUE }, { bar, "during", drool, Boolean.FALSE }, { bar, "during", mole, Boolean.FALSE }, { foo, "not during", bar, Boolean.TRUE }, { foo, "not during", drool, Boolean.TRUE }, { foo, "not during", mole, Boolean.TRUE }, { bar, "not during", foo, Boolean.FALSE }, { bar, "not during", drool, Boolean.TRUE }, { bar, "not during", mole, Boolean.TRUE }, { bar, "during[2]", foo, Boolean.TRUE }, { bar, "during[3]", foo, Boolean.TRUE }, { bar, "during[1]", foo, Boolean.FALSE }, { bar, "not during[2]", foo, Boolean.FALSE }, { bar, "not during[3]", foo, Boolean.FALSE }, { bar, "not during[1]", foo, Boolean.TRUE }, { bar, "during[1, 2]", foo, Boolean.TRUE }, { bar, "during[2, 3]", foo, Boolean.FALSE }, { bar, "during[3, 3]", foo, Boolean.FALSE }, { bar, "not during[1, 2]", foo, Boolean.FALSE }, { bar, "not during[2, 3]", foo, Boolean.TRUE }, { bar, "not during[3, 3]", foo, Boolean.TRUE }, { bar, "during[2, 2, 1, 1]", foo, Boolean.TRUE }, { bar, "during[1, 5, 1, 3]", foo, Boolean.TRUE }, { bar, "during[0, 1, 0, 3]", foo, Boolean.FALSE }, { bar, "not during[2, 2, 1, 1]", foo, Boolean.FALSE }, { bar, "not during[1, 5, 1, 3]", foo, Boolean.FALSE }, { bar, "not during[0, 1, 0, 3]", foo, Boolean.TRUE } };
    runEvaluatorTest(data, ValueType.OBJECT_TYPE);
}
Also used : DisconnectedWorkingMemoryEntryPoint(org.drools.core.common.DisconnectedWorkingMemoryEntryPoint) EventFactHandle(org.drools.core.common.EventFactHandle) DuringEvaluatorDefinition(org.drools.core.base.evaluators.DuringEvaluatorDefinition) Test(org.junit.Test)

Example 12 with EventFactHandle

use of org.drools.core.common.EventFactHandle in project drools by kiegroup.

the class TemporalEvaluatorFactoryTest method testOverlapedBy.

@Test
public void testOverlapedBy() {
    registry.addEvaluatorDefinition(DuringEvaluatorDefinition.class.getName());
    EventFactHandle foo = new EventFactHandle(1, "foo", 1, 7, 8, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle bar = new EventFactHandle(2, "bar", 1, 2, 8, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle drool = new EventFactHandle(1, "drool", 1, 11, 5, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle mole = new EventFactHandle(1, "mole", 1, 7, 3, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    final Object[][] data = { { foo, "overlappedby", bar, Boolean.TRUE }, { foo, "overlappedby", drool, Boolean.FALSE }, { foo, "overlappedby", mole, Boolean.FALSE }, { foo, "not overlappedby", bar, Boolean.FALSE }, { foo, "not overlappedby", drool, Boolean.TRUE }, { foo, "not overlappedby", mole, Boolean.TRUE }, { foo, "overlappedby[3]", bar, Boolean.TRUE }, { foo, "overlappedby[3]", drool, Boolean.FALSE }, { foo, "overlappedby[3]", mole, Boolean.FALSE }, { foo, "overlappedby[2]", bar, Boolean.FALSE }, { foo, "overlappedby[6]", mole, Boolean.FALSE }, { foo, "not overlappedby[3]", bar, Boolean.FALSE }, { foo, "not overlappedby[3]", drool, Boolean.TRUE }, { foo, "not overlappedby[3]", mole, Boolean.TRUE }, { foo, "not overlappedby[2]", bar, Boolean.TRUE }, { foo, "not overlappedby[6]", mole, Boolean.TRUE }, { foo, "overlappedby[1,3]", bar, Boolean.TRUE }, { foo, "overlappedby[1,3]", drool, Boolean.FALSE }, { foo, "overlappedby[1,3]", mole, Boolean.FALSE }, { foo, "overlappedby[4,6]", bar, Boolean.FALSE }, { foo, "overlappedby[1,8]", mole, Boolean.FALSE }, { foo, "not overlappedby[1,3]", bar, Boolean.FALSE }, { foo, "not overlappedby[1,3]", drool, Boolean.TRUE }, { foo, "not overlappedby[1,3]", mole, Boolean.TRUE }, { foo, "not overlappedby[4,6]", bar, Boolean.TRUE }, { foo, "not overlappedby[1,8]", mole, Boolean.TRUE } };
    runEvaluatorTest(data, ValueType.OBJECT_TYPE);
}
Also used : DisconnectedWorkingMemoryEntryPoint(org.drools.core.common.DisconnectedWorkingMemoryEntryPoint) EventFactHandle(org.drools.core.common.EventFactHandle) DuringEvaluatorDefinition(org.drools.core.base.evaluators.DuringEvaluatorDefinition) Test(org.junit.Test)

Example 13 with EventFactHandle

use of org.drools.core.common.EventFactHandle in project drools by kiegroup.

the class TemporalEvaluatorFactoryTest method testFinishedBy.

@Test
public void testFinishedBy() {
    registry.addEvaluatorDefinition(DuringEvaluatorDefinition.class.getName());
    EventFactHandle foo = new EventFactHandle(1, "foo", 1, 2, 10, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle bar = new EventFactHandle(2, "bar", 1, 5, 7, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle drool = new EventFactHandle(1, "drool", 1, 2, 10, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle mole = new EventFactHandle(1, "mole", 1, 7, 6, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    final Object[][] data = { { foo, "finishedby", bar, Boolean.TRUE }, { foo, "finishedby", drool, Boolean.FALSE }, { foo, "finishedby", mole, Boolean.FALSE }, { bar, "finishedby", foo, Boolean.FALSE }, { foo, "not finishedby", bar, Boolean.FALSE }, { foo, "not finishedby", drool, Boolean.TRUE }, { foo, "not finishedby", mole, Boolean.TRUE }, { bar, "not finishedby", foo, Boolean.TRUE }, { foo, "finishedby[1]", bar, Boolean.TRUE }, { foo, "finishedby[1]", drool, Boolean.FALSE }, { foo, "finishedby[1]", mole, Boolean.TRUE }, { bar, "finishedby[1]", foo, Boolean.FALSE }, { foo, "not finishedby[1]", bar, Boolean.FALSE }, { foo, "not finishedby[1]", drool, Boolean.TRUE }, { foo, "not finishedby[1]", mole, Boolean.FALSE }, { bar, "not finishedby[1]", foo, Boolean.TRUE }, { foo, "finishedby[3]", mole, Boolean.TRUE } };
    runEvaluatorTest(data, ValueType.OBJECT_TYPE);
}
Also used : DisconnectedWorkingMemoryEntryPoint(org.drools.core.common.DisconnectedWorkingMemoryEntryPoint) EventFactHandle(org.drools.core.common.EventFactHandle) DuringEvaluatorDefinition(org.drools.core.base.evaluators.DuringEvaluatorDefinition) Test(org.junit.Test)

Example 14 with EventFactHandle

use of org.drools.core.common.EventFactHandle in project drools by kiegroup.

the class TemporalEvaluatorFactoryTest method testIncludes.

@Test
public void testIncludes() {
    registry.addEvaluatorDefinition(DuringEvaluatorDefinition.class.getName());
    EventFactHandle foo = new EventFactHandle(1, "foo", 1, 2, 10, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle bar = new EventFactHandle(2, "bar", 1, 4, 7, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle drool = new EventFactHandle(1, "drool", 1, 1, 5, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle mole = new EventFactHandle(1, "mole", 1, 7, 6, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    final Object[][] data = { { bar, "includes", foo, Boolean.FALSE }, { drool, "includes", foo, Boolean.FALSE }, { mole, "includes", foo, Boolean.FALSE }, { foo, "includes", bar, Boolean.TRUE }, { drool, "includes", bar, Boolean.FALSE }, { mole, "includes", bar, Boolean.FALSE }, { bar, "not includes", foo, Boolean.TRUE }, { drool, "not includes", foo, Boolean.TRUE }, { mole, "not includes", foo, Boolean.TRUE }, { foo, "not includes", bar, Boolean.FALSE }, { drool, "not includes", bar, Boolean.TRUE }, { mole, "not includes", bar, Boolean.TRUE }, { foo, "includes[2]", bar, Boolean.TRUE }, { foo, "includes[3]", bar, Boolean.TRUE }, { foo, "includes[1]", bar, Boolean.FALSE }, { foo, "not includes[2]", bar, Boolean.FALSE }, { foo, "not includes[3]", bar, Boolean.FALSE }, { foo, "not includes[1]", bar, Boolean.TRUE }, { foo, "includes[1, 2]", bar, Boolean.TRUE }, { foo, "includes[2, 3]", bar, Boolean.FALSE }, { foo, "includes[3, 3]", bar, Boolean.FALSE }, { foo, "not includes[1, 2]", bar, Boolean.FALSE }, { foo, "not includes[2, 3]", bar, Boolean.TRUE }, { foo, "not includes[3, 3]", bar, Boolean.TRUE }, { foo, "includes[2, 2, 1, 1]", bar, Boolean.TRUE }, { foo, "includes[1, 5, 1, 3]", bar, Boolean.TRUE }, { foo, "includes[0, 1, 0, 3]", bar, Boolean.FALSE }, { foo, "not includes[2, 2, 1, 1]", bar, Boolean.FALSE }, { foo, "not includes[1, 5, 1, 3]", bar, Boolean.FALSE }, { foo, "not includes[0, 1, 0, 3]", bar, Boolean.TRUE } };
    runEvaluatorTest(data, ValueType.OBJECT_TYPE);
}
Also used : DisconnectedWorkingMemoryEntryPoint(org.drools.core.common.DisconnectedWorkingMemoryEntryPoint) EventFactHandle(org.drools.core.common.EventFactHandle) DuringEvaluatorDefinition(org.drools.core.base.evaluators.DuringEvaluatorDefinition) Test(org.junit.Test)

Example 15 with EventFactHandle

use of org.drools.core.common.EventFactHandle in project drools by kiegroup.

the class TemporalEvaluatorFactoryTest method testAfter.

@Test
public void testAfter() {
    registry.addEvaluatorDefinition(AfterEvaluatorDefinition.class.getName());
    EventFactHandle foo = new EventFactHandle(1, "foo", 1, 1, 2, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle bar = new EventFactHandle(2, "bar", 1, 4, 3, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    EventFactHandle drool = new EventFactHandle(1, "drool", 1, 5, 2, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    final Object[][] data = { { drool, "after", foo, Boolean.TRUE }, { drool, "after", bar, Boolean.FALSE }, { bar, "after", foo, Boolean.TRUE }, { bar, "after", drool, Boolean.FALSE }, { foo, "after", drool, Boolean.FALSE }, { foo, "after", bar, Boolean.FALSE }, { foo, "not after", bar, Boolean.TRUE }, { foo, "not after", drool, Boolean.TRUE }, { bar, "not after", drool, Boolean.TRUE }, { bar, "not after", foo, Boolean.FALSE }, { drool, "not after", foo, Boolean.FALSE }, { drool, "not after", bar, Boolean.TRUE }, { bar, "after[1]", foo, Boolean.TRUE }, { bar, "after[0]", foo, Boolean.TRUE }, { bar, "after[-3]", drool, Boolean.TRUE }, { bar, "after[-4]", drool, Boolean.TRUE }, { drool, "after[2]", foo, Boolean.TRUE }, { drool, "after[1]", foo, Boolean.TRUE }, { drool, "after[-2]", bar, Boolean.TRUE }, { drool, "after[-3]", bar, Boolean.TRUE }, { foo, "after[-6]", drool, Boolean.TRUE }, { foo, "after[-7]", drool, Boolean.TRUE }, { foo, "after[-6]", bar, Boolean.TRUE }, { foo, "after[-7]", bar, Boolean.TRUE }, { bar, "not after[1]", foo, Boolean.FALSE }, { bar, "not after[0]", foo, Boolean.FALSE }, { bar, "not after[-3]", drool, Boolean.FALSE }, { bar, "not after[-4]", drool, Boolean.FALSE }, { drool, "not after[2]", foo, Boolean.FALSE }, { drool, "not after[1]", foo, Boolean.FALSE }, { drool, "not after[-2]", bar, Boolean.FALSE }, { drool, "not after[-3]", bar, Boolean.FALSE }, { foo, "not after[-6]", drool, Boolean.FALSE }, { foo, "not after[-7]", drool, Boolean.FALSE }, { foo, "not after[-6]", bar, Boolean.FALSE }, { foo, "not after[-7]", bar, Boolean.FALSE }, { drool, "after[1,4]", foo, Boolean.TRUE }, { drool, "after[3,6]", foo, Boolean.FALSE }, { drool, "after[-3,1]", bar, Boolean.TRUE }, { drool, "after[-1,3]", bar, Boolean.FALSE }, { bar, "after[1,5]", foo, Boolean.TRUE }, { bar, "after[2,5]", foo, Boolean.FALSE }, { bar, "after[-3,0]", drool, Boolean.TRUE }, { bar, "after[-2,1]", drool, Boolean.FALSE }, { foo, "after[-7,-3]", bar, Boolean.TRUE }, { foo, "after[-5,-1]", bar, Boolean.FALSE }, { foo, "after[-6,-5]", drool, Boolean.TRUE }, { foo, "after[-5,-4]", drool, Boolean.FALSE }, { drool, "not after[1,4]", foo, Boolean.FALSE }, { drool, "not after[3,6]", foo, Boolean.TRUE }, { drool, "not after[-3,1]", bar, Boolean.FALSE }, { drool, "not after[-1,3]", bar, Boolean.TRUE }, { bar, "not after[1,5]", foo, Boolean.FALSE }, { bar, "not after[2,5]", foo, Boolean.TRUE }, { bar, "not after[-3,0]", drool, Boolean.FALSE }, { bar, "not after[-2,1]", drool, Boolean.TRUE }, { foo, "not after[-7,-3]", bar, Boolean.FALSE }, { foo, "not after[-5,-1]", bar, Boolean.TRUE }, { foo, "not after[-6,-5]", drool, Boolean.FALSE }, { foo, "not after[-5,-4]", drool, Boolean.TRUE } };
    runEvaluatorTest(data, ValueType.OBJECT_TYPE);
}
Also used : DisconnectedWorkingMemoryEntryPoint(org.drools.core.common.DisconnectedWorkingMemoryEntryPoint) AfterEvaluatorDefinition(org.drools.core.base.evaluators.AfterEvaluatorDefinition) EventFactHandle(org.drools.core.common.EventFactHandle) Test(org.junit.Test)

Aggregations

EventFactHandle (org.drools.core.common.EventFactHandle)86 Test (org.junit.Test)51 KieSession (org.kie.api.runtime.KieSession)23 KieBase (org.kie.api.KieBase)18 InternalFactHandle (org.drools.core.common.InternalFactHandle)16 DisconnectedWorkingMemoryEntryPoint (org.drools.core.common.DisconnectedWorkingMemoryEntryPoint)13 DisconnectedWorkingMemoryEntryPoint (org.drools.kiesession.entrypoints.DisconnectedWorkingMemoryEntryPoint)13 FactHandle (org.kie.api.runtime.rule.FactHandle)11 DuringEvaluatorDefinition (org.drools.core.base.evaluators.DuringEvaluatorDefinition)10 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)10 ObjectMarshallingStrategy (org.kie.api.marshalling.ObjectMarshallingStrategy)8 ArrayList (java.util.ArrayList)6 List (java.util.List)6 QueryElementFactHandle (org.drools.core.common.QueryElementFactHandle)6 WorkingMemoryEntryPoint (org.drools.core.WorkingMemoryEntryPoint)5 ObjectTypeConf (org.drools.core.reteoo.ObjectTypeConf)5 PropagationContext (org.drools.core.spi.PropagationContext)5 StockTick (org.drools.testcoverage.common.model.StockTick)5 EntryPointId (org.drools.core.rule.EntryPointId)4 AlphaNodeFieldConstraint (org.drools.core.spi.AlphaNodeFieldConstraint)4