AttributeDescriptor { @SuppressWarnings("unchecked") Member getReadMember(Class targetClass) throws NameNotFoundException { List key = new ArrayList(); key.add(targetClass); key.add(_name); Member m = JavaWorkarounds.computeIfAbsent(_localCache, key, k -> { Member member = getReadField(targetClass); return member == null ? getReadMethod(targetClass) : member; }); if (m == null) { throw new NameNotFoundException(String.format( "No public attribute named ' %s ' was found in class %s", _name, targetClass.getName())); } ((AccessibleObject) m).setAccessible(true); return m; } AttributeDescriptor(TypeRegistry pdxRegistry, String name); boolean validateReadType(Class targetType); Object read(Object target, ExecutionContext executionContext);  }
@Test public void getReadMemberShouldThrowExceptionWhenMethodCanNotBeFound() { AttributeDescriptor attributeDescriptor = new AttributeDescriptor(typeRegistry, "nonExistingAttribute"); assertThatThrownBy(() -> attributeDescriptor.getReadMember(TestBean.class)) .isInstanceOf(NameNotFoundException.class) .hasMessageContaining( "No public attribute named ' nonExistingAttribute ' was found in class " + TestBean.class.getName()); }