SubscribeToTopic implements BackgroundFunction<PubSubMessage> { @Override public void accept(PubSubMessage message, Context context) { if (message.getData() == null) { logger.info("No message provided"); return; } String messageString = new String( Base64.getDecoder().decode(message.getData().getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8); logger.info(messageString); }  @Override void accept(PubSubMessage message, Context context);  }
@Test public void functionsPubsubSubscribe_shouldPrintPubsubMessage() throws Exception { String encodedData = Base64.getEncoder().encodeToString( "hello".getBytes(StandardCharsets.UTF_8)); PubSubMessage message = new PubSubMessage(); message.setData(encodedData); new SubscribeToTopic().accept(message, null); assertThat("hello").isEqualTo(logHandler.getStoredLogRecords().get(0).getMessage()); }