### Question:
Reflect { @SuppressWarnings("unchecked") public boolean isSuperClass(Class subClass) { return parametrizedClass.isAssignableFrom(subClass); } Reflect(Class parametrizedClass); static boolean isCollection(Class<?> fieldClass); static boolean isCollection(Object object); static List<Field> getAllFields(Class<?> fieldClass); static boolean isAnnotationPresent(Class<?> fieldClass, String fieldName, Class<? extends Annotation> annotation); @SuppressWarnings("unchecked") boolean isSuperClass(Class subClass); boolean isSuperClass(Type t); boolean isSuperClass(Object object); @SuppressWarnings("unchecked") boolean isCollectionField(Field field); List<Field> getInheritedFields(Class<?> subClass); boolean hasField(Field field);  }### Answer:
@Test public void isSuperClass_shouldReturnFalseIfGivenSubClassIsNotAccessibleFromGivenParameterizedClass() { Reflect reflect = new Reflect(OpenmrsObject.class); Assert.assertFalse(reflect.isSuperClass(new NormalClass())); }
@Test public void isSuperClass_shouldReturnTrueIfGivenSubClassIsAccessibleFromGivenParameterizedClass() { Reflect reflect = new Reflect(OpenmrsObject.class); Assert.assertTrue(reflect.isSuperClass(OpenmrsObjectImp.class)); }
@Test public void isSuperClass_shouldReturnFalseIfGivenObjectIsNotAccessibleFromGivenParameterizedClass() { Reflect reflect = new Reflect(OpenmrsObject.class); Assert.assertFalse(reflect.isSuperClass(NormalClass.class)); }
@Test public void isSuperClass_shouldReturnTrueIfGivenObjectIsAccessibleFromGivenParameterizedClass() { Reflect reflect = new Reflect(OpenmrsObject.class); Assert.assertTrue(reflect.isSuperClass(new OpenmrsObjectImp())); }
@Test public void isSuperClass_shouldReturnTrueForAGenericWhoseBoundIsASubclass() { Reflect reflect = new Reflect(OpenmrsObject.class); Field field = ReflectionUtils.findField(Visit.class, "attributes"); ParameterizedType setOfAttr = (ParameterizedType) field.getGenericType(); Type genericType = setOfAttr.getActualTypeArguments()[0]; Assert.assertTrue(reflect.isSuperClass(genericType)); }
@Test public void isSuperClass_shouldReturnFalseForAGenericWhoseBoundIsNotASubclass() { Reflect reflect = new Reflect(Number.class); Field field = ReflectionUtils.findField(Visit.class, "attributes"); ParameterizedType setOfAttr = (ParameterizedType) field.getGenericType(); Type genericType = setOfAttr.getActualTypeArguments()[0]; Assert.assertFalse(reflect.isSuperClass(genericType)); }