Package org.drools

Examples of org.drools.TestWorkingMemoryEventListener


        // Dumper dumper = new Dumper( ruleBase );
        // dumper.dumpReteToDot( System.err );

        workingMemory = getWorkingMemory( ruleBase );
        workingMemory.addEventListener( new TestWorkingMemoryEventListener( ) );

        workingMemory.setApplicationData( "fibtotal",
                                          new FibTotal( ) );

        // Assert the facts, and fire the rules.
        Fibonacci fibonacci = new Fibonacci( 50 );
        workingMemory.assertObject( fibonacci );

        // test serialization
        workingMemory = serializeWorkingMemory( workingMemory );
        workingMemory = serializeWorkingMemory( workingMemory );

        workingMemory.fireAllRules( );

        // test serialization
        workingMemory = serializeWorkingMemory( workingMemory );
        workingMemory = serializeWorkingMemory( workingMemory );

        // test context after serlisation
        assertNull( workingMemory.getRuleBase( ).getRuleBaseContext( ).get( "java-classLoader" ) );

        // test application ran correctly
        assertEquals( 2,
                      workingMemory.getObjects( ).size( ) );
        Fibonacci a = (Fibonacci) workingMemory.getObjects( ).get( 0 );
        Fibonacci b = (Fibonacci) workingMemory.getObjects( ).get( 1 );
        assertEquals( 50,
                      a.getSequence( ) );
        assertEquals( 49,
                      b.getSequence( ) );

        assertEquals( 12586269025L,
                      a.getValue( ) );
        assertEquals( 7778742049L,
                      b.getValue( ) );

        // test application data
        FibTotal total = (FibTotal) workingMemory.getApplicationData( "fibtotal" );
        assertEquals( 50,
                      total.getTotal( ) );

        // test listener
        TestWorkingMemoryEventListener listener = (TestWorkingMemoryEventListener) workingMemory.getEventListeners( ).get( 0 );
        assertEquals( 50,
                      listener.asserted );
        assertEquals( 48,
                      listener.retracted );
        assertEquals( 50,
View Full Code Here


        Builder builder = new Builder( );
        builder.addRuleSet( ruleSet );
        RuleBase ruleBase = builder.buildRuleBase( );

        WorkingMemoryImpl workingMemory = (WorkingMemoryImpl) ruleBase.newWorkingMemory( );
        TestWorkingMemoryEventListener listener = new TestWorkingMemoryEventListener( );
        workingMemory.addEventListener( listener );

        /*
         * This is not recursive so a rule should not be able to activate itself
         */
 
View Full Code Here

        // ==================
        RuleBaseBuilder builder = new RuleBaseBuilder( );
        builder.addRuleSet( ruleSet );
        RuleBase ruleBase = builder.build( );
        workingMemory = getWorkingMemory( ruleBase );
        workingMemory.addEventListener( new TestWorkingMemoryEventListener( ) );
    }
View Full Code Here

                                            outList );

        assertEquals( numGuests,
                      actualGuests );

        TestWorkingMemoryEventListener listener = (TestWorkingMemoryEventListener) workingMemory.getEventListeners( ).get( 0 );
        assertEquals( 50,
                      listener.asserted );
        assertEquals( 0,
                      listener.retracted );
        assertEquals( 17,
View Full Code Here

TOP

Related Classes of org.drools.TestWorkingMemoryEventListener

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.