Package org.drools.spi

Examples of org.drools.spi.FieldExtractor


                                                                       null,
                                                                       null );

        final MockObjectSource source = new MockObjectSource( buildContext.getNextId() );

        final FieldExtractor extractor = cache.getExtractor( Cheese.class,
                                                             "type",
                                                             getClass().getClassLoader() );

        final FieldValue field = FieldFactory.getFieldValue( "cheddar" );
View Full Code Here


     */
    public void testPredicateConstraint() throws IntrospectionException {
        final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newStatefulSession();

        final FieldExtractor priceExtractor = cache.getExtractor( Cheese.class,
                                                                  "price",
                                                                  getClass().getClassLoader() );

        Pattern pattern = new Pattern( 0,
                                       new ClassObjectType( Cheese.class ) );
View Full Code Here

     */
    public void testReturnValueConstraint() throws IntrospectionException {
        final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newStatefulSession();

        final FieldExtractor priceExtractor = cache.getExtractor( Cheese.class,
                                                                  "price",
                                                                  getClass().getClassLoader() );

        final Pattern pattern = new Pattern( 0,
                                             new ClassObjectType( Cheese.class ) );
View Full Code Here

    }

    public void testPropagationWithNullValue() {

        final CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
        FieldExtractor extractor = ClassFieldExtractorCache.getInstance().getExtractor( Cheese.class,
                                                                                        "type",
                                                                                        this.getClass().getClassLoader() );
        final LiteralConstraint lit1 = new LiteralConstraint( extractor,
                                                              StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
                                                              new ObjectFieldImpl( "stilton" ) );
View Full Code Here

import org.drools.util.asm.TestInterfaceImpl;

public class BaseClassFieldExtractorFactoryTest extends TestCase {

    public void testIt() throws Exception {
        FieldExtractor ex = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
                                                                               "name",
                                                                               Thread.currentThread().getContextClassLoader() );
        assertEquals( 0,
                      ex.getIndex() );
        assertEquals( "michael",
                      ex.getValue( null, new TestBean() ) );
        ex = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
                                                                "age",
                                                                Thread.currentThread().getContextClassLoader() );
        assertEquals( 1,
                      ex.getIndex() );
        assertEquals( 42,
                      ((Number) ex.getValue( null, new TestBean() )).intValue() );

    }
View Full Code Here

                      ((Number) ex.getValue( null, new TestBean() )).intValue() );

    }

    public void testInterface() throws Exception {
        final FieldExtractor ex = ClassFieldExtractorCache.getExtractor( TestInterface.class,
                                                                         "something",
                                                                         getClass().getClassLoader() );
        assertEquals( 0,
                      ex.getIndex() );
        assertEquals( "foo",
                      ex.getValue( null, new TestInterfaceImpl() ) );
    }
View Full Code Here

        assertEquals( "foo",
                      ex.getValue( null, new TestInterfaceImpl() ) );
    }

    public void testAbstract() throws Exception {
        final FieldExtractor ex = ClassFieldExtractorCache.getExtractor( TestAbstract.class,
                                                                         "something",
                                                                         getClass().getClassLoader() );
        assertEquals( 0,
                      ex.getIndex() );
        assertEquals( "foo",
                      ex.getValue( null, new TestAbstractImpl() ) );
    }
View Full Code Here

        assertEquals( "foo",
                      ex.getValue( null, new TestAbstractImpl() ) );
    }

    public void testInherited() throws Exception {
        final FieldExtractor ex = ClassFieldExtractorCache.getExtractor( BeanInherit.class,
                                                                         "text",
                                                                         getClass().getClassLoader() );
        assertEquals( "hola",
                      ex.getValue( null, new BeanInherit() ) );
    }
View Full Code Here

        assertEquals( "hola",
                      ex.getValue( null, new BeanInherit() ) );
    }

    public void testSelfReference() throws Exception {
        final FieldExtractor ex = ClassFieldExtractorCache.getExtractor( BeanInherit.class,
                                                                         "this",
                                                                         getClass().getClassLoader() );
        final TestBean bean = new TestBean();
        assertEquals( bean,
                      ex.getValue( null, bean ) );
    }
View Full Code Here

    protected BetaNodeFieldConstraint getConstraint(String identifier,
                                                  Operator operator,
                                                  String fieldName,
                                                  Class clazz) {
        FieldExtractor extractor = ClassFieldExtractorCache.getExtractor( clazz,
                                                                          fieldName,
                                                                          getClass().getClassLoader() );
        Declaration declaration = new Declaration( identifier,
                                                   extractor,
                                                   new Pattern( 0,
View Full Code Here

TOP

Related Classes of org.drools.spi.FieldExtractor

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.