AdapterWrapper { void display(@NonNull Context context) throws DisplayException { Logger.debug("AdapterWrapper - Displaying message for schedule %s", scheduleId); displayed = true; try { DisplayHandler displayHandler = new DisplayHandler(scheduleId); adapter.onDisplay(context, displayHandler); coordinator.onDisplayStarted(message); } catch (Exception e) { throw new DisplayException("Adapter onDisplay(Activity, boolean, DisplayHandler) unexpected exception", e); } } 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 testDisplay() throws AdapterWrapper.DisplayException { adapterWrapper.display(context); verify(mockAdapter).onDisplay(eq(context), any(DisplayHandler.class)); verify(mockCoordinator).onDisplayStarted(adapterWrapper.message); }
@Test(expected = AdapterWrapper.DisplayException.class) public void testDisplayAdapterException() throws AdapterWrapper.DisplayException { doThrow(new RuntimeException("neat")) .when(mockAdapter).onDisplay(any(Context.class), any(DisplayHandler.class)); adapterWrapper.display(context); }
@Test(expected = AdapterWrapper.DisplayException.class) public void testDisplayCoordinatorException() throws AdapterWrapper.DisplayException { doThrow(new RuntimeException("neat")) .when(mockCoordinator).onDisplayStarted(adapterWrapper.message); adapterWrapper.display(context); }