@Test public void pubSubWrapping() throws IOException { Event legacyEvent = legacyEventForResource("legacy_pubsub.json"); CloudEvent cloudEvent = GcfEvents.convertToCloudEvent(legacyEvent); assertThat(new String(cloudEvent.getData(), UTF_8)) .isEqualTo("{\"message\":{\"@type\":\"type.googleapis.com/google.pubsub.v1.PubsubMessage\"," + "\"attributes\":{\"attribute1\":\"value1\"}," + "\"data\":\"VGhpcyBpcyBhIHNhbXBsZSBtZXNzYWdl\"}}"); }
static CloudEvent convertToCloudEvent(Event legacyEvent) { String eventType = legacyEvent.getContext().eventType(); EventAdapter eventAdapter = EVENT_TYPE_MAPPING.get(eventType); if (eventAdapter == null) { throw new IllegalArgumentException("Unrecognized event type \"" + eventType + "\""); } return eventAdapter.convertToCloudEvent(legacyEvent); }
GcfEvents { static CloudEvent convertToCloudEvent(Event legacyEvent) { String eventType = legacyEvent.getContext().eventType(); EventAdapter eventAdapter = EVENT_TYPE_MAPPING.get(eventType); if (eventAdapter == null) { throw new IllegalArgumentException("Unrecognized event type \"" + eventType + "\""); } return eventAdapter.convertToCloudEvent(legacyEvent); } }
GcfEvents { static CloudEvent convertToCloudEvent(Event legacyEvent) { String eventType = legacyEvent.getContext().eventType(); EventAdapter eventAdapter = EVENT_TYPE_MAPPING.get(eventType); if (eventAdapter == null) { throw new IllegalArgumentException("Unrecognized event type \"" + eventType + "\""); } return eventAdapter.convertToCloudEvent(legacyEvent); }  }
GcfEvents { static CloudEvent convertToCloudEvent(Event legacyEvent) { String eventType = legacyEvent.getContext().eventType(); EventAdapter eventAdapter = EVENT_TYPE_MAPPING.get(eventType); if (eventAdapter == null) { throw new IllegalArgumentException("Unrecognized event type \"" + eventType + "\""); } return eventAdapter.convertToCloudEvent(legacyEvent); }   }
GcfEvents { static CloudEvent convertToCloudEvent(Event legacyEvent) { String eventType = legacyEvent.getContext().eventType(); EventAdapter eventAdapter = EVENT_TYPE_MAPPING.get(eventType); if (eventAdapter == null) { throw new IllegalArgumentException("Unrecognized event type \"" + eventType + "\""); } return eventAdapter.convertToCloudEvent(legacyEvent); }    }