Search in sources :

Example 6 with ClassFieldAccessorStore

use of org.drools.core.base.ClassFieldAccessorStore in project drools by kiegroup.

the class LongClassFieldExtractorTest method setUp.

@Before
public void setUp() throws Exception {
    ClassFieldAccessorStore store = new ClassFieldAccessorStore();
    store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
    store.setEagerWire(true);
    extractor = store.getReader(TestBean.class, "longAttr");
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) TestBean(org.drools.core.base.TestBean) ClassFieldAccessorStore(org.drools.core.base.ClassFieldAccessorStore) Before(org.junit.Before)

Example 7 with ClassFieldAccessorStore

use of org.drools.core.base.ClassFieldAccessorStore in project drools by kiegroup.

the class IntClassFieldExtractorTest method setUp.

@Before
public void setUp() throws Exception {
    ClassFieldAccessorStore store = new ClassFieldAccessorStore();
    store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
    store.setEagerWire(true);
    this.reader = store.getReader(TestBean.class, "intAttr");
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) TestBean(org.drools.core.base.TestBean) ClassFieldAccessorStore(org.drools.core.base.ClassFieldAccessorStore) Before(org.junit.Before)

Example 8 with ClassFieldAccessorStore

use of org.drools.core.base.ClassFieldAccessorStore in project drools by kiegroup.

the class ObjectClassFieldExtractorTest method setUp.

@Before
public void setUp() throws Exception {
    ClassFieldAccessorStore store = new ClassFieldAccessorStore();
    store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
    store.setEagerWire(true);
    this.reader = store.getReader(TestBean.class, "listAttr");
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) TestBean(org.drools.core.base.TestBean) ClassFieldAccessorStore(org.drools.core.base.ClassFieldAccessorStore) Before(org.junit.Before)

Example 9 with ClassFieldAccessorStore

use of org.drools.core.base.ClassFieldAccessorStore in project drools by kiegroup.

the class ObjectClassFieldExtractorTest method testIsNullValue.

@Test
public void testIsNullValue() {
    assertFalse(this.reader.isNullValue(null, this.bean));
    ClassFieldAccessorStore store = new ClassFieldAccessorStore();
    store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
    store.setEagerWire(true);
    InternalReadAccessor nullExtractor = store.getReader(TestBean.class, "nullAttr");
    assertTrue(nullExtractor.isNullValue(null, this.bean));
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) InternalReadAccessor(org.drools.core.spi.InternalReadAccessor) ClassFieldAccessorStore(org.drools.core.base.ClassFieldAccessorStore) Test(org.junit.Test)

Example 10 with ClassFieldAccessorStore

use of org.drools.core.base.ClassFieldAccessorStore in project drools by kiegroup.

the class ClassBuilderTest method build.

private Class build(ClassBuilder builder, ClassDefinition classDef) throws Exception {
    classLoader = new PackageClassLoader(data, ProjectClassLoader.createProjectClassLoader());
    byte[] d = builder.buildClass(classDef, classLoader);
    data.write(convertClassToResourcePath(classDef.getClassName()), d);
    this.store = new ClassFieldAccessorStore();
    store.setClassFieldAccessorCache(new ClassFieldAccessorCache(classLoader));
    store.setEagerWire(true);
    Class clazz = classLoader.loadClass(classDef.getClassName());
    classDef.setDefinedClass(clazz);
    return clazz;
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) ClassFieldAccessorStore(org.drools.core.base.ClassFieldAccessorStore) PackageClassLoader(org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader)

Aggregations

ClassFieldAccessorStore (org.drools.core.base.ClassFieldAccessorStore)20 ClassFieldAccessorCache (org.drools.core.base.ClassFieldAccessorCache)17 Before (org.junit.Before)11 TestBean (org.drools.core.base.TestBean)9 ClassObjectType (org.drools.core.base.ClassObjectType)6 Pattern (org.drools.core.rule.Pattern)6 MvelConstraintTestUtil (org.drools.core.rule.MvelConstraintTestUtil)5 InternalReadAccessor (org.drools.core.spi.InternalReadAccessor)5 Declaration (org.drools.core.rule.Declaration)4 IOException (java.io.IOException)2 ObjectInput (java.io.ObjectInput)2 ObjectOutput (java.io.ObjectOutput)2 WorkingMemory (org.drools.core.WorkingMemory)2 ClassFieldAccessor (org.drools.core.base.ClassFieldAccessor)2 ClassFieldReader (org.drools.core.base.ClassFieldReader)2 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)2 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)2 ClassDefinition (org.drools.core.factmodel.ClassDefinition)2 FieldDefinition (org.drools.core.factmodel.FieldDefinition)2 PackageClassLoader (org.drools.core.rule.JavaDialectRuntimeData.PackageClassLoader)2