### Question:
ReflectionHelper { public static Field getDeclaredField(final Object bean, final String fieldName) { Class<?> clazz = bean.getClass(); try { return clazz.getDeclaredField(fieldName); } catch (SecurityException e) { throw new HibersapException("Field " + bean.getClass() + "." + fieldName + " is not accessible", e); } catch (NoSuchFieldException e) { throw new HibersapException("Field " + bean.getClass() + "." + fieldName + " does not exist in class " + clazz, e); } } private  ReflectionHelper(); static Class<?> getClassForName(final String className); static Class<?> getArrayType(final Class<?> type); static Field getDeclaredField(final Object bean, final String fieldName); static Object getFieldValue(final Object bean, final String fieldName); static Class<?> getGenericType(final Field field); static T newCollectionInstance(final Class<T> clazz); static T newInstance(final Class<T> clazz); static T newInstance(final String fullyQualifiedClassName, final Class<T> superType); static List<T> createInstances(final List<String> fullyQualifiedClassNames, final Class<T> superType); static void setFieldValue(final Object bean, final String fieldName, final Object value); static Set<Field> getDeclaredFieldsWithAnnotationRecursively(final Class<?> clazz,
                                                                        final Class<? extends Annotation> annotationClass); static T[] newArrayFromCollection(final Collection<?> collection, final Class<T> elementType);  }### Answer:
@Test public void getDeclaredFieldReturnsCorrectField() { TestBean bean = new TestBean(); Field field = ReflectionHelper.getDeclaredField(bean, "intValue"); assertThat(field.getName()).isEqualTo("intValue"); }
@Test(expected = HibersapException.class) public void getDeclaredFieldThrowsExceptionWhenFieldDoesNotExist() { ReflectionHelper.getDeclaredField(new TestBean(), "notExistent"); }