Search in sources :

Example 1 with TestBean

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

the class BaseClassFieldAccessorFactoryTest method testSelfReference.

@Test
public void testSelfReference() throws Exception {
    final InternalReadAccessor ex = store.getReader(BeanInherit.class, "this");
    final TestBean bean = new TestBean();
    assertEquals(bean, ex.getValue(null, bean));
}
Also used : TestBean(org.drools.core.base.TestBean) InternalReadAccessor(org.drools.core.spi.InternalReadAccessor) Test(org.junit.Test)

Example 2 with TestBean

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

the class BaseClassFieldAccessorFactoryTest method testIt.

@Test
public void testIt() throws Exception {
    ClassFieldAccessorFactory factory = new ClassFieldAccessorFactory();
    ClassFieldAccessorCache.CacheEntry cachEntry = new ClassFieldAccessorCache.CacheEntry(Thread.currentThread().getContextClassLoader());
    InternalReadAccessor ex = factory.getClassFieldReader(TestBean.class, "name", cachEntry);
    assertEquals("michael", ex.getValue(null, new TestBean()));
    ex = factory.getClassFieldReader(TestBean.class, "age", cachEntry);
    assertEquals(42, ((Number) ex.getValue(null, new TestBean())).intValue());
}
Also used : ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) TestBean(org.drools.core.base.TestBean) InternalReadAccessor(org.drools.core.spi.InternalReadAccessor) Test(org.junit.Test)

Aggregations

TestBean (org.drools.core.base.TestBean)2 InternalReadAccessor (org.drools.core.spi.InternalReadAccessor)2 Test (org.junit.Test)2 ClassFieldAccessorCache (org.drools.core.base.ClassFieldAccessorCache)1