@Test public void firestoreSimpleData() throws IOException { Event legacyEvent = legacyEventForResource("firestore_simple.json"); CloudEvent cloudEvent = GcfEvents.convertToCloudEvent(legacyEvent); Map<String, Object> data = cloudEventDataJson(cloudEvent); Map<String, Object> expectedValue = Map.of( "name", "projects/project-id/databases/(default)/documents/gcf-test/2Vm2mI1d0wIaK2Waj5to", "createTime", "2020-04-23T09:58:53.211035Z", "updateTime", "2020-04-23T12:00:27.247187Z", "fields", Map.of( "another test", Map.of("stringValue", "asd"), "count", Map.of("integerValue", "4"), "foo", Map.of("stringValue", "bar"))); Map<String, Object> expectedOldValue = Map.of( "name", "projects/project-id/databases/(default)/documents/gcf-test/2Vm2mI1d0wIaK2Waj5to", "createTime", "2020-04-23T09:58:53.211035Z", "updateTime", "2020-04-23T12:00:27.247187Z", "fields", Map.of( "another test", Map.of("stringValue", "asd"), "count", Map.of("integerValue", "3"), "foo", Map.of("stringValue", "bar"))); assertThat(data).containsAtLeast( "value", expectedValue, "oldValue", expectedOldValue, "updateMask", Map.of("fieldPaths", List.of("count"))); }
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); }    }