Package org.drools.common

Examples of org.drools.common.EventFactHandle


    @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" ) );
View Full Code Here


    @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" ) );
View Full Code Here

    @Test
    public void testMeets() {
        registry.addEvaluatorDefinition( DuringEvaluatorDefinition.class.getName() );

        EventFactHandle foo = new EventFactHandle( 1,
                                                   "foo",
                                                   1,
                                                   2,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle bar = new EventFactHandle( 2,
                                                   "bar",
                                                   1,
                                                   10,
                                                   7,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle drool = new EventFactHandle( 1,
                                                     "drool",
                                                     1,
                                                     8,
                                                     5,
                                                     new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle mole = new EventFactHandle( 1,
                                                    "mole",
                                                    1,
                                                    11,
                                                    4,
                                                    new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
View Full Code Here

    @Test
    public void testMetBy() {
        registry.addEvaluatorDefinition( DuringEvaluatorDefinition.class.getName() );

        EventFactHandle foo = new EventFactHandle( 1,
                                                   "foo",
                                                   1,
                                                   10,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle bar = new EventFactHandle( 2,
                                                   "bar",
                                                   1,
                                                   2,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle drool = new EventFactHandle( 1,
                                                     "drool",
                                                     1,
                                                     5,
                                                     3,
                                                     new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle mole = new EventFactHandle( 1,
                                                    "mole",
                                                    1,
                                                    4,
                                                    7,
                                                    new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
View Full Code Here

    @Test
    public void testOverlaps() {
        registry.addEvaluatorDefinition( DuringEvaluatorDefinition.class.getName() );

        EventFactHandle foo = new EventFactHandle( 1,
                                                   "foo",
                                                   1,
                                                   2,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle bar = new EventFactHandle( 2,
                                                   "bar",
                                                   1,
                                                   7,
                                                   7,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle drool = new EventFactHandle( 1,
                                                     "drool",
                                                     1,
                                                     11,
                                                     5,
                                                     new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle mole = new EventFactHandle( 1,
                                                    "mole",
                                                    1,
                                                    5,
                                                    5,
                                                    new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
View Full Code Here

    @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" ) );
View Full Code Here

    private static class SlidingTimeWindowComparator
        implements
        Comparator<RightTuple> {
        public int compare(RightTuple t1,
                           RightTuple t2) {
            final EventFactHandle e1 = (EventFactHandle) t1.getFactHandle();
            final EventFactHandle e2 = (EventFactHandle) t2.getFactHandle();
            return (e1.getStartTimestamp() < e2.getStartTimestamp()) ? -1 : (e1.getStartTimestamp() == e2.getStartTimestamp() ? 0 : 1);
        }
View Full Code Here

        assertTrue( handle1.isEvent() );
        assertTrue( handle2.isEvent() );
        assertTrue( handle3.isEvent() );
        assertTrue( handle4.isEvent() );

        EventFactHandle eh1 = (EventFactHandle) handle1;
        EventFactHandle eh2 = (EventFactHandle) handle2;
        EventFactHandle eh3 = (EventFactHandle) handle3;
        EventFactHandle eh4 = (EventFactHandle) handle4;

        assertEquals( tick1.getTime(),
                      eh1.getStartTimestamp() );
        assertEquals( tick2.getTime(),
                      eh2.getStartTimestamp() );
        assertEquals( tick3.getTime(),
                      eh3.getStartTimestamp() );
        assertEquals( tick4.getTime(),
                      eh4.getStartTimestamp() );

        assertEquals( tick1.getDuration(),
                      eh1.getDuration() );
        assertEquals( tick2.getDuration(),
                      eh2.getDuration() );
        assertEquals( tick3.getDuration(),
                      eh3.getDuration() );
        assertEquals( tick4.getDuration(),
                      eh4.getDuration() );

        wm.fireAllRules();

        assertEquals( 2,
                      results.size() );
View Full Code Here

        assertTrue( handle1.isEvent() );
        assertTrue( handle2.isEvent() );
        assertTrue( handle3.isEvent() );
        assertTrue( handle4.isEvent() );

        EventFactHandle eh1 = (EventFactHandle) handle1;
        EventFactHandle eh2 = (EventFactHandle) handle2;
        EventFactHandle eh3 = (EventFactHandle) handle3;
        EventFactHandle eh4 = (EventFactHandle) handle4;

        assertEquals( tick1.getTime(),
                      eh1.getStartTimestamp() );
        assertEquals( tick2.getTime(),
                      eh2.getStartTimestamp() );
        assertEquals( tick3.getTime(),
                      eh3.getStartTimestamp() );
        assertEquals( tick4.getTime(),
                      eh4.getStartTimestamp() );

        wm.fireAllRules();

        assertEquals( 2,
                      results.size() );
View Full Code Here

        final List results = new ArrayList();
        ksession.setGlobal( "results",
                            results );

        EventFactHandle handle1 = (EventFactHandle) eventStream.insert( new StockTick( 1,
                                                                                       "ACME",
                                                                                       50,
                                                                                       System.currentTimeMillis(),
                                                                                       3 ) );

        ksession.fireAllRules();

        clock.advanceTime( 11,
                           TimeUnit.SECONDS );
        /** clock.advance() will put the event expiration in the queue to be executed,
            but it has to wait for a "thread" to do that
            so we fire rules again here to get that
            alternative could run fireUntilHalt() **/
        ksession.fireAllRules();

        assertTrue( results.size() == 1 );
        assertTrue( handle1.isExpired() );
        assertFalse( ksession.getFactHandles().contains( handle1 ) );
    }
View Full Code Here

TOP

Related Classes of org.drools.common.EventFactHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.