### Question:
DesugarWorkerItem { public void configure(WorkerConfiguration workerConfiguration) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( "desugar configuring in {}", ManagementFactory.getRuntimeMXBean().getName()); } workerConfiguration.setIsolationMode(IsolationMode.PROCESS); workerConfiguration.classpath(ImmutableList.of(java8LangSupportJar.toFile())); workerConfiguration.forkOptions( javaForkOptions -> javaForkOptions.setJvmArgs( ImmutableList.of( "-Xmx64m", "-Djdk.internal.lambda.dumpProxyClasses=" + lambdaTmpDir.toString()))); boolean isWindows = SdkConstants.currentPlatform() == SdkConstants.PLATFORM_WINDOWS; workerConfiguration.setParams(args.getArgs(isWindows)); } DesugarWorkerItem(
            @NonNull Path java8LangSupportJar,
            @NonNull DesugarProcessArgs args,
            @NonNull Path lambdaTmpDir); void configure(WorkerConfiguration workerConfiguration);  }### Answer:
@Test public void testWorkerConfiguration() throws IOException { DesugarProcessArgs args = new DesugarProcessArgs( ImmutableMap.of("/dev/null", "/dev/null"), ImmutableList.of(), ImmutableList.of(), temporaryFolder.newFolder().toString(), true, 21, true); DesugarWorkerItem workerItem = new DesugarWorkerItem(java8SupportJar, args, temporaryFolder.getRoot().toPath()); when(workerConfiguration.getForkOptions()).thenReturn(options); doAnswer( invocation -> { Action<? super JavaForkOptions> action = (Action<? super JavaForkOptions>) invocation.getArguments()[0]; action.execute(options); return null; }) .when(workerConfiguration) .forkOptions(forOptionsCaptor.capture()); workerItem.configure(workerConfiguration); verify(options) .setJvmArgs( ImmutableList.of( "-Xmx64m", "-Djdk.internal.lambda.dumpProxyClasses=" + temporaryFolder.getRoot().toPath().toString())); verify(workerConfiguration).forkOptions(forOptionsCaptor.capture()); forOptionsCaptor.getValue().execute(options); verify(workerConfiguration).setIsolationMode(IsolationMode.PROCESS); List<String> params = Arrays.asList( "--verbose", "--input", "/dev/null", "--output", "/dev/null", "--min_sdk_version", "21", "--nodesugar_try_with_resources_if_needed", "--desugar_try_with_resources_omit_runtime_classes", "--legacy_jacoco_fix", "--copy_bridges_from_classpath"); verify(workerConfiguration).setParams(params); }
@Test public void testClasspath() throws IOException { DesugarProcessArgs args = new DesugarProcessArgs( ImmutableMap.of("/dev/null", "/dev/null"), ImmutableList.of("path/to/1.jar", "path/to/2.jar"), ImmutableList.of(), temporaryFolder.newFolder().toString(), true, 21, true); DesugarWorkerItem workerItem = new DesugarWorkerItem(java8SupportJar, args, temporaryFolder.getRoot().toPath()); doNothing().when(workerConfiguration).classpath(classpathCaptor.capture()); workerItem.configure(workerConfiguration); assertThat(classpathCaptor.getValue()).contains(java8SupportJar.toFile()); }
@Test public void testParameters() throws IOException { DesugarProcessArgs args = new DesugarProcessArgs( ImmutableMap.of("/dev/null", "/dev/null"), ImmutableList.of(), ImmutableList.of(), temporaryFolder.newFolder().toString(), false, 23, true); DesugarWorkerItem workerItem = new DesugarWorkerItem(java8SupportJar, args, temporaryFolder.getRoot().toPath()); workerItem.configure(workerConfiguration); List<String> params = Arrays.asList( "--input", "/dev/null", "--output", "/dev/null", "--min_sdk_version", "23", "--nodesugar_try_with_resources_if_needed", "--desugar_try_with_resources_omit_runtime_classes", "--legacy_jacoco_fix", "--copy_bridges_from_classpath"); verify(workerConfiguration).setParams(params); }