HelloGcs implements BackgroundFunction<GcsEvent> { @Override public void accept(GcsEvent event, Context context) { logger.info("Event: " + context.eventId()); logger.info("Event Type: " + context.eventType()); logger.info("Bucket: " + event.getBucket()); logger.info("File: " + event.getName()); logger.info("Metageneration: " + event.getMetageneration()); logger.info("Created: " + event.getTimeCreated()); logger.info("Updated: " + event.getUpdated()); }  @Override void accept(GcsEvent event, Context context);  }
@Test public void helloGcs_shouldPrintFileName() { GcsEvent event = new GcsEvent(); event.setName("foo.txt"); MockContext context = new MockContext(); context.eventType = "google.storage.object.finalize"; new HelloGcs().accept(event, context); String message = LOG_HANDLER.getStoredLogRecords().get(3).getMessage(); assertThat(message).contains("File: foo.txt"); }