### Question:
ModelHelper { public static Class<?> getAnnotatedResourceClass(Class<?> resourceClass, Class<? extends Annotation> annotation) { Class<?> foundInterface = null; Class<?> cls = resourceClass; do { if (cls.getDeclaredAnnotation(annotation) != null) { return cls; } if (foundInterface == null) { for (final Class<?> i : cls.getInterfaces()) { if (i.getDeclaredAnnotation(annotation) != null) { foundInterface = i; break; } } } cls = cls.getSuperclass(); } while (cls != null); if (foundInterface != null) { return foundInterface; } return resourceClass; } private  ModelHelper(); static Class<?> getAnnotatedResourceClass(Class<?> resourceClass, Class<? extends Annotation> annotation); static PrivilegedAction<Collection<? extends Method>> getDeclaredMethodsPA(final Class<?> clazz); static PrivilegedAction<Method> findMethodOnClassPA(final Class<?> cls, final Method m); static Type getArrayComponentType(final Type type); static Class<?> getArrayForComponentType(final Class<?> c); static MarshallerSupplier getMarshallerSupplier(GrpcMarshaller annotation); static Class<?> getGenericType(Type type);  }### Answer:
@Test public void shouldGetAnnotatedSuperClass() { Class<?> cls = ModelHelper.getAnnotatedResourceClass(ChildOne.class, Grpc.class); assertThat(cls, equalTo(Parent.class)); }
@Test public void shouldGetSelfIfAnnotated() { Class<?> cls = ModelHelper.getAnnotatedResourceClass(Parent.class, Grpc.class); assertThat(cls, equalTo(Parent.class)); }
@Test public void shouldGetSelfIfNothingAnnotated() { Class<?> cls = ModelHelper.getAnnotatedResourceClass(NoAnnotated.class, Grpc.class); assertThat(cls, equalTo(NoAnnotated.class)); }
@Test public void shouldGetAnnotatedSuperClassBeforeInterface() { Class<?> cls = ModelHelper.getAnnotatedResourceClass(ChildTwo.class, Grpc.class); assertThat(cls, equalTo(Parent.class)); }
@Test public void shouldGetAnnotatedInterface() { Class<?> cls = ModelHelper.getAnnotatedResourceClass(ChildThree.class, Grpc.class); assertThat(cls, equalTo(IFaceOne.class)); }