### Question:
ReflectionUtils { protected RuntimeException handleReflectionException(final Exception ex) { RuntimeException e; if (ex instanceof NoSuchMethodException) { e = new MissingMethodException("Method not found: " + ex.getMessage()); } else if (ex instanceof IllegalAccessException) { e = new IllegalStateException("Could not access method: " + ex.getMessage(), ex); } else if (ex instanceof RuntimeException) { e = (RuntimeException) ex; } else { e = new UndeclaredThrowableException(ex); } return e; }  Object invokeMethod(final Method method, final Object target, final Object... args); boolean isSetter(final Method method); boolean isGetter(final Method method); Object getFieldValue(final Object target, final Field field); @SuppressWarnings("unchecked") Object getFieldValue(final Object target, final String fieldName, final Class<?> fieldType); A getFieldAnnotation(final Field field, final Class<A> annotationClazz); A getParameterAnnotation(final Parameter parameter, final Class<A> annotationClazz, final String declaringClassName); Field getDeclaredField(final String fieldName, final Class<?> targetClass); Class<?> getDeclaredFieldType(final String fieldName, final Class<?> clazz); void setFieldValue(final Object target, final String fieldName, final Object fieldValue); void setFieldValue(final Object target, final Field field, final Object fieldValue); Method getSetterMethodForField(final Class<?> fieldClass, final String fieldName, final Class<?> fieldType); Class<?> getGenericFieldType(final Field field); MapType getMapGenericType(final Type fieldType, final String declaringClass, final String fieldName); Class<?> getArgumentTypeClass(final Object argument, final String declaringClass, final String fieldName, final boolean getNestedGenericClass); Class<?> getArrayType(final Field arrayField);  }### Answer:
@Test public void testHandleReflectionExceptionThrowsMissingMethodExceptionWhenGivenExceptionIsNoSuchMethodException() { NoSuchMethodException noSuchMethodException = new NoSuchMethodException(); RuntimeException actual = underTest.handleReflectionException(noSuchMethodException); assertThat(actual).isInstanceOf(MissingMethodException.class); }
@Test public void testHandleReflectionExceptionThrowsIllegalStateExceptionWhenGivenExceptionIsIllegalAccessException() { IllegalAccessException illegalAccessException = new IllegalAccessException(); RuntimeException actual = underTest.handleReflectionException(illegalAccessException); assertThat(actual).isInstanceOf(IllegalStateException.class); }
@Test public void testHandleReflectionExceptionThrowsRuntimeExceptionWhenGivenExceptionIsRuntimeException() { RuntimeException runtimeException = new RuntimeException(); RuntimeException actual = underTest.handleReflectionException(runtimeException); assertThat(actual).isInstanceOf(RuntimeException.class); }
@Test public void testHandleReflectionExceptionThrowsUndeclaredThrowableExceptionWhenGivenExceptionIsInvalidBeanException() { Exception genericException = new Exception(); RuntimeException actual = underTest.handleReflectionException(genericException); assertThat(actual).isInstanceOf(UndeclaredThrowableException.class); }