// 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: functions-framework-api/src/main/java/com/google/cloud/functions/RawBackgroundFunction.java
// @FunctionalInterface
// public interface RawBackgroundFunction {
//   /**
//    * 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 json the payload of the event, as a 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(String json, Context context) throws Exception;
// }


import com.google.cloud.functions.Context;
import com.google.cloud.functions.RawBackgroundFunction;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.example.functionjar;


/**
 * @author emcmanus@google.com (Éamonn McManus)
 */
public class Background implements RawBackgroundFunction {
  @Override
// 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: functions-framework-api/src/main/java/com/google/cloud/functions/RawBackgroundFunction.java
// @FunctionalInterface
// public interface RawBackgroundFunction {
//   /**
//    * 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 json the payload of the event, as a 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(String json, Context context) throws Exception;
// }


// Path: invoker/testfunction/src/test/java/com/example/functionjar/Background.java
import com.google.cloud.functions.Context;
import com.google.cloud.functions.RawBackgroundFunction;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;

// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.example.functionjar;


/**
 * @author emcmanus@google.com (Éamonn McManus)
 */
public class Background implements RawBackgroundFunction {
  @Override
  public void accept(String json, Context context) {