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));
}
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());
}
Aggregations