Package org.drools.spi

Examples of org.drools.spi.ObjectType


    protected PyDictionary setUpDictionary(Tuple tuple,
                                           Iterator declIter) throws Exception
    {
        Declaration eachDecl;

        ObjectType objectType;
        String type;
        Class clazz;
        int nestedClassPosition;
        int dotPosition;
View Full Code Here


        final RuleSet ruleSet = new RuleSet( "test RuleSet",
                                             this.ruleBaseContext );
        final Rule rule = new Rule( "Test Rule 1",
                                    ruleSet );
        rule.setImporter( new DefaultImporter( ) );
        ObjectType cheeseType = objectTypeFactory.newObjectType( rule,
                                                                 this.ruleBaseContext,
                                                                 cheeseConfiguration );

        tuple = new MockTuple( );
        rule.setImporter( new DefaultImporter( ) );
        tuple.setRule( rule );
        tuple.setWorkingMemory( new MockWorkingMemory( ) );

        // simple condition checks
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 0
        assertFalse( testCondition( testNumber++,
                                    tuple,
                                    rule ) ); // 1
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 2
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 3
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 4

        Declaration camembertDecl = rule.addParameterDeclaration( "camembert",
                                                                  cheeseType );
        Declaration stiltonDecl = rule.addParameterDeclaration( "stilton",
                                                                cheeseType );
        rule.setImporter( this.importer );
        // condition check with a single declaration
        tuple.put( camembertDecl,
                   new Cheese( "camembert" ) );
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 5
        assertFalse( testCondition( testNumber++,
                                    tuple,
                                    rule ) ); // 6

        // condition check with a single declaration
        tuple = new MockTuple( );
        rule.setImporter( this.importer );
        tuple.setRule( rule );
        tuple.setWorkingMemory( new MockWorkingMemory( ) );
        tuple.put( stiltonDecl,
                   new Cheese( "stilton" ) );
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 7
        assertFalse( testCondition( testNumber++,
                                    tuple,
                                    rule ) ); // 8

        // condition check with two declarations
        tuple = new MockTuple( );
        rule.setImporter( this.importer );
        tuple.setRule( rule );
        tuple.setWorkingMemory( new MockWorkingMemory( ) );
        tuple.put( stiltonDecl,
                   new Cheese( "stilton" ) );
        tuple.put( camembertDecl,
                   new Cheese( "camembert" ) );
        assertFalse( testCondition( testNumber++,
                                    tuple,
                                    rule ) ); // 9
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 10
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 11
        assertFalse( testCondition( testNumber++,
                                    tuple,
                                    rule ) ); // 12

        // condition check with 2 declarations and application data
        WorkingMemory workingMemory = new MockWorkingMemory( );
        workingMemory.setApplicationData( "bites",
                                          new Integer( 3 ) );
        workingMemory.setApplicationData( "favouriteCheese",
                                          new Cheese( "camembert" ) );
        tuple.setWorkingMemory( workingMemory );

        HashMap applicationData = new HashMap( );
        applicationData.put( "bites",
                             Integer.class );
        applicationData.put( "favouriteCheese",
                             Cheese.class );

        rule.setApplicationData( applicationData );

        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 13
        assertFalse( testCondition( testNumber++,
                                    tuple,
                                    rule ) ); // 14
        assertTrue( testCondition( testNumber++,
                                   tuple,
                                   rule ) ); // 15

        // test code works no matter what the order of decl are
        tuple = new MockTuple( );
        rule.setImporter( this.importer );
        rule.setApplicationData( new HashMap( ) );
        tuple.setRule( rule );
        workingMemory = new MockWorkingMemory( );
        tuple.setWorkingMemory( workingMemory );

        DefaultConfiguration stringConfiguration = new DefaultConfiguration( "test2" );
        stringConfiguration.setText( String.class.getName( ) );
        ObjectType stringType = objectTypeFactory.newObjectType( rule,
                                                                 this.ruleBaseContext,
                                                                 stringConfiguration );
        Declaration favouriteCheeseDecl = rule.addParameterDeclaration( "favouriteCheese",
                                                                        stringType );
View Full Code Here

                                             this.ruleBaseContext );
        Rule rule = new Rule( "Test Rule 1",
                              ruleSet );

        rule.setImporter( new DefaultImporter( ) );
        ObjectType cheeseType = objectTypeFactory.newObjectType( rule,
                                                                 this.ruleBaseContext,
                                                                 cheeseConfiguration );

        tuple = new MockTuple( );
        rule.setImporter( this.importer );
View Full Code Here

            Rule rule = (Rule) this.ruleSetReader.getParent( Rule.class );
            Declaration declaration = (Declaration) this.ruleSetReader.getParent( Declaration.class );
            ((DefaultConfiguration) config).setAttribute( "identifier",
                                                          declaration.getIdentifier( ) );
     
            ObjectType objectType = factory.newObjectType( rule,
                                                           this.ruleSetReader.getFactoryContext( ),
                                                           config );

            declaration.setObjectType( objectType );
        }
View Full Code Here

    private Parameter[] getParameters(Declaration[] declarations,
                                      Set imports)
    {
        List list = new ArrayList();

        ObjectType objectType;
        Class clazz;
        String identifier;
        Declaration declaration;

        String type;
View Full Code Here

     * The simples test that should work.
     */
    public void testPutGetMatch()
    {
        AgendaItemMap map = new AgendaItemMap( );
        ObjectType objType = getMockObjectType( );

        Declaration dec = new Declaration( "somthing",
                                           objType,
                                           1 );
        TupleKey key = new TupleKey( dec,
View Full Code Here

    }

    public void testMoreComplex()
    {
        AgendaItemMap map = new AgendaItemMap( );
        ObjectType objType = getMockObjectType( );

        Declaration dec = new Declaration( "somthing",
                                           objType,
                                           1 );
        TupleKey key = new TupleKey( dec,
View Full Code Here

    }

    public void testRemoveAll()
    {
        AgendaItemMap map = new AgendaItemMap( );
        ObjectType objType = getMockObjectType( );

        Declaration dec = new Declaration( "somthing",
                                           objType,
                                           1 );
        TupleKey key = new TupleKey( dec,
View Full Code Here

    public void testIsEmpty()
    {
        AgendaItemMap map = new AgendaItemMap( );
        assertTrue( map.isEmpty( ) );
        ObjectType objType = getMockObjectType( );

        Declaration dec = new Declaration( "somthing",
                                           objType,
                                           1 );
        TupleKey key = new TupleKey( dec,
View Full Code Here

        return del;
    }

    private ObjectType getMockObjectType()
    {
        return new ObjectType( ) {

            public boolean matches(Object object)
            {
                return false;
            }
View Full Code Here

TOP

Related Classes of org.drools.spi.ObjectType

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.