HaloJobScheduler { @Api(2.0) public void schedule(@NonNull Job job) { AssertionUtils.notNull(job, "job"); if (mServiceBinder == null) { mPendingList.put(job.info().mIdentity, job); } else { mServiceBinder.schedule(job); } } HaloJobScheduler(@NonNull Context context, @NonNull HaloThreadManager threadManger); @Api(2.0) void schedule(@NonNull Job job); @Api(2.0) void schedule(@NonNull Job... jobs); @Api(2.0) void cancel(@NonNull String tag); @Api(2.0) void closeDoor(); @Api(2.0) void stopAndReset();  }
@Test public void thatCanScheduleAJob() throws NoSuchFieldException, IllegalAccessException { HaloJobScheduler haloJobScheduler = givenAHaloJobScheduler(); Job job = givenAJob(mCallbackFlag,"job"); haloJobScheduler.schedule(job); HashMap<String, Job> pendingList = getPendingListByReflection(haloJobScheduler); assertThat(pendingList.containsKey(job.info().mTag)).isFalse(); }
@Test public void thatCanScheduleAListOfJobs() throws NoSuchFieldException, IllegalAccessException { HaloJobScheduler haloJobScheduler = givenAHaloJobScheduler(); Job job1 = givenAJob(mCallbackFlag,"job1"); Job job2 = givenAJob(mCallbackFlag,"job2"); Job [] jobs = new Job[] {job1,job2}; haloJobScheduler.schedule(jobs); HashMap<String, Job> pendingList = getPendingListByReflection(haloJobScheduler); assertThat(pendingList.containsKey(job1.info().mTag)).isFalse(); assertThat(pendingList.containsKey(job2.info().mTag)).isFalse(); }