Search in sources :

Example 6 with DisconnectedWorkingMemoryEntryPoint

use of org.drools.core.common.DisconnectedWorkingMemoryEntryPoint 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)

Example 7 with DisconnectedWorkingMemoryEntryPoint

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

the class FactHandleTest method testFactHandleImpllonglong.

/*
     * Class under test for void FactHandleImpl(long, long)
     */
@Test
public void testFactHandleImpllonglong() {
    final DefaultFactHandle f0 = new DefaultFactHandle(134, "cheese", 678, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    assertEquals(134, f0.getId());
    assertEquals(678, f0.getRecency());
}
Also used : DisconnectedWorkingMemoryEntryPoint(org.drools.core.common.DisconnectedWorkingMemoryEntryPoint) DefaultFactHandle(org.drools.core.common.DefaultFactHandle) Test(org.junit.Test)

Example 8 with DisconnectedWorkingMemoryEntryPoint

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

the class CompositeObjectSinkAdapterTest method testPropagationWithNullValue.

@Test
public void testPropagationWithNullValue() {
    final CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
    InternalReadAccessor extractor = store.getReader(Cheese.class, "type");
    final MvelConstraint lit1 = new MvelConstraintTestUtil("type == \"stilton\"", new ObjectFieldImpl("stilton"), new MockExtractor());
    final AlphaNode al1 = new AlphaNode(buildContext.getNextId(), lit1, new MockObjectSource(buildContext.getNextId()), buildContext);
    final MvelConstraint lit2 = new MvelConstraintTestUtil("type == \"brie\"", new ObjectFieldImpl("brie"), new MockExtractor());
    final AlphaNode al2 = new AlphaNode(buildContext.getNextId(), lit2, new MockObjectSource(buildContext.getNextId()), buildContext);
    final MvelConstraint lit3 = new MvelConstraintTestUtil("type == \"muzzarela\"", new ObjectFieldImpl("muzzarela"), new MockExtractor());
    final AlphaNode al3 = new AlphaNode(buildContext.getNextId(), lit3, new MockObjectSource(buildContext.getNextId()), buildContext);
    ad.addObjectSink(al1);
    ad.addObjectSink(al2);
    ad.addObjectSink(al3);
    InternalFactHandle handle = new ReteooFactHandleFactory().newFactHandle(new Cheese(), null, null, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    try {
        ad.propagateAssertObject(handle, null, null);
    } catch (RuntimeException e) {
        fail("Not supposed to throw any exception: " + e.getMessage());
    }
}
Also used : DisconnectedWorkingMemoryEntryPoint(org.drools.core.common.DisconnectedWorkingMemoryEntryPoint) MvelConstraint(org.drools.core.rule.constraint.MvelConstraint) Cheese(org.drools.core.test.model.Cheese) MvelConstraintTestUtil(org.drools.core.rule.MvelConstraintTestUtil) InternalReadAccessor(org.drools.core.spi.InternalReadAccessor) ObjectFieldImpl(org.drools.core.base.field.ObjectFieldImpl) InternalFactHandle(org.drools.core.common.InternalFactHandle) Test(org.junit.Test)

Example 9 with DisconnectedWorkingMemoryEntryPoint

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

the class TemporalEvaluatorFactoryTest method testCoincides.

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

Example 10 with DisconnectedWorkingMemoryEntryPoint

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

the class TemporalEvaluatorFactoryTest method testStarts.

@Test
public void testStarts() {
    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, 4, new DisconnectedWorkingMemoryEntryPoint("DEFAULT"));
    final Object[][] data = { { bar, "starts", foo, Boolean.TRUE }, { drool, "starts", foo, Boolean.FALSE }, { mole, "starts", foo, Boolean.FALSE }, { foo, "starts", bar, Boolean.FALSE }, { bar, "not starts", foo, Boolean.FALSE }, { drool, "not starts", foo, Boolean.TRUE }, { mole, "not starts", foo, Boolean.TRUE }, { foo, "not starts", bar, Boolean.TRUE }, { bar, "starts[1]", foo, Boolean.TRUE }, { drool, "starts[1]", foo, Boolean.FALSE }, { mole, "starts[1]", foo, Boolean.TRUE }, { foo, "starts[1]", bar, Boolean.FALSE }, { bar, "not starts[1]", foo, Boolean.FALSE }, { drool, "not starts[1]", foo, Boolean.TRUE }, { mole, "not starts[1]", foo, Boolean.FALSE }, { foo, "not starts[1]", bar, Boolean.TRUE }, { mole, "starts[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)

Aggregations

DisconnectedWorkingMemoryEntryPoint (org.drools.core.common.DisconnectedWorkingMemoryEntryPoint)15 Test (org.junit.Test)15 EventFactHandle (org.drools.core.common.EventFactHandle)13 DuringEvaluatorDefinition (org.drools.core.base.evaluators.DuringEvaluatorDefinition)10 AfterEvaluatorDefinition (org.drools.core.base.evaluators.AfterEvaluatorDefinition)1 BeforeEvaluatorDefinition (org.drools.core.base.evaluators.BeforeEvaluatorDefinition)1 CoincidesEvaluatorDefinition (org.drools.core.base.evaluators.CoincidesEvaluatorDefinition)1 ObjectFieldImpl (org.drools.core.base.field.ObjectFieldImpl)1 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)1 InternalFactHandle (org.drools.core.common.InternalFactHandle)1 MvelConstraintTestUtil (org.drools.core.rule.MvelConstraintTestUtil)1 MvelConstraint (org.drools.core.rule.constraint.MvelConstraint)1 InternalReadAccessor (org.drools.core.spi.InternalReadAccessor)1 Cheese (org.drools.core.test.model.Cheese)1