Package org.drools.time

Examples of org.drools.time.SessionPseudoClock.advanceTime()


        ksession.fireAllRules();
        assertEquals( 3, // we need to fix forall to not fire in this situation
                      results.size() );

        // advance time... forall still matches and should not fire
        clock.advanceTime( 60,
                           TimeUnit.SECONDS );
        ksession.fireAllRules();
        assertEquals( 4, // we need to fix forall to not fire in this situation
                      results.size() );
View Full Code Here


        for ( StatefulKnowledgeSession ksession : this.ksessions ) {
            SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
            long newTime = startTime + step.getDistanceMillis();
            long currentTime = clock.getCurrentTime();

            clock.advanceTime( newTime - currentTime,
                               TimeUnit.MILLISECONDS );
        }

        for ( Command cmd : step.getCommands() ) {
            if ( cmd instanceof NewStatefulKnowledgeSessionCommand ) {
View Full Code Here

                                                                                                         pathContext );
                if ( ksession != null ) {
                    SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
                    long newTime = startTime + step.getDistanceMillis();
                    long currentTime = clock.getCurrentTime();
                    clock.advanceTime( newTime - currentTime,
                                       TimeUnit.MILLISECONDS );
                    this.ksessions.add( ksession );
                    this.lastReturnValue = ksession;
                }
            } else if ( cmd instanceof GenericCommand ) {
View Full Code Here

        for ( StatefulKnowledgeSession ksession : this.ksessions ) {
          SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
 
          long newTime = this.startTime + step.getTemporalDistance();
          long currentTime = clock.getCurrentTime();
          clock.advanceTime( (currentTime + (newTime - currentTime)),
                             TimeUnit.MICROSECONDS );           
        }
       
        for ( Command cmd : step.getCommands() ) {
            if ( cmd instanceof KnowledgeContextResolveFromContextCommand) {
View Full Code Here

                    // instantiate the ksession, set it's clock and register it
                    StatefulKnowledgeSession ksession = ( StatefulKnowledgeSession ) executionHandler.execute( (GenericCommand) cmd, pathContext );
                    if ( ksession != null ) {
                        SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
                        if ( clock.getCurrentTime() == 0 ) {
                            clock.advanceTime( startTime,
                                               TimeUnit.MILLISECONDS );
                        }
                        this.ksessions.add( ksession );
                    }
                } else if ( cmd instanceof GenericCommand) {
View Full Code Here

        for ( StatefulKnowledgeSession ksession : this.ksessions ) {
            SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
            long newTime = startTime + step.getTemporalDistance();
            long currentTime = clock.getCurrentTime();

            clock.advanceTime( newTime - currentTime,
                               TimeUnit.MILLISECONDS );
        }

        for ( Command cmd : step.getCommands() ) {
            if ( cmd instanceof NewStatefulKnowledgeSessionCommand ) {
View Full Code Here

                                                                                                         pathContext );
                if ( ksession != null ) {
                    SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
                    long newTime = startTime + step.getTemporalDistance();
                    long currentTime = clock.getCurrentTime();
                    clock.advanceTime( newTime - currentTime,
                                       TimeUnit.MILLISECONDS );
                    this.ksessions.add( ksession );
                    this.lastReturnValue = ksession;
                }
            } else if ( cmd instanceof GenericCommand ) {
View Full Code Here

        // still under the threshold, so no fire
        assertEquals( 3,
                      results.size() );

        // advance clock and assert new data
        clock.advanceTime( 10,
                           TimeUnit.SECONDS ); // 10 seconds
        EventFactHandle handle6 = (EventFactHandle) wm.insert( new OrderEvent( "6",
                                                                               "customer A",
                                                                               115 ) );
        assertEquals( 55000,
View Full Code Here

        wm.setGlobal( "results",
                      results );

        SessionPseudoClock clock = (SessionPseudoClock) wm.getSessionClock();

        clock.advanceTime( 10,
                           TimeUnit.SECONDS );

        StockTickInterface st1O = new StockTick( 1,
                                                 "DROO",
                                                 100,
View Full Code Here

        // should not fire, because it must wait 10 seconds
        assertEquals( 0,
                      results.size() );

        clock.advanceTime( 5,
                           TimeUnit.SECONDS );

        EventFactHandle st2 = (EventFactHandle) wm.insert( new StockTick( 1,
                                                                          "DROO",
                                                                          80,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.