Package org.drools.compiler

Examples of org.drools.compiler.Cheesery$Maturity


         session.setGlobal( "results",
                            list );

         Cheese cheese = new Cheese( "stilton",
                                     10 );
         Cheesery cheesery = new Cheesery();
         cheesery.addCheese( cheese );
         Person bob = new Person( "bob",
                                  "stilton" );
         Cheese cheese2 = new Cheese();
         bob.setCheese( cheese2 );
View Full Code Here


         KnowledgeBase kbase = loadKnowledgeBaseFromString( rule.toString() );
         StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );
         org.kie.api.event.rule.AgendaEventListener ael = mock( org.kie.api.event.rule.AgendaEventListener.class );
         ksession.addEventListener( ael );

         Cheesery c1 = new Cheesery();
         c1.addCheese( new Cheese( "stilton", 20 ) );
         Cheesery c2 = new Cheesery();
         c2.addCheese( new Cheese( "brie", 10 ) );
         Cheesery c3 = new Cheesery();
         c3.addCheese( new Cheese( "muzzarella", 30 ) );

         ksession.insert( c1 );
         ksession.insert( c2 );
         ksession.insert( c3 );
         ksession.fireAllRules();
View Full Code Here

                                                                                            9 ), new Cheese( "brie",
                                                                                                             4 ), new Cheese( "brie",
                                                                                                                              1 ), new Cheese( "provolone",
                                                                                                                                               8 )};

        Cheesery cheesery = new Cheesery();

        for ( int i = 0; i < cheese.length; i++ ) {
            cheesery.addCheese( cheese[i] );
        }

        FactHandle cheeseryHandle = wm.insert( cheesery );

        final Person bob = new Person( "Bob",
                                       "stilton" );

        final FactHandle bobHandle = wm.insert( bob );

        // ---------------- 1st scenario
        wm.fireAllRules();
        // one fire, as per rule constraints
        assertEquals( 1,
                      results.size() );
        assertEquals( 3,
                      ((List) results.get( results.size() - 1 )).size() );

        // ---------------- 2nd scenario
        final int index = 1;
        cheese[index].setType( "brie" );
        wm.update( cheeseryHandle,
                   cheesery );
        wm.fireAllRules();

        // no fire
        assertEquals( 1,
                      results.size() );
        System.out.println( results );

        // ---------------- 3rd scenario
        bob.setLikes( "brie" );
        wm.update( bobHandle,
                   bob );
        wm.fireAllRules();

        // 2 fires
        assertEquals( 2,
                             results.size() );
        assertEquals( 3,
                             ((List) results.get( results.size() - 1 )).size() );

        // ---------------- 4th scenario
        cheesery.getCheeses().remove( cheese[3] );
        wm.update( cheeseryHandle,
                   cheesery );
        wm.fireAllRules();

        // should not have fired as per constraint
View Full Code Here

        KnowledgeBase kbase = loadKnowledgeBaseFromString( rule.toString() );
        StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );
        org.kie.api.event.rule.AgendaEventListener ael = mock( org.kie.api.event.rule.AgendaEventListener.class );
        ksession.addEventListener( ael );

        Cheesery c1 = new Cheesery();
        c1.addCheese( new Cheese( "stilton", 20 ) );
        Cheesery c2 = new Cheesery();
        c2.addCheese( new Cheese( "brie", 10 ) );
        Cheesery c3 = new Cheesery();
        c3.addCheese( new Cheese( "muzzarella", 30 ) );

        ksession.insert( c1 );
        ksession.insert( c2 );
        ksession.insert( c3 );
        ksession.fireAllRules();
View Full Code Here

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

        final Cheesery cheesery1 = new Cheesery();
        cheesery1.setStatus(Cheesery.SELLING_CHEESE);
        cheesery1.setMaturity(Maturity.OLD);
        session.insert(cheesery1);
        session = SerializationHelper.getSerialisedStatefulKnowledgeSession(session,
                                                                            true);

        final Cheesery cheesery2 = new Cheesery();
        cheesery2.setStatus(Cheesery.MAKING_CHEESE);
        cheesery2.setMaturity(Maturity.YOUNG);
        session.insert(cheesery2);
        session = SerializationHelper.getSerialisedStatefulKnowledgeSession(session,
                                                                            true);

        session.fireAllRules();
View Full Code Here

        Cheese brie = new Cheese( "brie",
                                  2 );
        Cheese stilton = new Cheese( "stilton",
                                     2 );
        Cheesery cheesery = new Cheesery();
        cheesery.addCheese( brie );
        cheesery.addCheese( stilton );

        ksession.insert( cheesery );
        ksession.fireAllRules();

        assertEquals( 1,
View Full Code Here

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

        final Cheesery cheesery = new Cheesery();
        final Cheese stilton = new Cheese( "stilton",
                                           12 );
        final Cheese cheddar = new Cheese( "cheddar",
                                           15 );
        cheesery.addCheese( stilton );
        cheesery.addCheese( cheddar );
        ksession.setGlobal( "cheesery",
                            cheesery );
        ksession.insert( cheesery );

        Person p = new Person( "stilton" );
View Full Code Here

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

        Cheesery cheesery = new Cheesery();
        cheesery.addCheese( new Cheese( "stilton",
                                        22 ) );

        session.insert( cheesery );

        // TODO java.io.EOFException
View Full Code Here

        ksession.insert( stilton );
        final Cheese brie = new Cheese( "brie",
                                        10 );
        ksession.insert( brie );

        final Cheesery cheesery = new Cheesery();
        cheesery.getCheeses().add( stilton );
        ksession.insert( cheesery );

        ksession.fireAllRules();

        assertEquals( 2,
View Full Code Here

        final Cheese brie = new Cheese( "brie",
                                        15 );
        ksession.insert( stilton );
        ksession.insert( muzzarela );

        final Cheesery cheesery = new Cheesery();
        cheesery.getCheeses().add( stilton.getType() );
        cheesery.getCheeses().add( brie.getType() );
        ksession.insert( cheesery );

        ksession.fireAllRules();

        assertEquals( 2,
View Full Code Here

TOP

Related Classes of org.drools.compiler.Cheesery$Maturity

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.