### Question:
JobInfoScheduler implements WorkScheduler { @Override public void schedule(TransportContext transportContext, int attemptNumber) { ComponentName serviceComponent = new ComponentName(context, JobInfoSchedulerService.class); JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); int jobId = getJobId(transportContext); if (isJobServiceOn(jobScheduler, jobId, attemptNumber)) { Logging.d( LOG_TAG, "Upload for context %s is already scheduled. Returning...", transportContext); return; } long nextCallTime = eventStore.getNextCallTime(transportContext); JobInfo.Builder builder = config.configureJob( new JobInfo.Builder(jobId, serviceComponent), transportContext.getPriority(), nextCallTime, attemptNumber); PersistableBundle bundle = new PersistableBundle(); bundle.putInt(ATTEMPT_NUMBER, attemptNumber); bundle.putString(BACKEND_NAME, transportContext.getBackendName()); bundle.putInt(EVENT_PRIORITY, PriorityMapping.toInt(transportContext.getPriority())); if (transportContext.getExtras() != null) { bundle.putString(EXTRAS, encodeToString(transportContext.getExtras(), DEFAULT)); } builder.setExtras(bundle); Logging.d( LOG_TAG, "Scheduling upload for context %s with jobId=%d in %dms(Backend next call timestamp %d). Attempt %d", transportContext, jobId, config.getScheduleDelay(transportContext.getPriority(), nextCallTime, attemptNumber), nextCallTime, attemptNumber); jobScheduler.schedule(builder.build()); } JobInfoScheduler(
      Context applicationContext, EventStore eventStore, SchedulerConfig config); @Override void schedule(TransportContext transportContext, int attemptNumber);  }### Answer:
@Test public void schedule_whenExtrasEvailable_transmitsExtras() { String extras = "e1"; TransportContext transportContext = TransportContext.builder() .setBackendName("backend1") .setExtras(extras.getBytes(Charset.defaultCharset())) .build(); store.recordNextCallTime(transportContext, 1000000); scheduler.schedule(transportContext, 1); JobInfo jobInfo = jobScheduler.getAllPendingJobs().get(0); PersistableBundle bundle = jobInfo.getExtras(); assertThat(bundle.get(JobInfoScheduler.EXTRAS)) .isEqualTo( Base64.encodeToString(extras.getBytes(Charset.defaultCharset()), Base64.DEFAULT)); }
@Test public void schedule_withMultipleContexts_whenExtrasAvailable_schedulesForBothContexts() { String extras1 = "e1"; String extras2 = "e2"; TransportContext ctx1 = TransportContext.builder() .setBackendName("backend1") .setExtras(extras1.getBytes(Charset.defaultCharset())) .build(); TransportContext ctx2 = TransportContext.builder() .setBackendName("backend1") .setExtras(extras2.getBytes(Charset.defaultCharset())) .build(); store.recordNextCallTime(ctx1, 1000000); store.recordNextCallTime(ctx2, 1000000); scheduler.schedule(ctx1, 1); scheduler.schedule(ctx2, 1); assertThat(jobScheduler.getAllPendingJobs()).hasSize(2); JobInfo jobInfo = jobScheduler.getAllPendingJobs().get(0); PersistableBundle bundle = jobInfo.getExtras(); assertThat(bundle.get(JobInfoScheduler.EXTRAS)) .isEqualTo( Base64.encodeToString(extras1.getBytes(Charset.defaultCharset()), Base64.DEFAULT)); jobInfo = jobScheduler.getAllPendingJobs().get(1); bundle = jobInfo.getExtras(); assertThat(bundle.get(JobInfoScheduler.EXTRAS)) .isEqualTo( Base64.encodeToString(extras2.getBytes(Charset.defaultCharset()), Base64.DEFAULT)); }