### Question:
InterfaceUtils { @SuppressWarnings("unchecked") public static Class<Service> getInterface(final Service service) { Class<Service> clazz = null; Class<?> classExamining = service.getClass(); while (classExamining != null) { for (Class<?> intfClass : classExamining.getInterfaces()) { if (Service.class.isAssignableFrom(intfClass)) { clazz = (Class<Service>)intfClass; break; } } classExamining = classExamining.getSuperclass(); } return clazz; }  @SuppressWarnings("unchecked") static Class<Service> getInterface(final Service service);  }### Answer:
@Test public void testExtendsSimple() { Class<Service> service = InterfaceUtils.getInterface(new ExtendsSimple() { public void init(ContainerContext cc) { } }); assertEquals(ExtendsSimple.class, service); }
@Test public void testExtendsMany() { Class<Service> service = InterfaceUtils.getInterface(new ExtendsMany()); assertEquals(ExtendsSimple.class, service); }