// Path: invoker/core/src/main/java/com/google/cloud/functions/invoker/BackgroundFunctionExecutor.java
// static Optional<Type> backgroundFunctionTypeArgument(
//     Class<? extends BackgroundFunction<?>> functionClass) {
//   // If this is BackgroundFunction<Foo> then the user must have implemented a method
//   // accept(Foo, Context), so we look for that method and return the type of its first argument.
//   // We must be careful because the compiler will also have added a synthetic method
//   // accept(Object, Context).
//   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();
// }
// 
// Path: functions-framework-api/src/main/java/com/google/cloud/functions/BackgroundFunction.java
// @FunctionalInterface
// public interface BackgroundFunction<T> {
//   /**
//    * Called to service an incoming event. This interface is implemented by user code to provide the
//    * action for a given background function. If this method throws any exception (including any
//    * {@link Error}) then the HTTP response will have a 500 status code.
//    *
//    * @param payload the payload of the event, deserialized from the original JSON string.
//    * @param context the context of the event. This is a set of values that every event has,
//    *     separately from the payload, such as timestamp and event type.
//    * @throws Exception to produce a 500 status code in the HTTP response.
//    */
//   void accept(T payload, Context context) throws Exception;
// }
// 
// Path: functions-framework-api/src/main/java/com/google/cloud/functions/Context.java
// public interface Context {
//   /**
//    * Returns event ID.
//    *
//    * @return event ID
//    */
//   String eventId();
// 
//   /**
//    * Returns event timestamp.
//    *
//    * @return event timestamp
//    */
//   String timestamp();
// 
//   /**
//    * Returns event type.
//    *
//    * @return event type
//    */
//   String eventType();
// 
//   /**
//    * Returns event resource.
//    *
//    * @return event resource
//    */
//   String resource();
// 
//   /**
//    * Returns additional attributes from this event. For CloudEvents, the entries in this map will
//    * include the <a
//    * href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#required-attributes">required
//    * attributes</a> and may include <a
//    * href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#required-attributes">optional
//    * attributes</a> and <a
//    * href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#extension-context-attributes">
//    * extension attributes</a>.
//    *
//    * <p>The map returned by this method may be empty but is never null.
//    *
//    * @return additional attributes form this event.
//    */
//   default Map<String, String> attributes() {
//     return Collections.emptyMap();
//   }
// }


import static com.google.cloud.functions.invoker.BackgroundFunctionExecutor.backgroundFunctionTypeArgument;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.google.cloud.functions.BackgroundFunction;
import com.google.cloud.functions.Context;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
package com.google.cloud.functions.invoker;



@RunWith(JUnit4.class)
public class BackgroundFunctionExecutorTest {
  private static class PubSubMessage {
    String data;
    Map<String, String> attributes;
    String messageId;
    String publishTime;
  }

  private static class PubSubFunction implements BackgroundFunction<PubSubMessage> {
    @Override
// Path: invoker/core/src/main/java/com/google/cloud/functions/invoker/BackgroundFunctionExecutor.java
// static Optional<Type> backgroundFunctionTypeArgument(
//     Class<? extends BackgroundFunction<?>> functionClass) {
//   // If this is BackgroundFunction<Foo> then the user must have implemented a method
//   // accept(Foo, Context), so we look for that method and return the type of its first argument.
//   // We must be careful because the compiler will also have added a synthetic method
//   // accept(Object, Context).
//   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();
// }
// 
// Path: functions-framework-api/src/main/java/com/google/cloud/functions/BackgroundFunction.java
// @FunctionalInterface
// public interface BackgroundFunction<T> {
//   /**
//    * Called to service an incoming event. This interface is implemented by user code to provide the
//    * action for a given background function. If this method throws any exception (including any
//    * {@link Error}) then the HTTP response will have a 500 status code.
//    *
//    * @param payload the payload of the event, deserialized from the original JSON string.
//    * @param context the context of the event. This is a set of values that every event has,
//    *     separately from the payload, such as timestamp and event type.
//    * @throws Exception to produce a 500 status code in the HTTP response.
//    */
//   void accept(T payload, Context context) throws Exception;
// }
// 
// Path: functions-framework-api/src/main/java/com/google/cloud/functions/Context.java
// public interface Context {
//   /**
//    * Returns event ID.
//    *
//    * @return event ID
//    */
//   String eventId();
// 
//   /**
//    * Returns event timestamp.
//    *
//    * @return event timestamp
//    */
//   String timestamp();
// 
//   /**
//    * Returns event type.
//    *
//    * @return event type
//    */
//   String eventType();
// 
//   /**
//    * Returns event resource.
//    *
//    * @return event resource
//    */
//   String resource();
// 
//   /**
//    * Returns additional attributes from this event. For CloudEvents, the entries in this map will
//    * include the <a
//    * href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#required-attributes">required
//    * attributes</a> and may include <a
//    * href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#required-attributes">optional
//    * attributes</a> and <a
//    * href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#extension-context-attributes">
//    * extension attributes</a>.
//    *
//    * <p>The map returned by this method may be empty but is never null.
//    *
//    * @return additional attributes form this event.
//    */
//   default Map<String, String> attributes() {
//     return Collections.emptyMap();
//   }
// }


// Path: invoker/core/src/test/java/com/google/cloud/functions/invoker/BackgroundFunctionExecutorTest.java
import static com.google.cloud.functions.invoker.BackgroundFunctionExecutor.backgroundFunctionTypeArgument;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.google.cloud.functions.BackgroundFunction;
import com.google.cloud.functions.Context;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

package com.google.cloud.functions.invoker;



@RunWith(JUnit4.class)
public class BackgroundFunctionExecutorTest {
  private static class PubSubMessage {
    String data;
    Map<String, String> attributes;
    String messageId;
    String publishTime;
  }

  private static class PubSubFunction implements BackgroundFunction<PubSubMessage> {
    @Override
    public void accept(PubSubMessage payload, Context context) {}