Package org.drools

Examples of org.drools.StockTick


       
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        AgendaEventListener ael = mock( AgendaEventListener.class );
        ksession.addEventListener( ael );
       
        ksession.insert( new StockTick(1, "RHT", 80, 1 ) );
        ksession.insert( new StockTick(2, "RHT", 100, 10 ) );
        int rules = ksession.fireAllRules();
        assertEquals( 1, rules );
       
        ArgumentCaptor<AfterActivationFiredEvent> cap = ArgumentCaptor.forClass( AfterActivationFiredEvent.class );
        verify( ael ).afterActivationFired( cap.capture() );
View Full Code Here


       
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages( Collections.singletonList( kpkg ) );
       
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        ksession.insert( new StockTick(1, "RHT", 80, 1 ) );
        int rules = ksession.fireAllRules();
        assertEquals( 0, rules );

        ksession = kbase.newStatefulKnowledgeSession();
        ksession.insert( new StockTick(2, "RHT", 150, 1 ) );
        rules = ksession.fireAllRules();
        assertEquals( 1, rules );
    }
View Full Code Here

    @Test
    public void testConnectorsAndOperators() throws Exception {
        final KnowledgeBase kbase = SerializationHelper.serializeObject( loadKnowledgeBase( "test_ConstraintConnectorsAndOperators.drl" ) );
        final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        ksession.insert( new StockTick( 1,
                                        "RHT",
                                        10,
                                        1000 ) );
        ksession.insert( new StockTick( 2,
                                        "IBM",
                                        10,
                                        1100 ) );
        final int fired = ksession.fireAllRules();
View Full Code Here

        final List results = new ArrayList();

        session.setGlobal("results",
                results);

        StockTickInterface tick1 = new StockTick(1,
                "DROO",
                50,
                System.currentTimeMillis());
        StockTickInterface tick2 = new StockTick(2,
                "ACME",
                10,
                System.currentTimeMillis());
        StockTickInterface tick3 = new StockTick(3,
                "ACME",
                10,
                System.currentTimeMillis());
        StockTickInterface tick4 = new StockTick(4,
                "DROO",
                50,
                System.currentTimeMillis());

        InternalFactHandle handle1 = (InternalFactHandle) session.insert(tick1);
        InternalFactHandle handle2 = (InternalFactHandle) session.insert(tick2);
        InternalFactHandle handle3 = (InternalFactHandle) session.insert(tick3);
        InternalFactHandle handle4 = (InternalFactHandle) session.insert(tick4);

        assertNotNull(handle1);
        assertNotNull(handle2);
        assertNotNull(handle3);
        assertNotNull(handle4);

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

        session.fireAllRules();

        assertEquals(0,
                results.size());

        StockTickInterface tick5 = new StockTick(5,
                "DROO",
                50,
                System.currentTimeMillis());
        StockTickInterface tick6 = new StockTick(6,
                "ACME",
                10,
                System.currentTimeMillis());
        StockTickInterface tick7 = new StockTick(7,
                "ACME",
                15,
                System.currentTimeMillis());
        StockTickInterface tick8 = new StockTick(8,
                "DROO",
                50,
                System.currentTimeMillis());

        WorkingMemoryEntryPoint entry = session.getWorkingMemoryEntryPoint("StockStream");
View Full Code Here

        final List<StockTick> results = new ArrayList<StockTick>();
        session.setGlobal("results",
                results);

        StockTickInterface tick5 = new StockTick(5,
                "DROO",
                50,
                System.currentTimeMillis());
        StockTickInterface tick6 = new StockTick(6,
                "ACME",
                10,
                System.currentTimeMillis());
        StockTickInterface tick7 = new StockTick(7,
                "ACME",
                30,
                System.currentTimeMillis());
        StockTickInterface tick8 = new StockTick(8,
                "DROO",
                50,
                System.currentTimeMillis());

        WorkingMemoryEntryPoint entry = session.getWorkingMemoryEntryPoint("stream1");
View Full Code Here

        final List<? extends Number> results = new ArrayList<Number>();
        session.setGlobal( "results",
                results );

        StockTickInterface tick5 = new StockTick( 5,
                "DROO",
                50,
                System.currentTimeMillis() );
        StockTickInterface tick6 = new StockTick( 6,
                "ACME",
                10,
                System.currentTimeMillis() );
        StockTickInterface tick7 = new StockTick( 7,
                "ACME",
                30,
                System.currentTimeMillis() );
        StockTickInterface tick8 = new StockTick( 8,
                "DROO",
                50,
                System.currentTimeMillis() );

        WorkingMemoryEntryPoint entry = session.getWorkingMemoryEntryPoint( "stream1" );
View Full Code Here

        WorkingMemoryEntryPoint ep1 = ksession.getWorkingMemoryEntryPoint("ep1");
        WorkingMemoryEntryPoint ep2 = ksession.getWorkingMemoryEntryPoint("ep2");
        WorkingMemoryEntryPoint ep3 = ksession.getWorkingMemoryEntryPoint("ep3");

        ep1.insert(new StockTick(1,
                "RHT",
                10,
                1000));
        ep2.insert(new StockTick(1,
                "RHT",
                10,
                1000));
        ep3.insert(new StockTick(1,
                "RHT",
                10,
                1000));
        int rulesFired = ksession.fireAllRules();
        assertEquals(3,
View Full Code Here

        WorkingMemoryEventListener wml = mock(WorkingMemoryEventListener.class);
        ksession.addEventListener(wml);

        PseudoClockScheduler clock = (PseudoClockScheduler) ksession.<SessionClock> getSessionClock();

        final StockTickInterface st1 = new StockTick(1,
                "RHT",
                100,
                1000);
        final StockTickInterface st2 = new StockTick(2,
                "RHT",
                100,
                1000);

        ksession.insert(st1);
View Full Code Here

        AgendaEventListener ael = mock(AgendaEventListener.class);
        ksession.addEventListener(ael);

        PseudoClockScheduler clock = (PseudoClockScheduler) ksession.<SessionClock> getSessionClock();

        final StockTickInterface st1 = new StockTick(1,
                "RHT",
                100,
                1000);
        final StockTickInterface st2 = new StockTick(2,
                "RHT",
                100,
                1000);

        ksession.insert(st1);
View Full Code Here

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        AgendaEventListener ael = mock(AgendaEventListener.class);
        ksession.addEventListener(ael);

        WorkingMemoryEntryPoint ep = ksession.getWorkingMemoryEntryPoint("ticks");
        ep.insert(new StockTick(1, "ACME", 20, 1000)); // not in the window
        ep.insert(new StockTick(2, "RHT", 20, 1000)); // not > 20
        ep.insert(new StockTick(3, "RHT", 30, 1000));
        ep.insert(new StockTick(4, "ACME", 30, 1000)); // not in the window
        ep.insert(new StockTick(5, "RHT", 25, 1000));
        ep.insert(new StockTick(6, "ACME", 10, 1000)); // not in the window
        ep.insert(new StockTick(7, "RHT", 10, 1000)); // not > 20
        ep.insert(new StockTick(8, "RHT", 40, 1000));

        ksession.fireAllRules();

        ArgumentCaptor<org.drools.event.rule.AfterActivationFiredEvent> captor = ArgumentCaptor.forClass(org.drools.event.rule.AfterActivationFiredEvent.class);
        verify(ael,
View Full Code Here

TOP

Related Classes of org.drools.StockTick

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.