### Question:
ReflectionUtils { public static Method getSetter(Object target, String property, Class<?> parameterType) { String setterMethodName = SETTER_PREFIX + property.substring(0, 1).toUpperCase() + property.substring(1); return getMethod(target, setterMethodName, parameterType); } private  ReflectionUtils(); static Class<T> getClass(String className); static Class<T> getClassOrNull(String className); static T getFieldValue(Object target, String fieldName); static void setFieldValue(Object target, String fieldName, Object value); static Method getMethod(Object target, String methodName, Class... parameterTypes); static boolean hasMethod(Class<?> targetClass, String methodName, Class... parameterTypes); static Method getGetter(Object target, String property); static Method getSetter(Object target, String property, Class<?> parameterType); static T invoke(Object target, Method method, Object... parameters); static T invokeGetter(Object target, String property); static void invokeSetter(Object target, String property, Object parameter); static final String GETTER_PREFIX; static final String SETTER_PREFIX; }### Answer:
@Test public void testGetSetter() { TestObject testObject = new TestObject(); try { ReflectionUtils.getSetter(testObject, "name", String.class); fail("There is no setName in TestObject"); } catch (ReflectionException expected) { assertEquals(NoSuchMethodException.class, expected.getCause().getClass()); } assertNotNull(ReflectionUtils.getSetter(testObject, "version", Integer.class)); try { ReflectionUtils.invoke(testObject, ReflectionUtils.getMethod(testObject, "setFails")); fail("Should have failed!"); } catch (ReflectionException e) { assertEquals(InvocationTargetException.class, e.getCause().getClass()); assertEquals(IllegalArgumentException.class, e.getCause().getCause().getClass()); } }