@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(); }
@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(); }
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(); } }
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); }
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); }
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);  }