@Test @SmallTest public void testFromWorkSpec_hasCorrectRuntimeExtras() { OneTimeWorkRequest work = new OneTimeWorkRequest.Builder(TestWorker.class).build(); Extras.RuntimeExtras runtimeExtras = new Extras.RuntimeExtras(); runtimeExtras.triggeredContentAuthorities = new String[]{"tca1", "tca2", "tca3"}; runtimeExtras.triggeredContentUris = new Uri[]{Uri.parse("tcu1"), Uri.parse("tcu2")}; Worker worker = WorkerWrapper.workerFromWorkSpec( mContext, getWorkSpec(work), new Extras(Data.EMPTY, Collections.<String>emptyList(), runtimeExtras, 1)); assertThat(worker, is(notNullValue())); assertThat(worker.getTriggeredContentAuthorities(), arrayContaining(runtimeExtras.triggeredContentAuthorities)); assertThat(worker.getTriggeredContentUris(), arrayContaining(runtimeExtras.triggeredContentUris)); }
static Worker workerFromWorkSpec(@NonNull Context context, @NonNull WorkSpec workSpec, @NonNull Extras extras) { String workerClassName = workSpec.workerClassName; UUID workSpecId = UUID.fromString(workSpec.id); return workerFromClassName( context, workerClassName, workSpecId, extras); }
WorkerWrapper implements Runnable { static Worker workerFromWorkSpec(@NonNull Context context, @NonNull WorkSpec workSpec, @NonNull Extras extras) { String workerClassName = workSpec.workerClassName; UUID workSpecId = UUID.fromString(workSpec.id); return workerFromClassName( context, workerClassName, workSpecId, extras); } }
WorkerWrapper implements Runnable { static Worker workerFromWorkSpec(@NonNull Context context, @NonNull WorkSpec workSpec, @NonNull Extras extras) { String workerClassName = workSpec.workerClassName; UUID workSpecId = UUID.fromString(workSpec.id); return workerFromClassName( context, workerClassName, workSpecId, extras); } private  WorkerWrapper(Builder builder); }
WorkerWrapper implements Runnable { static Worker workerFromWorkSpec(@NonNull Context context, @NonNull WorkSpec workSpec, @NonNull Extras extras) { String workerClassName = workSpec.workerClassName; UUID workSpecId = UUID.fromString(workSpec.id); return workerFromClassName( context, workerClassName, workSpecId, extras); } private  WorkerWrapper(Builder builder); @WorkerThread @Override void run(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void interrupt(boolean cancelled); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @SuppressWarnings("ClassNewInstance") static Worker workerFromClassName(
            @NonNull Context context,
            @NonNull String workerClassName,
            @NonNull UUID workSpecId,
            @NonNull Extras extras); }
WorkerWrapper implements Runnable { static Worker workerFromWorkSpec(@NonNull Context context, @NonNull WorkSpec workSpec, @NonNull Extras extras) { String workerClassName = workSpec.workerClassName; UUID workSpecId = UUID.fromString(workSpec.id); return workerFromClassName( context, workerClassName, workSpecId, extras); } private  WorkerWrapper(Builder builder); @WorkerThread @Override void run(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void interrupt(boolean cancelled); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @SuppressWarnings("ClassNewInstance") static Worker workerFromClassName(
            @NonNull Context context,
            @NonNull String workerClassName,
            @NonNull UUID workSpecId,
            @NonNull Extras extras);  }