AttributeDescriptor { Method getReadMethod(Class targetType) { Method m; String beanMethod = "get" + _name.substring(0, 1).toUpperCase() + _name.substring(1); m = getReadMethod(targetType, beanMethod); if (m != null) return m; return getReadMethod(targetType, _name); } AttributeDescriptor(TypeRegistry pdxRegistry, String name); boolean validateReadType(Class targetType); Object read(Object target, ExecutionContext executionContext);  }
@Test @Parameters({PUBLIC_ACCESSOR_BY_GETTER, PRIVATE_ACCESSOR_BY_GETTER}) public void getReadMethodShouldReturnRequestedMethodForAttributesWithGetters(String attributeName) throws NoSuchMethodException { AttributeDescriptor attributeDescriptor = new AttributeDescriptor(typeRegistry, attributeName); String getterName = "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1); assertThat(attributeDescriptor.getReadMethod(TestBean.class)) .isEqualTo(TestBean.class.getMethod(getterName)); }
@Test @Parameters({PUBLIC_ACCESSOR_BY_NAME, PRIVATE_ACCESSOR_BY_NAME}) public void getReadMethodShouldReturnRequestedMethodForAttributesWithAccessors( String attributeName) throws NoSuchMethodException { AttributeDescriptor attributeDescriptor = new AttributeDescriptor(typeRegistry, attributeName); assertThat(attributeDescriptor.getReadMethod(TestBean.class, attributeName)) .isEqualTo(TestBean.class.getMethod(attributeName)); }
@Test public void getReadMethodShouldReturnNullAndUpdateCachedClassToMethodsMapWhenMethodCanNotBeFound() { DefaultQuery.getPdxClasstoMethodsmap().clear(); AttributeDescriptor attributeDescriptor = new AttributeDescriptor(typeRegistry, "nonExistingAttribute"); assertThat(attributeDescriptor.getReadMethod(TestBean.class)).isNull(); assertThat(DefaultQuery.getPdxClasstoMethodsmap().isEmpty()).isFalse(); assertThat(DefaultQuery.getPdxClasstoMethodsmap() .containsKey(TestBean.class.getCanonicalName())).isTrue(); assertThat(DefaultQuery.getPdxClasstoMethodsmap().get(TestBean.class.getCanonicalName()) .contains("nonExistingAttribute")).isTrue(); }