InAppMessageManager { @MainThread @AutomationDriver.ReadyResult @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public int onCheckExecutionReadiness(@NonNull String scheduleId) { AdapterWrapper adapterWrapper = adapterWrappers.get(scheduleId); if (adapterWrapper == null) { Logger.error("Missing adapter for schedule %.", scheduleId); return AutomationDriver.READY_RESULT_INVALIDATE; } if (adapterWrapper.isReady(context)) { return AutomationDriver.READY_RESULT_CONTINUE; } else { return AutomationDriver.READY_RESULT_NOT_READY; } } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  InAppMessageManager(@NonNull Context context,
                               @NonNull PreferenceDataStore dataStore,
                               @NonNull Analytics analytics,
                               @NonNull Delegate delegate); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  InAppMessageManager(@NonNull Context context,
                        @NonNull PreferenceDataStore dataStore,
                        @NonNull Analytics analytics,
                        @NonNull RetryingExecutor executor,
                        @NonNull ActionRunRequestFactory runRequestFactory,
                        @NonNull AssetManager assetManager,
                        @NonNull Delegate delegate); void setAdapterFactory(@NonNull @InAppMessage.DisplayType String displayType, @Nullable InAppMessageAdapter.Factory factory); void setDisplayInterval(@IntRange(from = 0) long time, @NonNull TimeUnit timeUnit); long getDisplayInterval(); @NonNull AssetManager getAssetManager(); void addListener(@NonNull InAppMessageListener listener); void removeListener(@NonNull InAppMessageListener listener); void setMessageExtender(@Nullable InAppMessageExtender extender); void setOnRequestDisplayCoordinatorCallback(@Nullable OnRequestDisplayCoordinatorCallback callback); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void onAirshipReady(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void onPrepare(final @NonNull String scheduleId,
                          final @NonNull InAppMessage inAppMessage,
                          final @NonNull AutomationDriver.PrepareScheduleCallback callback); @MainThread @AutomationDriver.ReadyResult @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) int onCheckExecutionReadiness(@NonNull String scheduleId); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @MainThread void onExecute(@NonNull String scheduleId, @NonNull AutomationDriver.ExecutionCallback callback); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void onExecutionInvalidated(@NonNull final String scheduleId); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void onMessageScheduleFinished(@NonNull final String scheduleId); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void onNewMessageSchedule(@NonNull final String scheduleId, @NonNull final InAppMessage message); static final long DEFAULT_DISPLAY_INTERVAL_MS; }
@Test public void testOnCheckExecutionReadiness() { when(mockAssetManager.onPrepare(scheduleId, message)).thenReturn(AssetManager.PREPARE_RESULT_OK); when(mockAdapter.onPrepare(any(Context.class), any(Assets.class))).thenReturn(InAppMessageAdapter.OK); when(mockAdapter.isReady(any(Context.class))).thenReturn(true); AutomationDriver.PrepareScheduleCallback mockCallback = mock(AutomationDriver.PrepareScheduleCallback.class); manager.onPrepare(scheduleId, message, mockCallback); verify(mockAdapter).onPrepare(any(Context.class), any(Assets.class)); verify(mockCallback).onFinish(AutomationDriver.PREPARE_RESULT_CONTINUE); assertEquals(AutomationDriver.READY_RESULT_CONTINUE, manager.onCheckExecutionReadiness(scheduleId)); }