Search in sources :

Example 6 with ClassFieldAccessorCache

use of org.drools.core.base.ClassFieldAccessorCache 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 ClassFieldAccessorCache

use of org.drools.core.base.ClassFieldAccessorCache 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 ClassFieldAccessorCache

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

the class MVELClassFieldExtractorTest method setUp.

@Before
public void setUp() throws Exception {
    store.setClassFieldAccessorCache(new ClassFieldAccessorCache(Thread.currentThread().getContextClassLoader()));
    store.setEagerWire(true);
    extractor = (MVELObjectClassFieldReader) store.getMVELReader(Person.class.getPackage().getName(), Person.class.getName(), "addresses['home'].street", true, String.class);
    MVELDialectRuntimeData data = new MVELDialectRuntimeData();
    data.addImport(Person.class.getSimpleName(), Person.class);
    data.onAdd(null, ProjectClassLoader.createProjectClassLoader());
    extractor.compile(data);
    person[0] = new Person("bob", 30);
    business[0] = new Address("Business Street", "999", null);
    home[0] = new Address("Home Street", "555", "55555555");
    person[0].getAddresses().put("business", business[0]);
    person[0].getAddresses().put("home", home[0]);
    person[1] = new Person("mark", 35);
    business[1] = new Address("Another Business Street", "999", null);
    home[1] = new Address("Another Home Street", "555", "55555555");
    person[1].getAddresses().put("business", business[1]);
    person[1].getAddresses().put("home", home[1]);
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) Address(org.drools.core.test.model.Address) Person(org.drools.core.test.model.Person) Before(org.junit.Before)

Example 9 with ClassFieldAccessorCache

use of org.drools.core.base.ClassFieldAccessorCache 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 10 with ClassFieldAccessorCache

use of org.drools.core.base.ClassFieldAccessorCache 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)

Aggregations

ClassFieldAccessorCache (org.drools.core.base.ClassFieldAccessorCache)34 Before (org.junit.Before)22 ClassFieldAccessorStore (org.drools.core.base.ClassFieldAccessorStore)17 TestBean (org.drools.core.base.TestBean)9 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)9 ClassObjectType (org.drools.core.base.ClassObjectType)7 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)6 MvelConstraintTestUtil (org.drools.core.rule.MvelConstraintTestUtil)6 Pattern (org.drools.core.rule.Pattern)6 WorkingMemory (org.drools.core.WorkingMemory)5 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)5 Consequence (org.drools.core.spi.Consequence)5 KnowledgeHelper (org.drools.core.spi.KnowledgeHelper)5 InternalReadAccessor (org.drools.core.spi.InternalReadAccessor)4 IOException (java.io.IOException)3 ObjectInput (java.io.ObjectInput)3 ObjectOutput (java.io.ObjectOutput)3 ClassFieldReader (org.drools.core.base.ClassFieldReader)3 Declaration (org.drools.core.rule.Declaration)3 JavaDialectRuntimeData (org.drools.core.rule.JavaDialectRuntimeData)3