use of com.fasterxml.jackson.databind.ser.BeanPropertyWriter in project jackson-module-afterburner by FasterXML.
the class TestAccessorGeneration method testSingleIntAccessorGeneration.
/*
/**********************************************************************
/* Test methods
/**********************************************************************
*/
public void testSingleIntAccessorGeneration() throws Exception {
Method method = Bean1.class.getDeclaredMethod("getX");
AnnotatedMethod annMethod = new AnnotatedMethod(null, method, null, null);
PropertyAccessorCollector coll = new PropertyAccessorCollector(Bean1.class);
BeanPropertyWriter bpw = new BeanPropertyWriter(SimpleBeanPropertyDefinition.construct(null, annMethod, new PropertyName("x")), annMethod, null, null, null, null, null, false, null);
coll.addIntGetter(bpw);
BeanPropertyAccessor acc = coll.findAccessor(null);
Bean1 bean = new Bean1();
int value = acc.intGetter(bean, 0);
assertEquals(bean.getX(), value);
}
use of com.fasterxml.jackson.databind.ser.BeanPropertyWriter in project jackson-module-afterburner by FasterXML.
the class TestAccessorGeneration method testDualIntAccessorGeneration.
public void testDualIntAccessorGeneration() throws Exception {
PropertyAccessorCollector coll = new PropertyAccessorCollector(Bean3.class);
String[] methodNames = new String[] { "getX", "getY", "get3" };
for (String methodName : methodNames) {
Method method = Bean3.class.getDeclaredMethod(methodName);
AnnotatedMethod annMethod = new AnnotatedMethod(null, method, null, null);
// should we translate from method name to property name?
coll.addIntGetter(new BeanPropertyWriter(SimpleBeanPropertyDefinition.construct(null, annMethod, new PropertyName(methodName)), annMethod, null, null, null, null, null, false, null));
}
BeanPropertyAccessor acc = coll.findAccessor(null);
Bean3 bean = new Bean3();
assertEquals(bean.getX(), acc.intGetter(bean, 0));
assertEquals(bean.getY(), acc.intGetter(bean, 1));
assertEquals(bean.get3(), acc.intGetter(bean, 2));
}
Aggregations