### Question:
BackgroundFunctionExecutor extends HttpServlet { static Optional<Type> backgroundFunctionTypeArgument( Class<? extends BackgroundFunction<?>> functionClass) { return Arrays.stream(functionClass.getMethods()) .filter(m -> m.getName().equals("accept") && m.getParameterCount() == 2 && m.getParameterTypes()[1] == Context.class && m.getParameterTypes()[0] != Object.class) .map(m -> m.getGenericParameterTypes()[0]) .findFirst(); } private  BackgroundFunctionExecutor(FunctionExecutor<?> functionExecutor); static Optional<BackgroundFunctionExecutor> maybeForClass(Class<?> functionClass); static BackgroundFunctionExecutor forClass(Class<?> functionClass); @Override void service(HttpServletRequest req, HttpServletResponse res);  }### Answer:
@Test public void backgroundFunctionTypeArgument_simple() { assertThat(backgroundFunctionTypeArgument(PubSubFunction.class)).hasValue(PubSubMessage.class); }
@Test public void backgroundFunctionTypeArgument_superclass() { assertThat(backgroundFunctionTypeArgument(Child.class)).hasValue(PubSubMessage.class); }
@Test public void backgroundFunctionTypeArgument_genericInterface() { assertThat(backgroundFunctionTypeArgument(GenericChild.class)).hasValue(PubSubMessage.class); }
@Test public void backgroundFunctionTypeArgument_raw() { @SuppressWarnings("unchecked") Class<? extends BackgroundFunction<?>> c = (Class<? extends BackgroundFunction<?>>) (Class<?>) ForgotTypeParameter.class; assertThat(backgroundFunctionTypeArgument(c)).isEmpty(); }