Package org.drools.compiler

Examples of org.drools.compiler.Cheese


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

         final Cheese brie = new Cheese( "brie",
                                         12 );
         try {
             ksession.insert( brie );
             ksession.fireAllRules();
             fail( "Should throw an Exception from the ReturnValue" );
View Full Code Here


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

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

         ksession.fireAllRules();
View Full Code Here

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

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

         final Cheesery cheesery = new Cheesery();
         cheesery.getCheeses().add( stilton );
View Full Code Here

         ksession.fireAllRules();

         assertEquals( 0,
                       list.size() );
         Cheese brie = new Cheese( "brie" );
         ksession.insert( brie );

         ksession.fireAllRules();

         assertEquals( 2,
View Full Code Here

                             nonmatchlist );

         ksession.setGlobal( "cheeseType",
                             "stilton" );

         final Cheese stilton1 = new Cheese( "stilton",
                                             5 );
         final Cheese stilton2 = new Cheese( "stilton",
                                             7 );
         final Cheese brie = new Cheese( "brie",
                                         4 );
         ksession.insert( stilton1 );
         ksession.insert( stilton2 );
         ksession.insert( brie );
View Full Code Here

         ksession.fireAllRules();

         assertEquals( 0,
                       list.size() );

         ksession.insert( new Cheese( bob.getLikes(),
                                      10 ) );
         ksession.fireAllRules();

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

     @Test
     public void testUnbalancedTrees() throws Exception {
         KnowledgeBase kbase = SerializationHelper.serializeObject( loadKnowledgeBase( "test_UnbalancedTrees.drl" ) );
         StatefulKnowledgeSession wm = createKnowledgeSession( kbase );

         wm.insert( new Cheese( "a",
                                10 ) );
         wm.insert( new Cheese( "b",
                                10 ) );
         wm.insert( new Cheese( "c",
                                10 ) );
         wm.insert( new Cheese( "d",
                                10 ) );
         final Cheese e = new Cheese( "e",
                                      10 );
         wm.insert( e );

         wm.fireAllRules();

         assertEquals( "Rule should have fired twice, seting the price to 30",
                       30,
                       e.getPrice() );
         // success
     }
View Full Code Here

         final List result = new ArrayList();
         ksession.setGlobal( "results",
                             result );

         final Person person = new Person( "bob" );
         final Cheese cheese = new Cheese( "brie",
                                           10 );

         ksession.insert( person );
         ksession.insert( cheese );
View Full Code Here

         final Map result = new HashMap();
         ksession.setGlobal( "results",
                             result );

         final Cheese stilton = new Cheese( "stilton",
                                            20 );
         final Cheese brie = new Cheese( "brie",
                                         10 );

         ksession.insert( stilton );
         ksession.insert( brie );

         ksession.fireAllRules();
         assertEquals( 5,
                       result.size() );
         assertEquals( stilton.getPrice(),
                       ((Integer) result.get( stilton.getType() )).intValue() );
         assertEquals( brie.getPrice(),
                       ((Integer) result.get( brie.getType() )).intValue() );

         assertEquals( stilton.getPrice(),
                       ((Integer) result.get( stilton )).intValue() );
         assertEquals( brie.getPrice(),
                       ((Integer) result.get( brie )).intValue() );

         assertEquals( stilton.getPrice(),
                       ((Integer) result.get( "test3" + stilton.getType() )).intValue() );

         ksession.insert( new Person( "bob",
                                      brie.getType() ) );
         ksession.fireAllRules();

         assertEquals( 6,
                       result.size() );
         assertEquals( brie.getPrice(),
                       ((Integer) result.get( "test3" + brie.getType() )).intValue() );
     }
View Full Code Here

         StatefulKnowledgeSession wm = createKnowledgeSession( kbase );

         RuleRuntimeEventListener wmel = mock( RuleRuntimeEventListener.class );
         wm.addEventListener( wmel );

         final Cheese stilton = new Cheese( "stilton",
                                            15 );

         final FactHandle stiltonHandle = wm.insert( stilton );

         ArgumentCaptor<org.kie.api.event.rule.ObjectInsertedEvent> oic = ArgumentCaptor.forClass( org.kie.api.event.rule.ObjectInsertedEvent.class );
View Full Code Here

TOP

Related Classes of org.drools.compiler.Cheese

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.