Package org.drools.compiler

Examples of org.drools.compiler.Primitives


                      "then\n" +
                      "end\n";
         KnowledgeBase kbase = loadKnowledgeBaseFromString( str );
         StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );

         Primitives p = new Primitives();
         p.setBigDecimal( BigDecimal.valueOf( 10 ) );
         p.setBigInteger( BigInteger.valueOf( 10 ) );
         ksession.insert( p );

         int rulesFired = ksession.fireAllRules();
         assertEquals( 1,
                       rulesFired );
View Full Code Here


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

         final Primitives p1 = new Primitives();
         p1.setPrimitiveIntArray( new int[]{1, 2, 3} );
         p1.setArrayAttribute( new String[]{"a", "b"} );

         session.insert( p1 );

         session = SerializationHelper.getSerialisedStatefulKnowledgeSession( session,
                                                                              true );
View Full Code Here

                            foo );

         final PersonInterface p1 = new Person( null,
                                                "food",
                                                40 );
         final Primitives p2 = new Primitives();
         p2.setArrayAttribute( null );

         session.insert( p1 );
         session.insert( p2 );

         session = SerializationHelper.getSerialisedStatefulKnowledgeSession( session,
View Full Code Here

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

         final Primitives p = new Primitives();
         p.setStringArray( new String[]{"test1", "test3"} );
         ksession.insert( p );

         ksession.fireAllRules();

         assertEquals( 2,
View Full Code Here

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

         Primitives p1 = new Primitives();
         p1.setCharPrimitive( 'a' );
         p1.setStringAttribute( "b" );
         Primitives p2 = new Primitives();
         p2.setCharPrimitive( 'b' );
         p2.setStringAttribute( "a" );

         ksession.insert( p1 );
         ksession.insert( p2 );

         ksession.fireAllRules();
View Full Code Here

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

         Primitives p1 = new Primitives();
         ksession.insert( p1 );
         ksession.fireAllRules();
         assertEquals( 0,
                       results.size() );

         Primitives p2 = new Primitives();
         p2.setBooleanWrapper( Boolean.FALSE );
         ksession.insert( p2 );
         ksession.fireAllRules();
         assertEquals( 0,
                       results.size() );

         Primitives p3 = new Primitives();
         p3.setBooleanWrapper( Boolean.TRUE );
         ksession.insert( p3 );
         ksession.fireAllRules();
         assertEquals( 1,
                       results.size() );
View Full Code Here

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

         final Primitives fact = new Primitives();
         fact.setBooleanPrimitive( true );
         fact.setBooleanWrapper( new Boolean( true ) );
         fact.setObject( new Boolean( true ) );
         fact.setCharPrimitive( 'X' );
         final FactHandle handle = ksession.insert( fact );

         ksession.fireAllRules();

         int index = 0;
         assertEquals( list.toString(),
                       4,
                       list.size() );
         assertEquals( "boolean",
                       list.get( index++ ) );
         assertEquals( "boolean wrapper",
                       list.get( index++ ) );
         assertEquals( "boolean object",
                       list.get( index++ ) );
         assertEquals( "char",
                       list.get( index++ ) );

         fact.setBooleanPrimitive( false );
         fact.setBooleanWrapper( null );
         fact.setCharPrimitive( '\0' );
         fact.setObject( new Character( 'X' ) );
         ksession.update( handle,
                          fact );
         ksession.fireAllRules();
         assertEquals( 5,
                       list.size() );
         assertEquals( "char object",
                       list.get( index++ ) );

         fact.setObject( null );
         ksession.update( handle,
                          fact );
         ksession.fireAllRules();
         assertEquals( 6,
                       list.size() );
View Full Code Here

                      "end";

         KnowledgeBase kbase = loadKnowledgeBaseFromString( str );
         StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );

         Primitives p = new Primitives();
         p.setBooleanPrimitive( true );
         p.setBooleanWrapper( Boolean.FALSE );

         ksession.insert( p );

         int rules = ksession.fireAllRules();
         ksession.dispose();
View Full Code Here

                      "end\n";

         KnowledgeBase kbase = loadKnowledgeBaseFromString( str );
         StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );

         ksession.insert( new Primitives() );
         int rules = ksession.fireAllRules();
         assertEquals( 1,
                       rules );
     }
View Full Code Here

                      "end\n";

         KnowledgeBase kbase = loadKnowledgeBaseFromString( str );
         StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );

         Primitives primitives = new Primitives();
         primitives.setClassAttr( String.class );
         ksession.insert( primitives );
         int rules = ksession.fireAllRules();
         assertEquals( 1,
                       rules );
     }
View Full Code Here

TOP

Related Classes of org.drools.compiler.Primitives

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.