### Question:
ReflectionHelper { public static <T> T getValueInFieldOfType(Object on, Class<T> fieldType) { Field field = getOnlyFieldDefOfType(on.getClass(), fieldType); try { field.setAccessible(true); @SuppressWarnings("unchecked") T fieldValue = (T) field.get(on); return fieldValue; } catch (IllegalAccessException e) { throw new AssertionError(e); } } private  ReflectionHelper(); static void setValueInFieldOfType(Object on, Class<? super T> fieldType, T newValue); static T getValueInFieldOfType(Object on, Class<T> fieldType);  }### Answer:
@Test public void testGet() { Monkey monkey = new Monkey(); String name = ReflectionHelper.getValueInFieldOfType(monkey, String.class); assertEquals(monkey.name, name); }
@Test public void testGetInParent() { Monkey monkey = new Monkey(); List<?> friends = ReflectionHelper.getValueInFieldOfType(monkey, List.class); assertEquals(monkey.friends, friends); }
@Test(expected = NoSuchFieldError.class) public void testAmbiguousGet() { Dog dog = new Dog(); ReflectionHelper.getValueInFieldOfType(dog, String.class); }
@Test public void testActuallyNotAmbiguousGet() { Monkey monkey = new Monkey(); boolean isClimbing = ReflectionHelper.getValueInFieldOfType(monkey, boolean.class); assertEquals(monkey.isClimbing, isClimbing); }