use of org.drools.core.common.EventFactHandle in project drools by kiegroup.
the class DurationTimer method createTrigger.
public Trigger createTrigger(Activation item, InternalWorkingMemory wm) {
long timestamp;
if (eventFactHandle != null) {
Tuple leftTuple = item.getTuple();
EventFactHandle fh = (EventFactHandle) leftTuple.get(eventFactHandle);
timestamp = fh.getStartTimestamp();
} else {
timestamp = wm.getTimerService().getCurrentTime();
}
String[] calendarNames = item.getRule().getCalendars();
Calendars calendars = wm.getCalendars();
return createTrigger(timestamp, calendarNames, calendars);
}
use of org.drools.core.common.EventFactHandle in project drools by kiegroup.
the class TemporalEvaluatorFactoryTest method testBefore.
@Test
public void testBefore() {
registry.addEvaluatorDefinition(BeforeEvaluatorDefinition.class.getName());
EventFactHandle foo = new EventFactHandle(1, "foo", 1, 1, 2, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
EventFactHandle bar = new EventFactHandle(2, "bar", 1, 2, 2, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
EventFactHandle drool = new EventFactHandle(1, "drool", 1, 5, 3, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
final Object[][] data = { { foo, "before", drool, Boolean.TRUE }, { foo, "before", bar, Boolean.FALSE }, { drool, "before", foo, Boolean.FALSE }, { drool, "before", bar, Boolean.FALSE }, { bar, "before", drool, Boolean.TRUE }, { bar, "before", foo, Boolean.FALSE }, { foo, "not before", drool, Boolean.FALSE }, { foo, "not before", bar, Boolean.TRUE }, { drool, "not before", foo, Boolean.TRUE }, { drool, "not before", bar, Boolean.TRUE }, { bar, "not before", drool, Boolean.FALSE }, { bar, "not before", foo, Boolean.TRUE }, { foo, "before[2]", drool, Boolean.TRUE }, { foo, "before[3]", drool, Boolean.FALSE }, { foo, "before[-1]", bar, Boolean.TRUE }, { foo, "before[-2]", bar, Boolean.TRUE }, { bar, "before[1]", drool, Boolean.TRUE }, { bar, "before[2]", drool, Boolean.FALSE }, { bar, "before[-3]", foo, Boolean.TRUE }, { bar, "before[-2]", foo, Boolean.FALSE }, { drool, "before[-6]", bar, Boolean.TRUE }, { drool, "before[-5]", bar, Boolean.FALSE }, { drool, "before[-7]", foo, Boolean.TRUE }, { drool, "before[-8]", foo, Boolean.TRUE }, { foo, "not before[2]", drool, Boolean.FALSE }, { foo, "not before[3]", drool, Boolean.TRUE }, { foo, "not before[-1]", bar, Boolean.FALSE }, { foo, "not before[-2]", bar, Boolean.FALSE }, { bar, "not before[1]", drool, Boolean.FALSE }, { bar, "not before[2]", drool, Boolean.TRUE }, { bar, "not before[-3]", foo, Boolean.FALSE }, { bar, "not before[-2]", foo, Boolean.TRUE }, { drool, "not before[-6]", bar, Boolean.FALSE }, { drool, "not before[-5]", bar, Boolean.TRUE }, { drool, "not before[-7]", foo, Boolean.FALSE }, { drool, "not before[-8]", foo, Boolean.FALSE }, { foo, "before[2,4]", drool, Boolean.TRUE }, { foo, "before[3,4]", drool, Boolean.FALSE }, { foo, "before[-1,1]", bar, Boolean.TRUE }, { foo, "before[0,-2]", bar, Boolean.TRUE }, { bar, "before[0,4]", drool, Boolean.TRUE }, { bar, "before[2,4]", drool, Boolean.FALSE }, { bar, "before[-4,0]", foo, Boolean.TRUE }, { bar, "before[-2,0]", foo, Boolean.FALSE }, { drool, "before[-6,-3]", bar, Boolean.TRUE }, { drool, "before[-5,-3]", bar, Boolean.FALSE }, { drool, "before[-7,-4]", foo, Boolean.TRUE }, { drool, "before[-6,-4]", foo, Boolean.FALSE }, { foo, "not before[2,4]", drool, Boolean.FALSE }, { foo, "not before[3,4]", drool, Boolean.TRUE }, { foo, "not before[-1,1]", bar, Boolean.FALSE }, { foo, "not before[0,-2]", bar, Boolean.FALSE }, { bar, "not before[0,4]", drool, Boolean.FALSE }, { bar, "not before[2,4]", drool, Boolean.TRUE }, { bar, "not before[-4,0]", foo, Boolean.FALSE }, { bar, "not before[-2,0]", foo, Boolean.TRUE }, { drool, "not before[-6,-3]", bar, Boolean.FALSE }, { drool, "not before[-5,-3]", bar, Boolean.TRUE }, { drool, "not before[-7,-4]", foo, Boolean.FALSE }, { drool, "not before[-6,-4]", foo, Boolean.TRUE } };
runEvaluatorTest(data, ValueType.OBJECT_TYPE);
}
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);
}
use of org.drools.core.common.EventFactHandle in project drools by kiegroup.
the class TemporalEvaluatorFactoryTest method testStartedBy.
@Test
public void testStartedBy() {
registry.addEvaluatorDefinition(DuringEvaluatorDefinition.class.getName());
EventFactHandle foo = new EventFactHandle(1, "foo", 1, 2, 10, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
EventFactHandle bar = new EventFactHandle(2, "bar", 1, 2, 7, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
EventFactHandle drool = new EventFactHandle(1, "drool", 1, 2, 10, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
EventFactHandle mole = new EventFactHandle(1, "mole", 1, 1, 6, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
final Object[][] data = { { foo, "startedby", bar, Boolean.TRUE }, { foo, "startedby", drool, Boolean.FALSE }, { foo, "startedby", mole, Boolean.FALSE }, { bar, "startedby", foo, Boolean.FALSE }, { foo, "not startedby", bar, Boolean.FALSE }, { foo, "not startedby", drool, Boolean.TRUE }, { foo, "not startedby", mole, Boolean.TRUE }, { bar, "not startedby", foo, Boolean.TRUE }, { foo, "startedby[1]", bar, Boolean.TRUE }, { foo, "startedby[1]", drool, Boolean.FALSE }, { foo, "startedby[1]", mole, Boolean.TRUE }, { bar, "startedby[1]", foo, Boolean.FALSE }, { foo, "not startedby[1]", bar, Boolean.FALSE }, { foo, "not startedby[1]", drool, Boolean.TRUE }, { foo, "not startedby[1]", mole, Boolean.FALSE }, { bar, "not startedby[1]", foo, Boolean.TRUE }, { foo, "startedby[3]", mole, Boolean.TRUE } };
runEvaluatorTest(data, ValueType.OBJECT_TYPE);
}
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);
}
Aggregations