@Test
  public void finishesJobsQueuedAfterUnbind() throws Exception {
    final Queue<Pair<Bundle, Integer>> callbackResults = new ArrayDeque<>();
    noopCallback =
        new IJobCallback.Stub() {
          @Override
          public void jobFinished(Bundle invocationData, @JobService.JobResult int result) {
            callbackResults.offer(Pair.create(invocationData, result));
          }
        };

    connection = new JobServiceConnection(noopCallback, contextMock);
    connection.onServiceConnected(null, binderMock);
    connection.onServiceDisconnected(null);

    assertThat(callbackResults).isEmpty();

    // If the job is queued after the connection has been unbound (regardless of reason) then we
    // should NOT start it and should instead send a retry message via the callback
    connection.startJob(job);

    assertThat(callbackResults).hasSize(1);
    Pair<Bundle, Integer> result = callbackResults.poll();
    assertBundlesEqual(jobData, result.first);
    assertThat(result.second).isEqualTo(Integer.valueOf(JobService.RESULT_FAIL_RETRY));
  }
The combination of Mockito and ShadowBinder ends up meaning we can't just wrap the IBinder in a
spy. So this is a manually created mock object.
jobdispatcher/src/test/java/com/firebase/jobdispatcher/JobServiceConnectionTest.java