@Test public void testMultipleFinish() throws InterruptedException { JobService.Binder binder = (JobService.Binder) Robolectric.buildService(NoopAsyncJobService.class).create().get().onBind(null); final CountDownLatch doneSignal = new CountDownLatch(PARALLEL_COUNT); for (int i = 0; i < PARALLEL_COUNT; i++) { JobParameters jobParams = new JobParameters( params.getJobId() + i, params.getExtras(), params.getTransientExtras(), null, params.getTriggeredContentUris(), params.getTriggeredContentAuthorities(), params.isOverrideDeadlineExpired()); assertTrue(binder.startJob(jobParams, new JobService.Binder.Callback() { @Override public void jobFinished(JobParameters params, boolean needsReschedule) { doneSignal.countDown(); } })); } assertTrue(doneSignal.await(TIMEOUT_MS * Math.max(1, PARALLEL_COUNT / 4), TimeUnit.MILLISECONDS)); }
@NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; }
JobService extends Service { @NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; } }
JobService extends Service { @NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; }  }
JobService extends Service { @NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; }  @NonNull @Override final IBinder onBind(Intent intent); abstract boolean onStartJob(JobParameters params); abstract boolean onStopJob(JobParameters params); final void jobFinished(JobParameters params, boolean needsReschedule); }
JobService extends Service { @NonNull @Override public final IBinder onBind(Intent intent) { if (binder == null) { binder = new Binder(this); } return binder; }  @NonNull @Override final IBinder onBind(Intent intent); abstract boolean onStartJob(JobParameters params); abstract boolean onStopJob(JobParameters params); final void jobFinished(JobParameters params, boolean needsReschedule);  }