### Question:
ClassUtils { static Set<Method> getSetters(Class<?> targetClass, String propertyName) { String setterName = setterName(propertyName); Set<Method> setters = new HashSet<>(); while (targetClass != null) { for (Method method : targetClass.getDeclaredMethods()) { if (method.getName().equals(setterName) && method.getParameterTypes().length == 1) { logger.debug("Found setter {} in class {}", method, targetClass); setters.add(method); } } targetClass = targetClass.getSuperclass(); } return setters; } private  ClassUtils();   }### Answer:
@Test public void getMultiplePotentialSetters() { Set<Method> methods = ClassUtils.getSetters(TestBean.class, "strField"); Assert.assertEquals(methods.size(), 2); }
@Test public void getSinglePotentialSetter() { Set<Method> methods = ClassUtils.getSetters(TestBean.class, "intField"); Assert.assertEquals(methods.size(), 1); }
@Test public void getNonExistingPotentialSetters() { Set<Method> methods = ClassUtils.getSetters(TestBean.class, "someNonExisting"); Assert.assertEquals(methods.size(), 0); }
@Test public void getInheritedPotentialSetters() { Set<Method> methods = ClassUtils.getSetters(InheritedTestBean.class, "strField"); Assert.assertEquals(methods.size(), 2); }