Search in sources :

Example 1 with TestBean

use of org.drools.core.util.asm.TestBean in project drools by kiegroup.

the class ClassFieldAccessorTest method testBasic.

@Test
public void testBasic() throws Exception {
    final Object[] objArray = new Object[1];
    final TestBean obj = new TestBean();
    obj.setBlah(false);
    obj.setSomething("no");
    obj.setObjArray(objArray);
    final ClassFieldReader ext = store.getReader(TestBean.class, "blah");
    assertEquals(false, ((Boolean) ext.getValue(null, obj)).booleanValue());
    final ClassFieldReader ext2 = store.getReader(TestBean.class, "fooBar");
    assertEquals("fooBar", ext2.getValue(null, obj));
    final ClassFieldReader ext3 = store.getReader(TestBean.class, "objArray");
    assertEquals(objArray, ext3.getValue(null, obj));
}
Also used : TestBean(org.drools.core.util.asm.TestBean) Test(org.junit.Test)

Example 2 with TestBean

use of org.drools.core.util.asm.TestBean in project drools by kiegroup.

the class ClassFieldAccessorTest method testLong.

@Test
public void testLong() throws Exception {
    final ClassFieldReader ext = store.getReader(TestBean.class, "longField");
    final TestBean bean = new TestBean();
    assertEquals(424242, ((Number) ext.getValue(null, bean)).longValue());
}
Also used : TestBean(org.drools.core.util.asm.TestBean) Test(org.junit.Test)

Example 3 with TestBean

use of org.drools.core.util.asm.TestBean in project drools by kiegroup.

the class ClassFieldAccessorTest method testNonExistentField.

@Test
public void testNonExistentField() throws Exception {
    final Object[] objArray = new Object[1];
    final TestBean obj = new TestBean();
    obj.setBlah(false);
    obj.setSomething("no");
    obj.setObjArray(objArray);
    ClassFieldReader ext = store.getReader(TestBean.class, "xyz");
    assertNull(ext);
}
Also used : TestBean(org.drools.core.util.asm.TestBean) ClassFieldReader(org.drools.mvel.accessors.ClassFieldReader) Test(org.junit.Test)

Example 4 with TestBean

use of org.drools.core.util.asm.TestBean in project drools by kiegroup.

the class ClassFieldAccessorTest method testBasic.

@Test
public void testBasic() throws Exception {
    final Object[] objArray = new Object[1];
    final TestBean obj = new TestBean();
    obj.setBlah(false);
    obj.setSomething("no");
    obj.setObjArray(objArray);
    final ClassFieldReader ext = store.getReader(TestBean.class, "blah");
    assertEquals(false, ((Boolean) ext.getValue(null, obj)).booleanValue());
    final ClassFieldReader ext2 = store.getReader(TestBean.class, "fooBar");
    assertEquals("fooBar", ext2.getValue(null, obj));
    final ClassFieldReader ext3 = store.getReader(TestBean.class, "objArray");
    assertEquals(objArray, ext3.getValue(null, obj));
}
Also used : TestBean(org.drools.core.util.asm.TestBean) ClassFieldReader(org.drools.mvel.accessors.ClassFieldReader) Test(org.junit.Test)

Example 5 with TestBean

use of org.drools.core.util.asm.TestBean in project drools by kiegroup.

the class ClassFieldAccessorTest method testLong.

@Test
public void testLong() throws Exception {
    final ClassFieldReader ext = store.getReader(TestBean.class, "longField");
    final TestBean bean = new TestBean();
    assertEquals(424242, ((Number) ext.getValue(null, bean)).longValue());
}
Also used : ClassFieldReader(org.drools.mvel.accessors.ClassFieldReader) TestBean(org.drools.core.util.asm.TestBean) Test(org.junit.Test)

Aggregations

TestBean (org.drools.core.util.asm.TestBean)6 Test (org.junit.Test)6 ClassFieldReader (org.drools.mvel.accessors.ClassFieldReader)3