### Question:
MainThreadRequestListener extends RequestListenerWrapper<R> { @Override public void onError(final int response, @Nonnull final Exception e) { mErrorRunnable = new Runnable() { @Override public void run() { mListener.onError(response, e); } }; mMainThread.execute(mErrorRunnable); } MainThreadRequestListener(@Nonnull CancellableExecutor mainThread, @Nonnull RequestListener<R> listener); @Override void onSuccess(@Nonnull final R result); @Override void onError(final int response, @Nonnull final Exception e); void onCancel();  }### Answer:
@Test public void testShouldCallOnError() throws Exception { final RequestListener l = mock(RequestListener.class); final MainThreadRequestListener mtl = new MainThreadRequestListener(Tests.sameThreadExecutor(), l); final Exception e = new Exception(); mtl.onError(3, e); verify(l).onError(eq(3), eq(e)); }
@Test public void testShouldCancelErrorRunnable() throws Exception { final RequestListener l = mock(RequestListener.class); final CancellableExecutor executor = new TestExecutor(); final MainThreadRequestListener mtl = new MainThreadRequestListener(executor, l); mtl.onError(3, new Exception()); mtl.cancel(); }