ActorCallLoader extends Loader<R> { @Override protected void onStartLoading() { if (mState == STATE_CALLING) { return; } if (mState == STATE_DONE) { deliverResult(mResult); return; } doLoad(); } ActorCallLoader(@NonNull Context context, @NonNull ActorsThreads actors, @NonNull ActorRef<A> actorRef);   }
@Test public void onStartLoading() { mLoader.onStartLoading(); mLoader.onStartLoading(); Mockito.verify(mActorImpl, Mockito.times(1)).getResult(); }
@SuppressWarnings("unchecked") @Test public void redeliverResult() { mLoader.onStartLoading(); final ArgumentCaptor<ResultListener> captor = ArgumentCaptor.forClass(ResultListener.class); Mockito.verify(mPromise).then(Mockito.same(mUiThread), captor.capture()); ResultListener listener = captor.getValue(); Assert.assertNotNull(listener); listener.onResult("Test"); Assert.assertTrue(mResultCaptor.resultDelivered); Assert.assertEquals("Test", mResultCaptor.result); Mockito.reset(mActorImpl); mResultCaptor.result = null; mResultCaptor.resultDelivered = false; mLoader.onStartLoading(); Mockito.verifyZeroInteractions(mActorImpl); Assert.assertTrue(mResultCaptor.resultDelivered); Assert.assertEquals("Test", mResultCaptor.result); }