Package org.drools.core

Examples of org.drools.core.FactHandle


       
        wm = ((StatefulKnowledgeSessionImpl)kbase.newStatefulKnowledgeSession()).session;
        list = new ArrayList();
        wm.setGlobal( "list", list );
       
        FactHandle fh1 = wm.insert( new A(1) );
        FactHandle fh2 = wm.insert( new A(2) );
        FactHandle fh3 = wm.insert( new A(3) );
        FactHandle fh4 = wm.insert( new A(4) );
        wm.fireAllRules();       
        assertEquals( 4, list.get(0));       
    }      
View Full Code Here


       
        wm = ((StatefulKnowledgeSessionImpl)kbase.newStatefulKnowledgeSession()).session;
        list = new ArrayList();
        wm.setGlobal( "list", list );
       
        FactHandle fh1 = wm.insert( new B(1) );
        FactHandle fh2 = wm.insert( new B(2) );
        FactHandle fh3 = wm.insert( new B(3) );
        FactHandle fh4 = wm.insert( new B(4) );
       
        FactHandle fha = wm.insert( new A(1) );
        FactHandle fhc = wm.insert( new C(1) );
        wm.fireAllRules();       
        assertEquals( 4, list.get(0));       
    }
View Full Code Here

        final FactHandle[] cheeseHandles = new FactHandle[cheese.length];
        for ( int i = 0; i < cheese.length; i++ ) {
            cheeseHandles[i] = (FactHandle) wm.insert( cheese[i] );
        }
        final FactHandle bobHandle = (FactHandle) wm.insert( bob );

        // ---------------- 1st scenario
        int fireCount = 0;
        wm.fireAllRules();
        assertEquals( ++fireCount,
View Full Code Here

        final List list = new ArrayList();
        wm.setGlobal( "list", list );

        final Cheese stilton = new Cheese( "stilton",
                                           5 );
        final FactHandle stiltonHandle = (FactHandle) wm.insert( stilton );
        final Cheese cheddar = new Cheese( "cheddar",
                                           7 );
        final FactHandle cheddarHandle = (FactHandle) wm.insert( cheddar );
        wm.fireAllRules();

        assertEquals( 0,
                      list.size() );
View Full Code Here

        wm.setGlobal( "list",
                                 list );

        final Cheese stilton = new Cheese( "stilton",
                                           5 );
        final FactHandle stiltonHandle = (FactHandle) wm.insert( stilton );
        final Cheese cheddar = new Cheese( "cheddar",
                                           7 );
        final FactHandle cheddarHandle = (FactHandle) wm.insert( cheddar );

        final PersonInterface paul = new Person( "paul",
                                                 "stilton",
                                                 12 );
        wm.insert( paul );
View Full Code Here

        final List list = new ArrayList();
        wm.setGlobal( "list", list );

        final Cheese cheddar = new Cheese( "cheddar",
                                           7 );
        final FactHandle cheddarHandle = (FactHandle) wm.insert( cheddar );
        wm.fireAllRules();

        assertEquals( 0,
                      list.size() );

        final Cheese stilton = new Cheese( "stilton",
                                           5 );
        final FactHandle stiltonHandle = (FactHandle) wm.insert( stilton );
        wm.fireAllRules();

        assertEquals( 1,
                      list.size() );

        final Cheese brie = new Cheese( "brie",
                                        5 );
        final FactHandle brieHandle = (FactHandle) wm.insert( brie );
        wm.fireAllRules();

        assertEquals( 1,
                      list.size() );
    }
View Full Code Here

                                        "stilton" );
        workingMemory.insert( mark );

        final Cheese stilton1 = new Cheese( "stilton",
                                            6 );
        final FactHandle stilton1Handle = (FactHandle) workingMemory.insert( stilton1 );
        final Cheese stilton2 = new Cheese( "stilton",
                                            7 );
        final FactHandle stilton2Handle =  (FactHandle) workingMemory.insert( stilton2 );

        workingMemory.fireAllRules();
        assertEquals( 0,
                      list.size() );
View Full Code Here

        workingMemory.fireAllRules();
        assertEquals( ++fired,
                      list.size() );

        // only stilton, so should not fire again
        FactHandle stilton1 = (FactHandle) workingMemory.insert( new Cheese( "stilton",
                                                                10 ) );
        workingMemory.fireAllRules();
        assertEquals( fired,
                      list.size() );

        // only stilton, so should not fire again
        FactHandle stilton2 = (FactHandle) workingMemory.insert( new Cheese( "stilton",
                                                                11 ) );
        workingMemory.fireAllRules();
        assertEquals( fired,
                      list.size() );

        // still only stilton, so should not fire 
        workingMemory.retract( stilton1 );
        workingMemory.fireAllRules();
        assertEquals( fired,
                      list.size() );

        // there is a brie, so should not fire 
        FactHandle brie = (FactHandle) workingMemory.insert( new Cheese( "brie",
                                                            10 ) );
        workingMemory.fireAllRules();
        assertEquals( fired,
                      list.size() );
View Full Code Here

        final Cheesery cheesery = new Cheesery();

        cheesery.addCheese( cheddar );
        cheesery.addCheese( provolone );

        FactHandle handle = (FactHandle) workingMemory.insert( cheesery );
        workingMemory.fireAllRules();
        assertEquals( 0,
                      list.size() );

        cheesery.addCheese( new Cheese( "stilton",
View Full Code Here

        final Cheese brie = new Cheese( "brie",
                                        15 );
        final Person mark = new Person( "mark",
                                        "stilton" );

        FactHandle ch = (FactHandle) workingMemory.insert( cheddar );
        FactHandle ph = (FactHandle) workingMemory.insert( provolone );
        FactHandle bh = (FactHandle) workingMemory.insert( brie );
        FactHandle markh = (FactHandle) workingMemory.insert( mark );

        workingMemory.fireAllRules();
        assertEquals( 1,
                      list.size() );
    }
View Full Code Here

TOP

Related Classes of org.drools.core.FactHandle

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.