### Question:
DisplayCallbacksImpl implements FirebaseInAppMessagingDisplayCallbacks { @Override public Task<Void> displayErrorEncountered(InAppMessagingErrorReason errorReason) { String RENDER_ERROR = "render error to metrics logger"; if (shouldLog()) { Logging.logd("Attempting to record: " + RENDER_ERROR); Completable completable = Completable.fromAction( () -> metricsLoggerClient.logRenderError(inAppMessage, errorReason)); return maybeToTask( logToImpressionStore().andThen(completable).andThen(updateWasImpressed()).toMaybe(), schedulers.io()); } logActionNotTaken(RENDER_ERROR); return new TaskCompletionSource<Void>().getTask(); } @VisibleForTesting  DisplayCallbacksImpl(
      ImpressionStorageClient impressionStorageClient,
      Clock clock,
      Schedulers schedulers,
      RateLimiterClient rateLimiterClient,
      CampaignCacheClient campaignCacheClient,
      RateLimit appForegroundRateLimit,
      MetricsLoggerClient metricsLoggerClient,
      DataCollectionHelper dataCollectionHelper,
      InAppMessage inAppMessage,
      String triggeringEvent); @Override Task<Void> impressionDetected(); @Override Task<Void> messageDismissed(InAppMessagingDismissType dismissType); @Deprecated Task<Void> messageClicked(); @Override Task<Void> messageClicked(Action action); @Override Task<Void> displayErrorEncountered(InAppMessagingErrorReason errorReason);  }### Answer:
@Test public void logRenderError_pipesErrorToEngagementMetrics() { displayCallbacksImpl.displayErrorEncountered(InAppMessagingErrorReason.IMAGE_DISPLAY_ERROR); verify(metricsLoggerClient) .logRenderError(BANNER_MESSAGE_MODEL, InAppMessagingErrorReason.IMAGE_DISPLAY_ERROR); assertThat(wasRecorded).isTrue(); }
@Test public void logRenderError_addsImpressionToStoreButDoesntLogToEngagementMetrics() { displayCallbacksImpl.displayErrorEncountered(InAppMessagingErrorReason.IMAGE_DISPLAY_ERROR); verify(metricsLoggerClient) .logRenderError(BANNER_MESSAGE_MODEL, InAppMessagingErrorReason.IMAGE_DISPLAY_ERROR); verify(metricsLoggerClient, never()).logImpression(BANNER_MESSAGE_MODEL); assertThat(wasRecorded).isTrue(); }
@Test public void logRenderError_doesNothingIfDataCollectionIsDisabled() { when(dataCollectionHelper.isAutomaticDataCollectionEnabled()).thenReturn(false); displayCallbacksImpl.displayErrorEncountered(InAppMessagingErrorReason.IMAGE_DISPLAY_ERROR); verify(metricsLoggerClient, times(0)) .logRenderError(BANNER_MESSAGE_MODEL, InAppMessagingErrorReason.IMAGE_DISPLAY_ERROR); }
@Test public void logRenderError_logsCorrectlyForTestMessage() { displayCallbacksImpl = displayCallbacksFactory.generateDisplayCallback( BANNER_TEST_MESSAGE_MODEL, ANALYTICS_EVENT_NAME); displayCallbacksImpl.displayErrorEncountered(InAppMessagingErrorReason.IMAGE_DISPLAY_ERROR); verify(metricsLoggerClient, times(1)) .logRenderError(BANNER_MESSAGE_MODEL, InAppMessagingErrorReason.IMAGE_DISPLAY_ERROR); }