### Question:
DisplayCallbacksImpl implements FirebaseInAppMessagingDisplayCallbacks { @Override public Task<Void> messageDismissed(InAppMessagingDismissType dismissType) { String MESSAGE_DISMISSAL = "message dismissal to metrics logger"; if (shouldLog()) { Logging.logd("Attempting to record: " + MESSAGE_DISMISSAL); Completable completable = Completable.fromAction(() -> metricsLoggerClient.logDismiss(inAppMessage, dismissType)); return logImpressionIfNeeded(completable); } logActionNotTaken(MESSAGE_DISMISSAL); 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 logDismiss_pipesDismissToEngagementMetrics() { displayCallbacksImpl.messageDismissed(InAppMessagingDismissType.SWIPE); verify(metricsLoggerClient).logDismiss(BANNER_MESSAGE_MODEL, InAppMessagingDismissType.SWIPE); assertThat(wasRecorded).isTrue(); }
@Test public void logDismiss_logsImpressionIfNotAlreadyImpressed() { displayCallbacksImpl.messageDismissed(InAppMessagingDismissType.SWIPE); verify(metricsLoggerClient).logDismiss(BANNER_MESSAGE_MODEL, InAppMessagingDismissType.SWIPE); verify(metricsLoggerClient, times(1)).logImpression(BANNER_MESSAGE_MODEL); assertThat(wasRecorded).isTrue(); }
@Test public void logDismiss_doesNothingIfDataCollectionIsDisabled() { when(dataCollectionHelper.isAutomaticDataCollectionEnabled()).thenReturn(false); displayCallbacksImpl.messageDismissed(InAppMessagingDismissType.SWIPE); verify(metricsLoggerClient, times(0)) .logDismiss(BANNER_MESSAGE_MODEL, InAppMessagingDismissType.SWIPE); }
@Test public void logDismiss_logsCorrectlyForTestMessage() { displayCallbacksImpl = displayCallbacksFactory.generateDisplayCallback( BANNER_TEST_MESSAGE_MODEL, ANALYTICS_EVENT_NAME); displayCallbacksImpl.messageDismissed(InAppMessagingDismissType.SWIPE); verify(metricsLoggerClient, times(1)) .logDismiss(BANNER_MESSAGE_MODEL, InAppMessagingDismissType.SWIPE); }