AdapterWrapper { @InAppMessageAdapter.PrepareResult int prepare(@NonNull Context context, @NonNull Assets assets) { try { Logger.debug("AdapterWrapper - Preparing message for schedule %s", scheduleId); return adapter.onPrepare(context, assets); } catch (Exception e) { Logger.error(e, "AdapterWrapper - Exception during prepare(Context)."); return InAppMessageAdapter.RETRY; } } AdapterWrapper(@NonNull String scheduleId,
                   @NonNull InAppMessage message,
                   @NonNull InAppMessageAdapter adapter,
                   @NonNull DisplayCoordinator coordinator);  final String scheduleId; final InAppMessage message; final InAppMessageAdapter adapter; final DisplayCoordinator coordinator; public boolean displayed; }
@Test public void testPrepare() { Assets mockAssets = mock(Assets.class); when(mockAdapter.onPrepare(context, mockAssets)).thenReturn(InAppMessageAdapter.CANCEL); int result = adapterWrapper.prepare(context, mockAssets); assertEquals(InAppMessageAdapter.CANCEL, result); }
@Test public void testPrepareException() { Assets mockAssets = mock(Assets.class); when(mockAdapter.onPrepare(context, mockAssets)).thenThrow(new RuntimeException("neat")); int result = adapterWrapper.prepare(context, mockAssets); assertEquals(InAppMessageAdapter.RETRY, result); }